Game Development Community

SetSkinName in TGEA?

by Martin Schultz · in Torque Game Engine Advanced · 06/14/2007 (12:48 am) · 4 replies

I tried to reskin my shape within the game using setSkinName. It works flawlessly in TGE, but in TGEA I always get a shape skinned with the "missing material/texture" orange texture.

I have a base texture called "base.camouflage.png" which works great if I don't call a setSkinName. Additionally I have 2 team textures named "team1.camouflage.png" and "team2.camouflage.png". Setting the skin in TGE I use a call like this:

.setSkinName("team1");

and I get the new skin. I'm using the same call now in TGEA. I used the debugger to break into the client-side "reskin" method and tried to understand what happens there. I saw the code cycling through all the materials of the shape, but it didn't apply the new skin. I have to admin I'm not fully sure if I understood what the reskin does, but I thought it just exchanges the desired texture. But as my shape has 3 subtextures on it (window, turbine and the base camouflage texture) I started wondering how the code knows which of the 3 materials it needs to exchange?

Not sure if I described the problem well, but maybe there's someone who can enlighten me :-)

Thanks,
Martin

#1
06/14/2007 (8:07 am)
Do you have Material entries for all 3 of those skin textures?
#2
06/14/2007 (11:52 am)
No, I don't. From what I understood in the code the reskin method uses textures, not materials. Or am I totally wrong there? I mean I even don't have a material for the base texture created, but it shows up like it should in the game if I don't call the setSkin method.

Here's a screenie from Max from the materials setup:
www.decane.net/gg/fge/fge_materials.jpg
#3
06/14/2007 (12:07 pm)
You're getting confused with a mixing of terminology here. Separate the idea of a "material" as far as a modeling program is concerned from the concept of a TGEA "Material." Although the 2 often intersect, they are different enough to warrant separation.

As far as my understanding goes, the basic unit of a TGEA Material is a single texture file. It is possible that multiple TGEA Materials can apply to a single texture file, but that is only possible (practical) if separate modeling program "materials" use the same texture file.

That is probably confusing you so I'll stick to the point. If you have different texture files, like one called "base.camouflage.png" and "team1.camouflage.png" you will need at least 2 Material (TGEA) definitions for them. A Material definition in TGEA looks like this:
new Material(baseSkin) {
    baseTex = "base.camouflage";
};

If you don't have one of those for every texture file that will be in use in your game you will get the "no material" texture on your models.
#4
06/14/2007 (12:23 pm)
Ha! The material definitions were missing, so simple... thanks a lot Mark!

I thought I'm aware of the difference between Max materials and TGEA materials, but it seems I simply forgot to define the materials at all. I posted the screenshot of the Max materials because I had already 2 materials defined in TGEA for the turbine glow and the window specular, but I forgot the base material, LOL :-)

I tried the whole time to map the material in TGEA to the corresponding material in Max, but that was the wrong way it seems. Anyway, works great now. Super, thanks.