#include <Transparency.h>
Inheritance diagram for TTransparent:

Defines the common predecessor of all transparent objects.
The concept is to basically "extend OpenGL" by ability of drawing transparent objects not ordered. Instead of just rendering, the object is Scheduled for Render, and rendered afterwards, together with all other transparent objects in appropriate order. The objects are stored in a binary tree. Each object element can take part in the tree only once - the objects are not allocated nor de-allocated.
For example, in TFire, descendant of TTransparent is used:
class TFire: public TEffect { public: class TParticle : TTransparent { TVector Position; ... public: virtual void Render(TCamera *Camera); void Schedule(TCamera *Camera); void Displace(TVector &Place); // places particle to the beginning of its path void TimeTick(double delta); // updates particle's position }; private: TParticle Particles[ParticleCount]; ... }
Particles[i].Schedule() is called in the TFire::Render() method, to ask for rendering the particle. However, the actual OpenGL commands are postponed till TTransparent::RenderScheduled() is called from TTankGame::Render().
The Schedule method contains something like:
void TFire::TParticle::Schedule(TCamera *Camera) { float dist = Camera->GetDepth(Position); ScheduleForRender(dist); }
All the transparent objects in the game should be descendants of TTransparent and all should be rendered at a time (TTransparent::RenderScheduled()), in the proper order given by their depth.
Public Member Functions | |
| TTransparent () | |
| Default constructor. | |
| virtual | ~TTransparent () |
| Virtual destructor. | |
| void | ScheduleForRender (float dist) |
| Registers the transparent object to the ordered list of transparent objects. | |
| virtual void | Render (TCamera *Camera)=0 |
| Pure virtual Render function. | |
Static Public Member Functions | |
| static void | Clear () |
| Static reset function. | |
| static void | RenderScheduled (TCamera *Camera) |
| Static Render function to display all the scheduled objects in the correct order. | |
Static Private Member Functions | |
| static void | RenderNode (TTransparent *node, TCamera *Camera) |
| Static Render function to display a sub-tree under a given node. | |
Private Attributes | |
| float | dist |
| distance from the camera - the transparent objects get sorted by this one | |
| TTransparent * | left |
| Left node from this one in the tree. | |
| TTransparent * | right |
| Right node from this one in the tree. | |
Static Private Attributes | |
| static TTransparent * | root = NULL |
| Static root of the ordered tree. | |
|
|
Static reset function. Clears the ordered tree of transparent objects.
Note that the clearing only means setting the static |
|
||||||||||||
|
Static Render function to display a sub-tree under a given node. This function is only used by the RenderScheduled static function.
|
|
|
Static Render function to display all the scheduled objects in the correct order. The function recursively goes through the ordered tree and renders all the registered objects by calling their virtual Render function. |
|
|
Registers the transparent object to the ordered list of transparent objects.
|
1.4.6-NO