Game Development Community

Using materials.cs with exported DTS

by Gerald Fishel · in Torque Game Engine Advanced · 12/02/2008 (8:52 pm) · 1 replies

Hi all,

I'm trying to get my head around using the material system in TGEA. Right now I have a simple box that I exported from 3DS Max, with a material that has a diffuse texture map. So I would like to set material properties for this with materials.cs instead. What exactly do I have to do to make that happen?

Do I just put the materials.cs file in the same folder as the .dts and it will read it automatically or do I need to do something to configure the DTS to read the materials.cs?

What all do I need to do to map the material definitions to materials in the DTS?

i.e. my box object is named "box", the material in 3ds max is named 'box1mat', and the texture is plate.png. From what I've read in the docs it sounds like I need to map the material definition to the texture in 3DS Max. So I tried a mateiral definition like this in materials.cs:

new Material(plate)
{
   mapTo = "plate";
   baseTex[0] = "~/data/shapes/test/box2";
};

basically to see that the material is working I wanted to specify a different texture, so I set baseTex[0] to b ox2 instead of plate.

But of course this doesn't work, or I wouldn't be writing this. The box is still rendered with the original plate texture.

So what is the correct way to setup a material for this?

Thanks,
Gerald

#1
12/02/2008 (9:33 pm)
Okay, I noticed a warning in my log file about the plate material being overwritten. I renamed the texture to boxplate.png and re-exported the DTS, then set the mapTo to boxplate, and it worked fine. I guess the engine balks at overriding a texture with the same name in another object.