Setting Object Alpha / Transparency
by Cinder Games · in Torque Game Engine · 04/25/2006 (6:56 pm) · 7 replies
I'm looking for a way to set an OBJECTs alpha/ transparency.
I am well aware you can use PNGs with transparency and all that Jazz... but i'm looking for ways to set an object to a certain transparent amount.
Are there any built in functions for this? I can't seem to locate any information on this.
I am well aware you can use PNGs with transparency and all that Jazz... but i'm looking for ways to set an object to a certain transparent amount.
Are there any built in functions for this? I can't seem to locate any information on this.
#2
04/25/2006 (10:00 pm)
Alrighty. I know there's a .startfade function, but that just fades and object in or out.
#3
04/25/2006 (10:02 pm)
Look at the function setFade on TSMesh. I'm preeetty sure that's what that does. Actually looking over the ShapeBase class and it's startFade function and variables, it seems to be setting stuff with TSMesh::setOverrideFade, so I'd look at the startFade functions and it's variables and try to see if you can figure anything out from that. So yes, you'll have to do some source code tweaking to get this, not sure how tough it'll be.
#4
04/26/2006 (1:40 am)
The function is setCloaked and it will make the object transparent.
#5
setAlphaAlways(0.0-1.0f);
Though the setcloak code also overlays a cloak texture by default as well. It might take some doing, but you should be able to work that thing into something usable with a little fooling around. The code tends to look for a lot of "absolute" settings (i.e. "if mCloakLevel == 0.0" ), so you might have to change all those to be like, "if mCloakLevel < 1.0" to get it to work with variant levels of transparency. Or at least look at them to see what ones youl'd have to change. You'll have to change the references to setAlphaAlways to just use the mCloakLevel directly too, instead of the offset functionality they're using.
04/26/2006 (1:49 am)
Ah hah, found it. SetCloaked by default just sets an object to 0.125 transparency and it's mounted images to 0.15. But you _should_ be able to modify or make your own function that does this with a variable setting. The function everything actually calls to change the transparency level issetAlphaAlways(0.0-1.0f);
Though the setcloak code also overlays a cloak texture by default as well. It might take some doing, but you should be able to work that thing into something usable with a little fooling around. The code tends to look for a lot of "absolute" settings (i.e. "if mCloakLevel == 0.0" ), so you might have to change all those to be like, "if mCloakLevel < 1.0" to get it to work with variant levels of transparency. Or at least look at them to see what ones youl'd have to change. You'll have to change the references to setAlphaAlways to just use the mCloakLevel directly too, instead of the offset functionality they're using.
#6
However what i don't like is the fact it's applying some other texture to the object. That'll be an issue. Guess i'l modify it and maybe if i come up with something useful, i'll post some code.
04/26/2006 (3:14 pm)
Oh, great. thanks. that'll definately get me where i need to go. I wonder why i never noticed that function....However what i don't like is the fact it's applying some other texture to the object. That'll be an issue. Guess i'l modify it and maybe if i come up with something useful, i'll post some code.
#7
04/26/2006 (3:59 pm)
You can probably just comment out the lines where it applies the texture, since I assume you aren't going to be using the normal setCloak functionality, they're pretty easy to spot.
Torque Owner Ben R Vesco