Game Development Community

Multiple textures

by Stephen Colbran · in Torque 3D Professional · 08/06/2009 (3:22 pm) · 4 replies

Is it possible to switch the textures of a player in T3D during the game?

For example: I have a model with 3 textures, legs, shirt and head.
During the game, could I call a script (say... %this.player.setTexture("arms", "arms.1.jpg")) that would change one of the textures?

If not, are there plans to add this functionality?

Thanks

#1
08/07/2009 (1:05 am)
Well the simplest thing to try ( off the top of my head ).

If you define the material in script that maps to your players arm texture, then you should be able to set a different texture on that material at a later time and call reload on the material.

That will, however, also change it for all TSShapeInstance's ( read: players or tsstatics etc ) referencing that same TSShape ( read: dts or collada ), which may or may not be a problem for your game.
#2
08/07/2009 (2:48 am)
EDIT: Found solution

Yeah I need the textures for multiplayer.
It's basically for customizable characters in my game.

Just for the knowledge, how could I change the texture for a material during the game?

Thanks
#3
08/09/2009 (1:22 pm)
This is one of the Materials within materials.cs for the BoomBot.
new Material(blue_IB1)
{
   mapTo = "blue_IB1";
   diffuseMap[0] = "blue_IB1";
   normalMap[0] = "blue_IB1PSDbump";
   pixelSpecular[0] = true;
   specular[0] = "1.0 1.0 1.0 1.0";
   specularPower[0] = 32.0;

};

At some point later that you want to change the texture (im assuming you mean diffuseMap).

blue_IB1.diffuseMap[0] = "some_other_texture";
// This may be required...
//blue_IB1.reload();
#4
08/10/2009 (5:27 pm)
Ah, I see. Thanks