OpenGLPrakt --> cObject --> cVisibleObject

class cVisibleObject
    extends cObject as public

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!

Source:
../src/cVisibleObject.hh:40

Constructors Index

cVisibleObject
[public] constructor with initialization for name (default constructor)
cVisibleObject
[public] copy constructor
cVisibleObject
[public] constructor with initialization for position and name
cVisibleObject
[public] constructor with initialization for position, rotation and name
~cVisibleObject
[public] destructor


Variables Index

mGlobalTransformation
[protected] The resulting _global_ transformation of this object.
mMaterial
[protected] the material to use for this object
mPosition
[protected] actual position of the object
mRotation
[protected] actual rotation of the object
mVisible
[protected] Visibility of object


Methods Index

Activate
[protected] Activate the object. (here: draw it if visible)
Deactivate
[protected] actions to perform after drawing the object and it's siblings (might be overloaded)
DontUseMaterial
[public] disable use of material for this object
DrawThisObject
[protected] perform actual drawing of the object (has to be overloaded)
GetDefaultName
[protected] return default name of object (the poor man's RTTI)
Init
[public] initialize object and it's childs
IsVisible
[public] get visibility
MoveBy
[public] move object by given amount
MoveTo
[public] move object to given position
RotateBy
[public] rotate object angle degrees around given vector ("adds" to current rotation)
RotateBy
[public] rotate object by applying a quaternion ("adds" to current rotation)
SetRotation
[public] set rotation to given values (replaces current rotation)
SetRotation
[public] set rotation to given value (replaces current rotation)
SetVisible
[public] set visibility
Transform
[protected] perform transformation neccessary before drawing
UseMaterial
[public] set material to use for this object (store reference only!)


Constructors

cVisibleObject

public cVisibleObject ( const char * name = NULL ) ;

constructor with initialization for name (default constructor)

Parameters:
name name to identify the object (optional)

cVisibleObject

public cVisibleObject ( const cVisibleObject & ) ;

copy constructor

cVisibleObject

public cVisibleObject ( const cVertex & pos ,
                        const char * name = NULL ) ;

constructor with initialization for position and name

Parameters:
pos initial object position
name name to identify the object (optional)

cVisibleObject

public cVisibleObject ( const cVertex & pos ,
                        const cQuaternion & rot ,
                        const char * name = NULL ) ;

constructor with initialization for position, rotation and name

Parameters:
pos initial object position
rot initial object rotation
name name to identify the object (optional)

cVisibleObject

public virtual ~ cVisibleObject ( ) ;

destructor


Variables

mRotation

protected cQuaternion mRotation

actual rotation of the object

See Also:
cVisibleObject::Activate

mPosition

protected cVertex mPosition

actual position of the object

See Also:
cVisibleObject::Activate

mVisible

protected bool mVisible

Visibility of object

is the object visible (read: call DrawThisObject())

See Also:
DrawThisObject

mMaterial

protected cMaterial * mMaterial

the material to use for this object

NULL == do not use a material

mGlobalTransformation

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.

See Also:
Activate

Methods

Init

public virtual int Init ( ) ;

initialize object and it's childs

(partially inherited from cObject)

MoveTo

public virtual void MoveTo ( const cVertex & pos ) ;

move object to given position

Parameters:
pos new absolute center of objects coordinate system

MoveBy

public virtual void MoveBy ( const cVertex & pos ) ;

move object by given amount

Parameters:
pos new center of objects coordinate system relative to actual

RotateBy

public virtual void RotateBy ( const GLfloat angle ,
                               const cVertex & axis ) ;

rotate object angle degrees around given vector ("adds" to current rotation)

Parameters:
angle angle in degree
axis vector to rotate around

RotateBy

public virtual void RotateBy ( const cQuaternion & quaternion ) ;

rotate object by applying a quaternion ("adds" to current rotation)

Parameters:
quaternion quaternion to apply

SetRotation

public virtual void SetRotation ( const GLfloat angle ,
                                  const cVertex & axis ) ;

set rotation to given values (replaces current rotation)

Parameters:
angle angle in degree
axis vector to rotate around

SetRotation

public virtual void SetRotation ( const cQuaternion & new_rotation ) ;

set rotation to given value (replaces current rotation)

Parameters:
new_rotation quaternion representing rotation

UseMaterial

public virtual void UseMaterial ( cMaterial * material ) ;

set material to use for this object (store reference only!)

Parameters:
material pointer to cMaterial to use

DontUseMaterial

public virtual void DontUseMaterial ( ) ;

disable use of material for this object

Parameters:
material const reference to cMaterial to use

SetVisible

public void SetVisible ( bool visible ) ;

set visibility

Parameters:
visible visibility

IsVisible

public bool IsVisible ( ) const ;

get visibility

Activate

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)

  1. - perform any steps neccessary to prepare for drawing (inherited, overloaded, may be overloaded)
  2. Transform () - apply rotation and translation (might be overloaded to prefent transformation)
  3. DrawThisObject () - perform actual drawing if object is visible (usually has to be overloaded)
  4. call cObject::Activate() to activate all siblings
  5. Deactivate () called by cObject::Activate() - undo special things done in Activate(), call cObject::Deactivate () (inherited, overloaded, may be overloaded)

You may overwrite this but make sure to call cVisibleObject::Activate() to get transformations right!

Transform

protected virtual void Transform ( ) ;

perform transformation neccessary before drawing

might be overloaded e.g. to prevent transformation

DrawThisObject

protected virtual void DrawThisObject ( ) = 0 ;

perform actual drawing of the object (has to be overloaded)

Deactivate

protected virtual void Deactivate ( ) ;

actions to perform after drawing the object and it's siblings (might be overloaded)

GetDefaultName

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.