Game Development Community

Applying materials to avatars in MS 3.5

by Scott Burns · in Torque Game Engine Advanced · 07/11/2006 (10:55 am) · 5 replies

I'm in the process of porting over stuff from TGE 1.4 and I haven't really messed around with TSE much before this. One thing I'm having a problem with is materials on my avatar, all I get is the no material error texture on him. I did a quick port just days before 3.5 dropped and I didn't have to worry about this with that one.

What I'm not seeing is where and how exactly materials are applied to the model. Searching hasn't turned up much, some methods using addMaterialMapping that I have a feeling are deprecated.

If anybody can light the way here I'd appreciate it.

#1
07/11/2006 (11:03 am)
This is detailed in the documentation.

You apply materials to the texture, not the model.

new Material(shader)
{
   mapTo = "texture";
   baseTex[0] = "texture.png";
   bumpTex[0] = "texture_nm.png";
   pixelSpecular[0] = true;
   specular[0] = "0.1 0.1 0.1 0.1";
   specularPower[0] = 32.0;
};
#2
07/11/2006 (11:19 am)
Haven't updated to 3.5 yet, but I heard that now you're required to add a mapTo field to all materials, to specify which texture the material will associate to.

Also, if you're using Maya, you must add the texture file extension to the mapTo field. The Maya exporter stores the texture extension in the DTS file, and the mapTo field must be identical to the texture name in the DTS in order to properly map to it.
#3
07/11/2006 (11:20 am)
Yeah, that was bad wording on my part, I realize that the mapping is to the texture.

Is this in the TDN documentation or the doxygen documentation? I've read over the Materials Overview on there and according to it this should be all that's needed.

new Material(SoldierSkin)
{
	mapTo = "~/data/shapes/Avatars/Army/base.skin";
	baseTex[0] = "~/data/shapes/Avatars/Army/base.skin.png";
	bumpTex[0] = "~/data/shapes/Avatars/Army/base_skin_normal.png";
	pixelSpecular[0] = true;
	specular[0] = "0.1 0.1 0.1 0.1";
	specularPower[0] = "32.0";
};

The mapTo I added from your example. If there's better documentation that I've overlooked I'd appreciate a link, I still find TDN rather laborious to navigate.
#4
07/11/2006 (11:24 am)
@scott - i have the same issue on some models. The texture does not display but it use to display fine in ms3. All i get on those models is the error texture
#5
07/11/2006 (11:26 am)
Aha! Thanks Manoel, that gave me enough of a hint to figure out the way to do it. We are in fact using Maya. So my material needs to look like this.

new Material(SoldierSkin)
{
	mapTo = "base.skin.png";
	baseTex[0] = "~/data/shapes/Avatars/Army/base.skin.png";
	bumpTex[0] = "~/data/shapes/Avatars/Army/base_skin_normal.png";
	pixelSpecular[0] = true;
	specular[0] = "0.1 0.1 0.1 0.1";
	specularPower[0] = "32.0";
};