cWorld Class Reference

cWorld defines the typical root of the CHAI scene graph. It stores lights, allocates textures, and serves as the root for scene-wide collision detection. More...

#include <CWorld.h>

Inheritance diagram for cWorld:

cGenericObject List of all members.

Public Member Functions

 cWorld ()
 Constructor of cWorld.
virtual ~cWorld ()
 Destructor of cWorld.
void setBackgroundColor (const GLfloat a_red, const GLfloat a_green, const GLfloat a_blue)
 Set the background color used when rendering.
void setBackgroundColor (const cColorf &a_color)
 Set the background color used when rendering.
cColorf getBackgroundColor () const
 Get the background color used when rendering.
void enableLightSourceRendering (bool enable)
 Enable or disable the rendering of this world's light sources.
cTexture2DnewTexture ()
 Create a new bitmap texture.
cTexture2DgetTexture (unsigned int a_index)
 Get a pointer to a texture by passing an index into my texture list.
void addTexture (cTexture2D *a_texture)
 Add a texture to my texture list.
bool removeTexture (cTexture2D *a_texture)
 Remove a texture from my texture list.
bool deleteTexture (cTexture2D *a_texture)
 Delete a texture.
void deleteAllTextures ()
 Delete all textures.
virtual bool computeCollisionDetection (cVector3d &a_segmentPointA, const cVector3d &a_segmentPointB, cGenericObject *&a_colObject, cTriangle *&a_colTriangle, cVector3d &a_colPoint, double &a_colDistance, const bool a_visibleObjectsOnly=false, const int a_proxyCall=-1)
 Compute collision detection between a ray segment and all objects in this world.
virtual void render (const int a_renderMode=0)
 Render OpenGL lights.
virtual cLightgetLightSource (int index)
 Get access to a particular light source (between 0 and MAXIMUM_OPENGL_LIGHT_COUNT-1).
virtual void onDisplayReset (const bool a_affectChildren=true)
 Resets textures and displays for the world.

Public Attributes

double m_worldModelView [16]
 It's useful to store the world's modelview matrix, for rendering stuff in "global" coordinates.

Protected Member Functions

bool addLightSource (cLight *a_light)
bool removeLightSource (cLight *a_light)
 Remove a light source from this world.

Protected Attributes

cColorf m_backgroundColor
 Background color. Default color is black.
vector< cTexture2D * > m_textures
 List of textures.
vector< cLight * > m_lights
 List of light sources.
bool m_renderLightSources
 Should I render my light sources, or just use the current OpenGL light state?
bool m_performingDisplayReset
 Some apps may have multiple cameras, which would cause recursion when resetting the display.

Friends

class cLight
 Add a light source to this world.

Detailed Description

cWorld defines the typical root of the CHAI scene graph. It stores lights, allocates textures, and serves as the root for scene-wide collision detection.


Constructor & Destructor Documentation

cWorld::cWorld (  ) 

Constructor of cWorld.

Constructor of cWorld.

cWorld::~cWorld (  )  [virtual]

Destructor of cWorld.

Destructor of cWorld. Deletes the world, all his children, and all his textures.


Member Function Documentation

void cWorld::setBackgroundColor ( const GLfloat  a_red,
const GLfloat  a_green,
const GLfloat  a_blue 
)

Set the background color used when rendering.

Set the background color used when rendering. This really belongs in cCamera or cViewport; it's a historical artifact that it lives here.

Parameters:
a_red Red component.
a_green Green component.
a_blue Blue component.

void cWorld::setBackgroundColor ( const cColorf a_color  ) 

Set the background color used when rendering.

Set the background color used when rendering. This really belongs in cCamera or cViewport; it's a historical artifact that it lives here.

Parameters:
a_color new background color.

cTexture2D * cWorld::newTexture (  ) 

Create a new bitmap texture.

Create new texture and add it to textures list.

Returns:
Return pointer to new texture entity.

void cWorld::addTexture ( cTexture2D a_texture  ) 

Add a texture to my texture list.

Add texture to texture list.

Parameters:
a_texture Texture to be added to the textures list.

bool cWorld::removeTexture ( cTexture2D a_texture  ) 

Remove a texture from my texture list.

Remove texture from textures list. Texture is not deleted from memory.

Parameters:
a_texture Texture to be removed from textures list.
Returns:
Return true if operation succeeded

bool cWorld::deleteTexture ( cTexture2D a_texture  ) 

Delete a texture.

Delete texture from textures list and erase it from memory.

Parameters:
a_texture Texture to be deleted.
Returns:
Return true if operation succeeded

void cWorld::deleteAllTextures (  ) 

Delete all textures.

Delete all texture from memory.

bool cWorld::computeCollisionDetection ( cVector3d a_segmentPointA,
const cVector3d a_segmentPointB,
cGenericObject *&  a_colObject,
cTriangle *&  a_colTriangle,
cVector3d a_colPoint,
double &  a_colDistance,
const bool  a_visibleObjectsOnly = false,
const int  a_proxyCall = -1 
) [virtual]

Compute collision detection between a ray segment and all objects in this world.

Determine whether the given segment intersects a triangle in this world. The segment is described by a start point /e a_segmentPointA and end point /e a_segmentPointB. Collision detection functions of all children of the world are called, which recursively call the collision detection functions for all objects in this world. If there is more than one collision, the one closest to a_segmentPointA is the one returned.

For any dynamic objects in the world with valid position and rotation histories (as indicated by the m_historyValid member of cGenericObject), the first endpoint of the segment is adjusted so that it is in the same location relative to the moved object as it was at the previous haptic iteration (provided the object's m_lastRot and m_lastPos were updated), so that collisions between the segment and the moving object can be properly detected. If the returned collision is with a moving object, the actual parameter corresponding to a_segmentPointA is set to the adjusted position for that object.

If a collision(s) is located, information about the (closest) collision is stored in the corresponding parameters a_colObject, a_colTriangle, a_colPoint, and a_colDistance.

Parameters:
a_segmentPointA Start point of segment. Value may be changed if returned collision is with a moving object.
a_segmentPointB End point of segment.
a_colObject Pointer to nearest collided object.
a_colTriangle Pointer to nearest collided triangle.
a_colPoint Position of nearest collision.
a_colDistance Distance between segment origin and nearest collision point.
a_visibleObjectsOnly Should we ignore invisible objects?
a_proxyCall If this is > 0, this is a call from a proxy, and the value of a_proxyCall specifies which call this is. -1 for non-proxy calls.

Reimplemented from cGenericObject.

void cWorld::render ( const int  a_renderMode = 0  )  [virtual]

Render OpenGL lights.

Render the world in OpenGL.

Parameters:
a_renderMode Rendering Mode.

Reimplemented from cGenericObject.

cLight * cWorld::getLightSource ( int  index  )  [virtual]

Get access to a particular light source (between 0 and MAXIMUM_OPENGL_LIGHT_COUNT-1).

Get access to a particular light source (between 0 and MAXIMUM_OPENGL_LIGHT_COUNT-1). Returns a pointer to the requested light, or zero if it's not available.

Parameters:
index Specifies the light (0 -> 7) that should be accessed
Returns:
return A pointer to a valid light or 0 if that light doesn't exist

void cWorld::onDisplayReset ( const bool  a_affectChildren = true  )  [virtual]

Resets textures and displays for the world.

Called by the user or by the viewport when the world needs to have textures and display lists reset (e.g. after a switch to or from fullscreen).

Parameters:
a_affectChildren Should I pass this on to my children?

Reimplemented from cGenericObject.

bool cWorld::addLightSource ( cLight a_light  )  [protected]

Add an OpenGL light source to the world. A maximum of eight light sources can be registered. For each registered light source, an OpenGL lightID number is defined

Parameters:
a_light light source to register.
Returns:
return true if light source was registered, otherwise return false.

bool cWorld::removeLightSource ( cLight a_light  )  [protected]

Remove a light source from this world.

Remove a light source from world.

Parameters:
a_light light source to be removed.
Returns:
return true if light source was removed, otherwise return false.


The documentation for this class was generated from the following files:
Generated on Mon Jun 11 09:41:48 2007 for CHAI 3D by  doxygen 1.5.2