TTransparent Class Reference

#include <Transparency.h>

Inheritance diagram for TTransparent:

TFire::TParticle TGadgetBar::TRenderer TMenuGadget::TRenderer TMissileSmoke::TParticle TParticleExplosion::TParticle TParticleSmoke::TParticle TPetrolFire::TParticle TSmokeVol::TParticle TTree::TTreePart List of all members.

Detailed Description

TTransparent class.

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
TTransparentleft
 Left node from this one in the tree.
TTransparentright
 Right node from this one in the tree.

Static Private Attributes

static TTransparentroot = NULL
 Static root of the ordered tree.


Member Function Documentation

void TTransparent::Clear  )  [static]
 

Static reset function.

Clears the ordered tree of transparent objects.

Note that the clearing only means setting the static root variable - no objects are de-allocated or anything similar.

void TTransparent::RenderNode TTransparent node,
TCamera Camera
[static, private]
 

Static Render function to display a sub-tree under a given node.

This function is only used by the RenderScheduled static function.

Parameters:
node node to be rendered with it's underlaying tree.
Camera camera object managing the projection

void TTransparent::RenderScheduled TCamera Camera  )  [static]
 

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.

void TTransparent::ScheduleForRender float  dist  ) 
 

Registers the transparent object to the ordered list of transparent objects.

Parameters:
dist the object will be sorted into the list according to the distance


The documentation for this class was generated from the following files:
Viewable With Any Browser   Valid HTML 4.01!   Generated on Fri Apr 14 08:04:33 2006 for TankGame by doxygen 1.4.6-NO