Game Development Community

Switch and Set Skin Texture with multiple meshes

by Joel Hargarten · in Torque Game Engine · 07/10/2006 (7:28 am) · 9 replies

Hey.
I've created a model that has multiple meshes in it each with a different texture. How do I change what texture file it uses while in game? I know that you can use %player.setSkinName("red"); to set it for the entire model if you just have one mesh in your DTS shape, but how do I specify which one to change if I have more than one mesh? Could I just use %player.Mesh1.setSkinName("red");?

Also, can someone explain to me how the the following code works as far as naming textures:

Quote:
Tex0.player.png

%player.setSkinName("TEX0");
Thanks.

#1
07/10/2006 (8:53 am)
If I understand the way you've phrased things...

::if you have each segment of a segmented shape[multiple enclosed meshes] on separate UV texture bitmaps, I don't believe that TorqueScript solution will work, source code would need to be changed. For example; a robot with each separate body part mapped to separate textures[don't ask why,unless you've done this,;)], will not allow setSkinName to change each segment's texture bitmap.

but...I 'think', if you're approaching things like this...


::if you have a multiple, single objectMeshes, let's use a human figure as an example; say a SINGLE mesh geometry of a pajama clad 'look'[pajamas,no shoes, scruffy beard geometry:our BASE geometry] and the same human figure but with a SINGLE mesh geometry 'look' of a booted, shaven, workclothed human[WORKER geometry] all in the same DTS shape. You could use setSkinName, I think, with the caveat of a single mesh object for each single UV mapping. You might name the BASE geometry's texture "base.human.png". Then you would name the worker geometry's texture to something like, "worker.human.png".

...you might be able to get it to work.

I'm pretty sure that's the limit of setSkinName without changing the source C++ code.

oh, I don't think you need that mesh geometry naming convention, I was just using that to keep the multiple meshes organized...

I believe there is a C++ Resource on the site.
#2
07/10/2006 (9:24 am)
Yeah, I suspect that it will require some changes to the source code. Let me verify what it is I'm trying to do. I have a player model that is divided into 8 different sections. arms, legs, torso, etc. Each one has a different texture applied to it. What I want to do is to switch to different textures depending on game events. How do I accomplish this?
#3
07/10/2006 (9:41 am)
...the Resource here on the site. I've seen at least one for multiple meshes/multiple UV's.

Oh, based on game event?? Have no idea. But I do know that the player class has some that swap textures based on animation for a calling in :Damage, but beyond that 'event', I don't know if there is any more stock code to swap textures like that.
#4
07/10/2006 (10:28 am)
@ Joel -

you may not need to mod the engine to do this, altho you may.

try this,
let's say you've got only two meshes.

make four textures:

base.mesh1.jpg
blue.mesh1.jpg

base.mesh2.jpg
blue.mesh2.jpg

then try setSkin(blue.mesh1);

if that don't work,
i think you'll need to implement that resource.

.. which "that resource" is this.
#5
07/10/2006 (11:38 am)
That's the one...

I thought I'd tried as your example, Orion, before...and didn't have it work??!, great if it does, I'll put it in the 'doable' list... but that was a while ago, I know you can't do swap multi subMaterial textures, one mesh with multiple UV texture bitmaps...swapping just one of the textures.

I thought that what happened was, if the geometry isn't textured with the new called one, they revert to BASE texture...
#6
07/10/2006 (11:39 am)
Yah, i think you need to use the resource.
otherwise why would Chris have made a resource titled "Multiple skins on a single model" ?
#7
07/10/2006 (12:07 pm)
Thanks guys, I'll be sure to try it out soon, just one last thing. How does the naming convention work? I have a mesh in my model named 'Torso3' its texture file is 'torso.png' How do I set this? and whats 'base' and 'blue'?
#8
07/10/2006 (1:10 pm)
Hey Joel.

it's a little weird.

basically, make a texture named "base.torso.png" and have the mesh use it.
- "torso" can be anything, but "base" needs to be "base", and it needs to be first.

then, you can make as many alternate textures as you want by replacing just the "base" part.
eg, "blue.torso.png", "otherBlue.torso.png" etc.

then you'll be able to do things like
%player.setSkin("blue.torso")
and
%player.setSkin("otherBlue.torso")
and
%player.setSkin("base.torso"), if you like.

also, if i were you, i'd establish a naming convention of some sort to indicate which textures belong to which mesh. for example instead of "base.torso.png", something like "base.Torso3.png".
#9
07/10/2006 (1:21 pm)
Thanks a lot Orion. It makes sense to me and I'll try all of this out tonight. thanks again!