Game Development Community

DTS model: No material

by Amr Bekhit · in Torque Game Engine Advanced · 10/27/2006 (5:07 pm) · 7 replies

Hi all,

I'm having trouble understanding how the materials system works in TSE. With TGE I am used to simply placing a models texture files in the same directory and when I add the model to the game, the textures are loaded and placed around the model. I did the same with TSE but instead I get a NO MATERIAL texture around my model. I've had a look on the search and on the TDN and found the bit on the documentation on materials, but I didn't really understand it.

I've had a look at some of the test objects as well. I found a materials.cs file in there that declared loads of Materials and CustomMaterials, but I don't see how those materials are linked to their respective objects.

All I need to do for the time being is just to load a DTS in with a texture on. How can I do that?

--Amr

#1
10/28/2006 (12:24 am)
Put a materials.cs file next to your model dts file

If you are using a texture called thisIsMyTexture.jpg, then write this in the file:
new Material(myUniqueMaterialName)
{
   baseTex[0] = "~/path/to/texture/thisIsMyTexture";
};

Thats it!
#2
10/28/2006 (3:57 am)
Magic! Thanks very much for the info Thomas. That's also helped me understand a bit more about materials I think.

My model has 3 textures applied to it. What I initially did was create one Material in this form:

new Material(GalleonMaterial)
{
   baseTex[0]="./ship.bmp";
   baseTex[1]="./sails.bmp";
   baseTex[2]="./extras.bmp";
};

But that didn't work so I ended up with three different materials. From that, this is how I see materials working:

Basically, for each texture you have, you create a material object. Any object that uses that textures does so via the material that texture is linked to. You can add loads of cool shader stuff to the material as well so that those bits of the model which use that texture will be affected by the graphic properties I add to the materials object.

Just a question: obviously it seems that I can add multiple baseTexs to my material, but how do they work?

Correct so far?

--Amr
#3
10/28/2006 (11:11 am)
When you indicate a different number in the index (between the [ ]), you are telling the shader generator that you want multiple render passes on your object.

This can be useful in some cases, or not, depending on your underlying textures!
#4
10/28/2006 (11:29 am)
Correct Amr, except the multiple baseTex stuff - as Stephen explained :-)
#5
10/28/2006 (11:34 am)
Thanks for the info chaps. I now have a much better understanding of how the systems work, and hopefully the confidence too!

--Amr
#6
10/28/2006 (3:07 pm)
Next step is to simply put in some shader stuff - try copying various settings from other materials.cs files into your materials and play with them!

Dont even have to code shader code to get some great effects
#7
10/28/2006 (3:15 pm)
I had a bit of a play - good fun what you can do with what is already there!

--Amr