Game Development Community

Materials and paths?

by Guimo · in Torque 3D Professional · 11/21/2011 (5:34 pm) · 1 replies

Hi everybody,

This is just a followup for this thread:

http://www.garagegames.com/community/forums/viewthread/128574

So, let me explain the new problem. I have a single card DTS model and the game switches textures over that model.

I setup my folders as:
-card
-- 1024
--- card.dts --> material is base.card
--- material.dts --> mapTo = 1024.card
--- 1024.card.jpg
-- 1033
--- card.dts --> material is base.card
--- material.dts --> mapTo = 1033.card
--- 1033.card.jpg

As you see, every folder has a model, a texture and a material definition. The base material of the model is base.card. The material definition then uses the mapTo to target the JPG to the proper material type.

So I load the card model and then run a setSkinName (on the guiObjectView) and the proper texture is loaded fine. i.e.
view.setModel("card/1024/card.dts");
view.setSkinName("1024");

And it loaded ok, the 1024.card.jpg is displayed over the model.

Then I change the card:
view.setModel("card/1033/card.dts");
view.setSkinName("1033");

And it loaded ok. Notice that it is not the same texture and they are different materials.

So, as everything was fine, I decided that I didn't need the card.dts model duplicated (I have a lot of this cards) so I deleted the DTS from all the folders and put a single copy of the card.dts in the main card directory.

Then then I do:
view.setModel("card/card.dts"...); //the new path of the dts
view.setSkinName("1024");

But now it displays "NO MATERIAL".


So, I followed the setSkinName method, it uses the reSkin method of the TSShapeInstance. That method does the following:

Torque::Path shapePath = mShapeResource.getPath();
const String resourcePath = shapePath.getPath();
...
String newPath = resourcePath + "/" + matName.replace( 0, oldBaseNameLength, newBaseName );

So in other words it picks the path of the main tsShapeInstance to search for the specified material "1024". Of course the texture 1024.card.jpg is no longer in the same folder as the card.dts file so it fails.

And to make things worse, I thought the reSkin method worked with the materials, but I was wrong. The reSkin method uses the tsMaterial::setMaterial method which in turn loads a texture and not a material. Indeed if a texture as 1024.card.xxx is not present in the same folder as the DTS the method fails.

So, basically:
a. I'm forced have the textures in the same folder as the model as the model path is used to search for new skin textures.
b. Material definitions are completely ignored.
c. I can't use materials in the guiObjectView.

Any comments would be appreciated.

Thank you so much.


#1
11/22/2011 (3:23 pm)
Ok, I got tired of the limitations so I coded my own GuiWSObjectView and added some additional tricks like an enhanced skin support, material support and scene management allowing for multiple objects in the same scene.

Is good to have the source code :)