OpenGLPrakt --> cObject --> cVisibleObject
This object provides anything neccessary to build viewable objects.
It is intended to derive from it, overloading the DrawTheObject() and probably Init() methods.
This is already OpenGL specific!
If we talk about a position, it's OpenGL's notion of a translation via glTranslatef, that means, that not the object but the object's coordinate system is translated! Take care of that!
public cVisibleObject ( const char * name = NULL ) ;
constructor with initialization for name (default constructor)
name | name to identify the object (optional) |
public cVisibleObject ( const cVisibleObject & ) ;
copy constructor
public cVisibleObject ( const cVertex & pos , const char * name = NULL ) ;
constructor with initialization for position and name
pos | initial object position |
name | name to identify the object (optional) |
public cVisibleObject ( const cVertex & pos , const cQuaternion & rot , const char * name = NULL ) ;
constructor with initialization for position, rotation and name
pos | initial object position |
rot | initial object rotation |
name | name to identify the object (optional) |
public virtual ~ cVisibleObject ( ) ;
destructor
protected cQuaternion mRotation
actual rotation of the object
protected cVertex mPosition
actual position of the object
protected bool mVisible
Visibility of object
is the object visible (read: call DrawThisObject())
protected cMaterial * mMaterial
the material to use for this object
NULL == do not use a material
protected cMatrix mGlobalTransformation
The resulting _global_ transformation of this object.
It is aquired via glGetFloatv (GL_MODELVIEW_MATRIX). It's purpose is to simplify interaction.
public virtual int Init ( ) ;
initialize object and it's childs
(partially inherited from cObject)
public virtual void MoveTo ( const cVertex & pos ) ;
move object to given position
pos | new absolute center of objects coordinate system |
public virtual void MoveBy ( const cVertex & pos ) ;
move object by given amount
pos | new center of objects coordinate system relative to actual |
public virtual void RotateBy ( const GLfloat angle , const cVertex & axis ) ;
rotate object angle degrees around given vector ("adds" to current rotation)
angle | angle in degree |
axis | vector to rotate around |
public virtual void RotateBy ( const cQuaternion & quaternion ) ;
rotate object by applying a quaternion ("adds" to current rotation)
quaternion | quaternion to apply |
public virtual void SetRotation ( const GLfloat angle , const cVertex & axis ) ;
set rotation to given values (replaces current rotation)
angle | angle in degree |
axis | vector to rotate around |
public virtual void SetRotation ( const cQuaternion & new_rotation ) ;
set rotation to given value (replaces current rotation)
new_rotation | quaternion representing rotation |
public virtual void UseMaterial ( cMaterial * material ) ;
set material to use for this object (store reference only!)
material | pointer to cMaterial to use |
public virtual void DontUseMaterial ( ) ;
disable use of material for this object
material | const reference to cMaterial to use |
public void SetVisible ( bool visible ) ;
set visibility
visible | visibility |
public bool IsVisible ( ) const ;
get visibility
protected virtual void Activate ( ) ;
Activate the object. (here: draw it if visible)
The scene is drawn by pre-oder traversing the scene graph (an n-ary tree). Drawing is started by invoking Activate() which takes care that all childs are drawn as well.
Activate() works as follows: (see implementation for details)
You may overwrite this but make sure to call cVisibleObject::Activate() to get transformations right!
protected virtual void Transform ( ) ;
perform transformation neccessary before drawing
might be overloaded e.g. to prevent transformation
protected virtual void DrawThisObject ( ) = 0 ;
perform actual drawing of the object (has to be overloaded)
protected virtual void Deactivate ( ) ;
actions to perform after drawing the object and it's siblings (might be overloaded)
protected virtual const char * GetDefaultName ( ) const ;
return default name of object (the poor man's RTTI)
Every object within the scene graph can be associated a name. By default, the class of the object is used.
This documentation was generated automatically by the ccdoc tool (version 0.7a).
Click here to submit a bug report or feature request.
Click here to return to the top of the page.