Material swap issues
by Joel Hargarten · in Torque Game Engine · 04/04/2007 (2:21 pm) · 4 replies
Hey everyone,
I've been trying to implement a material swap system for what was formerly known as TSE and I guess is now TGEA. I implemented the setSkinName resource I found in the forums, but to no avail. It just says how it changed the index of the matierals, but nothing changes visually on the model. I have a couple of questions that may assist in getting this to work.
First off, how does the materials.cs know which material to apply to which mesh? I was originally naming each material the same as the mesh in the model, but I recently created multiple materials with completly different names so I could switch between textures, but it always overrides the other materials (even the one that is named the same as the mesh) with which ever material is listed last in materials.cs. Does it just look at the materials' file name and path to determine?
For example, I am trying to switch hair colors and I have two file paths with the same file name:
Hair\Blonde\hair_long.png
Hair\Red\hair_long.png
The Red always overrides the blonde because its at the bottom, otherwise it uses the blonde texture. Does it just look for the 'hair_long.png' file name in materials.cs because that is the applied texture I have in 3ds MAX?
I use 3ds Max to export from, In MAX I have a basic model that I apply material textures to. When I apply a texture file like 'hair_long.png', after I export it to torque, It seems that I can't just apply any material or texture file in materials.cs to that mesh, because it's somehow hardcoded in the DTS file that only a texture file named hair_long.png can be applied to it. Is there a way I can change it so that any texture file can be applied to any mesh in the DTS? Because that may be what is preventing the setSkinName function from switching the material correctly. Any light that can be shined on this would be appriciated. Thanks.
I've been trying to implement a material swap system for what was formerly known as TSE and I guess is now TGEA. I implemented the setSkinName resource I found in the forums, but to no avail. It just says how it changed the index of the matierals, but nothing changes visually on the model. I have a couple of questions that may assist in getting this to work.
First off, how does the materials.cs know which material to apply to which mesh? I was originally naming each material the same as the mesh in the model, but I recently created multiple materials with completly different names so I could switch between textures, but it always overrides the other materials (even the one that is named the same as the mesh) with which ever material is listed last in materials.cs. Does it just look at the materials' file name and path to determine?
For example, I am trying to switch hair colors and I have two file paths with the same file name:
Hair\Blonde\hair_long.png
Hair\Red\hair_long.png
The Red always overrides the blonde because its at the bottom, otherwise it uses the blonde texture. Does it just look for the 'hair_long.png' file name in materials.cs because that is the applied texture I have in 3ds MAX?
I use 3ds Max to export from, In MAX I have a basic model that I apply material textures to. When I apply a texture file like 'hair_long.png', after I export it to torque, It seems that I can't just apply any material or texture file in materials.cs to that mesh, because it's somehow hardcoded in the DTS file that only a texture file named hair_long.png can be applied to it. Is there a way I can change it so that any texture file can be applied to any mesh in the DTS? Because that may be what is preventing the setSkinName function from switching the material correctly. Any light that can be shined on this would be appriciated. Thanks.
#2
04/05/2007 (8:20 am)
But what do I do if I want to indepentantly change each meshes assigned material, instead of switching all materials for the entire player?
#3
It would be nice to mix and match... the camoflauge body clothing with the red punk hairdo and the yellow go-go boots, but unfortunately that's not how the engine does it.
04/05/2007 (9:19 am)
Dig into the source code and rewrite how the engine works.It would be nice to mix and match... the camoflauge body clothing with the red punk hairdo and the yellow go-go boots, but unfortunately that's not how the engine does it.
#4
For hiding meshes
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5421
and this to swap materials:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=10957
they work both with tgea 1.0, i dont tested yet with the new release i wait, till constructor is released, and the new TGEA 1.02 update.
04/05/2007 (9:35 am)
Hi if you use TGEA you can use this 2 resources:For hiding meshes
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5421
and this to swap materials:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=10957
they work both with tgea 1.0, i dont tested yet with the new release i wait, till constructor is released, and the new TGEA 1.02 update.
Torque Owner Pete Patterson
In 3DS Max, you *must* name the textures using the word 'base' and a '.' and then whatever you like, so:
base.head.png
base.torso.png
base.boots.png
etc
Then you can create other texture sets:
skin1.head.png
skin1.torso.png
skin1.boots.png
skin2.head.png
skin2.torso.png
skin2.boots.png
etc.
In TGEA, you will want to create material definitions for each of the skins.
new Material(base.head)
{
...
}
new Material(skin1.head)
{
...
}
new Material(skin2.head)
{
...
}
etc.
Then you can use setSkinName('skin1') or setSkinName('skin2') to switch to a different set.