Material swaps
by Howard Dortch · in Torque 3D Professional · 01/16/2012 (6:41 am) · 8 replies
I have 16 door switches with a red and green light (glow material) on each one. I use a single DTS object for all the switches with a base material. The lights are just a green and red material that I can alter the glow value on.
Here is the problem:
If I set the green to glow then all 16 switches will glow ( not good )
If I make 16 materials so they would be independant then I have to make 16 different switches ( not good)
Anyone have a suggestion on how I can make one material glow on one switch when user access without having to make 16 separate objects? Recap - Door closed switch glows green, door open switch glows red.
This type of issue will happen on computer panels, equipment etc, I like to think there is a easy way to make single lights glowing on objects...
Any help?
Here is the problem:
If I set the green to glow then all 16 switches will glow ( not good )
If I make 16 materials so they would be independant then I have to make 16 different switches ( not good)
Anyone have a suggestion on how I can make one material glow on one switch when user access without having to make 16 separate objects? Recap - Door closed switch glows green, door open switch glows red.
This type of issue will happen on computer panels, equipment etc, I like to think there is a easy way to make single lights glowing on objects...
Any help?
#2
01/17/2012 (8:55 am)
Try digging around for ShapeBase::setSkinName() too.
#3
somemat.emissive[0] = "1"; // turn light on
somemat.reload();
this works but since all the switches use it then they all glow. I hate to think I have to make 16 objects...
01/18/2012 (7:15 pm)
Does that just change the texture or the material? I have the correct texture I just want it to glow....somemat.emissive[0] = "1"; // turn light on
somemat.reload();
this works but since all the switches use it then they all glow. I hate to think I have to make 16 objects...
#4
Changing a property on a Material will affect ALL shapes that use that Material. To achieve the effect you want, define two Materials; one with emissive set false, one with emissive set true. Use the skin field to swap between them for each shape instance.
01/19/2012 (8:28 pm)
Reading the docs will answer your question.Changing a property on a Material will affect ALL shapes that use that Material. To achieve the effect you want, define two Materials; one with emissive set false, one with emissive set true. Use the skin field to swap between them for each shape instance.
#5
base.switch
glow.switch
Then name your images to match that convention:
base.switch.jpg
glow.switch.jpg
You can then use livingRoomSwitch.setSkinName("glow") to make the living room switch glow without making all of them glow.
This is how Tribes et. al. allowed changing the team armor skins.
For an actual example, look at the solder's materials - they are set up to use this.
01/20/2012 (9:20 am)
setSkinName() is on a per-item basis. There is some material setup required in your modeling package, namely you have to name your material using this naming convention:base.switch
glow.switch
Then name your images to match that convention:
base.switch.jpg
glow.switch.jpg
You can then use livingRoomSwitch.setSkinName("glow") to make the living room switch glow without making all of them glow.
This is how Tribes et. al. allowed changing the team armor skins.
For an actual example, look at the solder's materials - they are set up to use this.
#6
Thanks...
01/21/2012 (6:38 am)
Yeah I know how that works, thats what I do now and it just looks ugly wrong. Problem is the box that holds the lights glow if I do that. I have a black box with red and green buttons. Looks like the only solution is to set the 16 boxes then create antoher 16 objects that gets aligned to the front of the boxes for switches. Thanks...
#7
1). In your 3D modeler, duplicate the lens geometry and give the duplicate a unique texture (but remember to follow the naming convention Richard outlined above). Then, in T3D, create another material definition (with glow enabled) and map it to the new lens texture. Now when you call setSkinName() only the lens texture will change.
2). Utilize glow masks/maps to define which area of the switch texture should glow. See: http://www.garagegames.com/community/blogs/view/19919 for instructions on how to mask portions of a texture.
01/21/2012 (12:34 pm)
You've got a few options here assuming your switch mesh is currently only using a single texture for the switch 'box' and light lenses:1). In your 3D modeler, duplicate the lens geometry and give the duplicate a unique texture (but remember to follow the naming convention Richard outlined above). Then, in T3D, create another material definition (with glow enabled) and map it to the new lens texture. Now when you call setSkinName() only the lens texture will change.
2). Utilize glow masks/maps to define which area of the switch texture should glow. See: http://www.garagegames.com/community/blogs/view/19919 for instructions on how to mask portions of a texture.
#8
01/28/2012 (7:09 am)
Thanks, didn't know that would work with multiple materials like that.
Associate Chris Robertson
You can swap the 'skin' of each object independently at level design time (by setting the 'skin' field of the object in the world editor), or during the game (as a result of the player 'using' the switch).