OpenGLPrakt --> cObject --> cWorld

class cWorld
    extends cObject as public
    extends cEventConsumer as public

The world class. The interface to OpenGL/GLUT.

Only _one_ cWorld object may be active at once. This object _has_ to be the root of the scene graph.

Source:
../src/cWorld.hh:44

Constructors Index

cWorld
[public] default constructor w/ optional name
cWorld
[public] copy constructor
~cWorld
[public] destructor


Methods Index

Activate
[protected] set up for drawing
ActivateMenuEntry
[public] trigger event bound to given menu id
AddMenuEntry
[public] add menu entry to actual menu
AddSubMenu
[public] add sub menu to actual menu
Animate
[public] broadcast animation event, re-register timer callback if animation still activated
AttachMenu
[public] attach menu to given mouse button
Deactivate
[protected] clean up after drawing the world
DisableAnimation
[public] stop animation
Draw
[public] start drawing the whole world (wrapper for Activate())
EnableAnimation
[public] start animation
GetDefaultName
[protected] return name of class (for poor RTTI and as fallback for GetName)
GetDisplayHeight
[public] query height of display
GetDisplayWidth
[public] query width of display
GetWorkingMenu
[public] get current menu where entries are added to
Init
[public] initialize world (and OpenGL window using GLUT)
Init
[public] Initialize world and OpenGL window using GLUT and providing several defaults
MoveCameraAndLookatBy
[public] for "walk" navigation
MoveCameraBy
[public] move camera by a given amount without changing LookAt
MoveCameraTo
[public] move camera to a give point without changing LookAt, but probably with changing UpVector
MoveLookAtBy
[public] for "orbit navigation": move orbit center = look-at
OrbitCamera
[public] for "orbit navigation": orbit around look-at
PanCamera
[public] for "walk" navigation: look around
ReceiveEvent
[public] event receiver
ReshapeDisplay
[public] set new window dimensions
SceneGraphToMenu
[public] make scene graph visible via menu
SetAnimationSpeed
[public] set or change animation speed
SetCamera
[public] set up camera
SetOrthoProjection
[public] activate orthogonal projection
SetPerspectiveProjection
[public] activate pespective projection
SetWorkingMenu
[public] set current menu where entries are added to


Constructors

cWorld

public cWorld ( cEventDispatcher * disp ,
                const char * name = NULL ) ;

default constructor w/ optional name

Parameters:
name optional name of object

cWorld

public cWorld ( const cWorld & ) ;

copy constructor

cWorld

public virtual ~ cWorld ( ) ;

destructor


Methods

Init

public virtual int Init ( int * argc ,
                          char * * argv ) ;

initialize world (and OpenGL window using GLUT)

Parameters:
argc passed from main
argv passed from main

Init

public virtual int Init ( int * argc ,
                          char * * argv ,
                          unsigned int glut_display_mode ,
                          int default_width = - 1 ,
                          int default_height = - 1 ,
                          int default_pos_x = - 1 ,
                          int default_pos_y = - 1 ) ;

Initialize world and OpenGL window using GLUT and providing several defaults

If you provide one of default_width or default_height you have to provide the "opposite" as well. The same rule applies to default_pos_x and default_pos_y.

Parameters:
argc passed from main
argv passed from main
glut_display_mod use GLUT_xxx constants ORed together to describe the display type you need (e.g. GLUT_RGB|GLUT_DEPTH|GLUT_DOUBLE) default: GLUT_RGB | GLUT_DEPTH
default_width default width (-1 = don't care)
default_height default height (-1 = don't care)
default_pos_x default x position of window (-1 = don't care)
default_pos_y default y position of window (-1 = don't care)

ReshapeDisplay

public virtual void ReshapeDisplay ( int width ,
                                     int height ) ;

set new window dimensions

Parameters:
width new width of window
height new height of window

Draw

public virtual void Draw ( ) ;

start drawing the whole world (wrapper for Activate())

note: this is called by GLUTDisplayCB, there should be no need to call it from somewhere else!

SceneGraphToMenu

public virtual void SceneGraphToMenu ( int menu ) ;

make scene graph visible via menu

Parameters:
menu id of menu to add scene graph to

SetWorkingMenu

public virtual void SetWorkingMenu ( int id ) ;

set current menu where entries are added to

Parameters:
id number of menu to activate

GetWorkingMenu

public virtual int GetWorkingMenu ( ) ;

get current menu where entries are added to

Return:
id number of active menu

AddMenuEntry

public virtual int AddMenuEntry ( const char * entry ,
                                  const cEvent & event ) ;

add menu entry to actual menu

Parameters:
entry text to show as the entry
event event to trigger if menu is selected

Return:
id of menu entry for later reference

AddSubMenu

public virtual int AddSubMenu ( const char * name ) ;

add sub menu to actual menu

Parameters:
name text to show as sub menu name

Return:
id of sub menu entry for later reference

AttachMenu

public virtual void AttachMenu ( int button ) ;

attach menu to given mouse button

Parameters:
button GLUT_x_BUTTON (x = LEFT|MIDDLE|RIGHT)

SetCamera

public int SetCamera ( const cVertex & pos ,
                       const cVertex & lookat ,
                       const cVertex & up ) ;

set up camera

Parameters:
pos camera position
lookat point the camera looks at
up the direction which is "up" from the camera's point of view

Return:
-1 on error, 0 on success

MoveCameraTo

public int MoveCameraTo ( const cVertex & pos ) ;

move camera to a give point without changing LookAt, but probably with changing UpVector

Parameters:
pos position to move camera to

Return:
-1 on error, 0 on success

MoveCameraBy

public int MoveCameraBy ( const cVertex & dif ) ;

move camera by a given amount without changing LookAt

Parameters:
dif amount to move camera (it is added to camera pos.)

Return:
-1 on error, 0 on success

MoveCameraAndLookatBy

public void MoveCameraAndLookatBy ( const cVertex & dif ) ;

for "walk" navigation

Parameters:
dif amount to move by

PanCamera

public void PanCamera ( GLfloat x ,
                        GLfloat y ) ;

for "walk" navigation: look around

Parameters:
x_angle angle to turn around x
y_angle angle to turn around y

OrbitCamera

public void OrbitCamera ( GLfloat x ,
                          GLfloat y ) ;

for "orbit navigation": orbit around look-at

Parameters:
x_angle angle to turn around x
y_angle angle to turn around y

MoveLookAtBy

public void MoveLookAtBy ( const cVertex & dif ) ;

for "orbit navigation": move orbit center = look-at

Parameters:
dif amount to move look-at

GetDisplayWidth

public unsigned int GetDisplayWidth ( ) ;

query width of display

Return:
width of viewing window

GetDisplayHeight

public unsigned int GetDisplayHeight ( ) ;

query height of display

Return:
height of viewing window

SetPerspectiveProjection

public int SetPerspectiveProjection ( GLdouble fovy ,
                                      GLdouble near ,
                                      GLdouble far ) ;

activate pespective projection

Parameters:
fovy field of view angle (degree) in y direction
near coordinate for near clipping plane (>0 !)
far coordinate for far clipping plane (>0 !)

Return:
-1 on error (invalid values), 0 on success

SetOrthoProjection

public int SetOrthoProjection ( GLdouble fovy ,
                                GLdouble near ,
                                GLdouble far ) ;

activate orthogonal projection

Parameters:
fovy field of view angle (degree) in y direction
near coordinate for near clipping plane (>0 !)
far coordinate for far clipping plane (>0 !)

Return:
0 (always succeeds)

ActivateMenuEntry

public int ActivateMenuEntry ( int id ) ;

trigger event bound to given menu id

this is basically an internal function, but can be called from outside without any risk

Parameters:
id menu entry id to activate

Return:
-1 if invalid ID was given

EnableAnimation

public void EnableAnimation ( ) ;

start animation

SetAnimationSpeed

public void SetAnimationSpeed ( int speed ) ;

set or change animation speed

Parameters:
speed ms per frame (0 - stop animation)

DisableAnimation

public void DisableAnimation ( ) ;

stop animation

ReceiveEvent

public virtual int ReceiveEvent ( const cEvent & event ) ;

event receiver

Animate

public void Animate ( int value ) ;

broadcast animation event, re-register timer callback if animation still activated

Should not be called by user.

Parameters:
value value to send around with animation event (a frame counter)

Activate

protected virtual void Activate ( ) ;

set up for drawing

Deactivate

protected virtual void Deactivate ( ) ;

clean up after drawing the world

GetDefaultName

protected virtual const char * GetDefaultName ( ) const ;

return name of class (for poor RTTI and as fallback for GetName)


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.