Transparent tsshapes
by Mehmet Kizil · in Torque Game Engine · 02/09/2004 (5:49 pm) · 5 replies
Sup all,
Hopefully a quick one.....I just need a little code chane so that I can have the alpha of a tsshape as a varibale, so I can change it on the fly in script. I was skimming through the render code, but couldn't find anything helpful.
Thanks heaps if you know how to do it...
(code only!.....thanks).
Hopefully a quick one.....I just need a little code chane so that I can have the alpha of a tsshape as a varibale, so I can change it on the fly in script. I was skimming through the render code, but couldn't find anything helpful.
Thanks heaps if you know how to do it...
(code only!.....thanks).
#2
inside TSStatic.cc there is a line in the render function:
mShapeInstance->setAlphaAlways(1.0);
This is the alpha value of the shape, so you can either just change it to say 0.5 for semi-transparent or you can throw a new variable into the class and add it to the fields and change it on the fly....
02/10/2004 (5:17 pm)
Ok I figured it out (damn easy), just thought i'd put it here if anyone else wanted to know:inside TSStatic.cc there is a line in the render function:
mShapeInstance->setAlphaAlways(1.0);
This is the alpha value of the shape, so you can either just change it to say 0.5 for semi-transparent or you can throw a new variable into the class and add it to the fields and change it on the fly....
#3
I have made a new object based on the fxRenderObject melv made ages ago. Um it also needs to have a
variable transparency. Now inside the render function i was using the command glColor4f(1,1,1,mAlpha);
and yes this made it transparent but if you put some objects behind it they dont render,
(i'm guessing it had something to do with the order of rendering).
Does anyone know any other way I could get it to be properly transparent, either another method,
or a method of sorting the scene correctly or something...
Ta.
02/10/2004 (8:00 pm)
Now that I have that out of the way I have a new question:...I have made a new object based on the fxRenderObject melv made ages ago. Um it also needs to have a
variable transparency. Now inside the render function i was using the command glColor4f(1,1,1,mAlpha);
and yes this made it transparent but if you put some objects behind it they dont render,
(i'm guessing it had something to do with the order of rendering).
Does anyone know any other way I could get it to be properly transparent, either another method,
or a method of sorting the scene correctly or something...
Ta.
#4
02/11/2004 (5:09 am)
If you read Melv's notes in the top of the fxRenderObject's source code you will see the relevant info:Quote:
// A "SceneRenderImage" is simply a structure that defines the rendering attributes
// of the object that control the way the SceneTraversal routines handle it.
// Important factors such as is the object translucent (in which case it needs
// sorted back->front) can be specified here.
//
// In my example, you will see me dynamically allocating a "SceneRenderImage",
// populating relevant fields and then inserting it into the SceneState. You don't
// need to destroy it, the SceneGraph will do that after the frame is complete.
//
// There are lots of fields that I just haven't got the energy to go into here but
// two important ones I will. The "isTranslucent" field tells the SceneGraph that
// at least one portion of your object has transparency. If you didn't already
// know it, rendering transparent objects requires that objects be rendered from
// back to front (far to near) order to look correct. I won't go into why this is
// so because then I'm getting into imaging and then I'll really bore you. ;)
//
// The second important field is "sortType" which allows you to specify the way
// the object is handled by the scene. You can use the following ...
//
// Non-translucent objects ...
//
// Sky - Specialised for Sky object only.
// Terrain - Specialised for Terrain object only.
// Normal - Standard one to use for non-translucent objects.
//
// Translucent objects only ...
//
// Point - Object is a point defined by state->poly[0]
// Plane - Object is a plane defined by state->poly[0-3]
// EndSort - Object should appear after everything else has rendered
// BeginSort - Object should appear before everything else has rendered
//
// The "EndSort" is useful for rendering lens flares which need to be rendered
// after everything else has been rendered.
//
// The "BeginSort" is handy for rendering stuff behind the terrain but after
// the Sky like my fxSunLight object which renders a remote object and a local
// object.
//
// This brings me to an interesting point. You can insert more than one
// SceneRenderImage into the SceneState during the call to "prepRenderImage"
// which results in the "renderObject" being called more than once at the
// point defined by the "SceneRenderImage"s attributes. I do this with the
// fxSunLight but be sure you know what you are doing with this as you can
// significantly reduce your frame-rate by causing the same objects to be
// rendered multiple times.
//
// Why this complexity? Well, it's a very powerful method to use because you
// do all sorts of wizardry by traversing scene portals, clipping the frustum
// and iterating the new frustum up-to a specified depth to give you the
// ability to create mirrors, water reflections and other portal effects.
#5
image->isTranslucent = false; // had to change it to true thats all...
Ta.
02/11/2004 (6:36 pm)
Thanks heaps man, i had everthing right i just missed the whole image->isTranslucent = false; // had to change it to true thats all...
Ta.
Associate Kyle Carter