#include <CGenericObject.h>
Inheritance diagram for cGenericObject:
Public Member Functions | |
cGenericObject () | |
Constructor of cGenericObject. | |
virtual | ~cGenericObject () |
Destructor of cGenericObject. | |
virtual void | renderSceneGraph (const int a_renderMode=CHAI_RENDER_MODE_RENDER_ALL) |
Render the entire scene graph, starting from this object. | |
cGenericObject * | getParent () const |
Read parent of current object. | |
void | setPos (const cVector3d &a_pos) |
Set the local position of this object. | |
void | setPos (const double a_x, const double a_y, const double a_z) |
Set the local position of this object. | |
cVector3d | getPos () const |
Get the local position of this object. | |
cVector3d | getGlobalPos () const |
Get the global position of this object. | |
void | setRot (const cMatrix3d &a_rot) |
Set the local rotation matrix for this object. | |
cMatrix3d | getRot () const |
Get the local rotation matrix of this object. | |
cMatrix3d | getGlobalRot () const |
Get the global rotation matrix of this object. | |
void | translate (const cVector3d &a_translation) |
Translate this object by a specified offset. | |
void | translate (const double a_x, const double a_y, const double a_z) |
Translate this object by a specified offset. | |
void | rotate (const cMatrix3d &a_rotation) |
Rotate this object by multiplying with a specified rotation matrix. | |
void | rotate (const cVector3d &a_axis, const double a_angle) |
Rotate this object around axis a_axis by angle a_angle (radians). | |
void | computeGlobalPositions (const bool a_frameOnly=true, const cVector3d &a_globalPos=cVector3d(0.0, 0.0, 0.0), const cMatrix3d &a_globalRot=cIdentity3d()) |
Compute the global position and rotation of this object and its children. | |
void | computeGlobalCurrentObjectOnly (const bool a_frameOnly=true) |
Compute the global position and rotation of current object only. | |
virtual bool | computeCollisionDetection (cVector3d &a_segmentPointA, const cVector3d &a_segmentPointB, cGenericObject *&a_colObject, cTriangle *&a_colTriangle, cVector3d &a_colPoint, double &a_colSquareDistance, const bool a_visibleObjectsOnly=false, const int a_proxyCall=-1) |
Compute collision detection using collision trees. | |
virtual void | AdjustCollisionSegment (cVector3d &a_segmentPointA, cVector3d &a_localSegmentPointA, const cGenericObject *a_object) |
Adjust collision segment for dynamic objects. | |
virtual cVector3d | computeForces (const cVector3d &a_probePosition) |
Descend through child objects to compute interaction forces for all cGenericPotentialFields. | |
void | setShow (const bool a_show, const bool a_affectChildren=false) |
Show or hide this object, optionally propagating the change to children. | |
bool | getShow () const |
Read the display status of object (true means it's visible). | |
void | setHapticEnabled (const bool a_hapticEnabled, const bool a_affectChildren=false) |
Allow this object to be felt (when visible), optionally propagating the change to children. | |
bool | getHapticEnabled () const |
Read the haptic status of object (true means it can be felt when visible). | |
void | setShowTree (const bool a_showTree, const bool a_affectChildren=false) |
Show or hide the child/parent tree, optionally propagating the change to children. | |
bool | getShowTree () const |
Read the display status of the tree (true means it's visible). | |
void | setTreeColor (const cColorf &a_treeColor, const bool a_affectChildren=false) |
Set the tree color, optionally propagating the change to children. | |
cColorf | getTreeColor () const |
Read the tree color. | |
void | setShowFrame (const bool a_showFrame, const bool a_affectChildren=false) |
Show or hide the reference frame arrows for this object, optionally propagating the change to children. | |
bool | getShowFrame (void) const |
Read the display status of the reference frame (true means it's visible). | |
void | setShowBox (const bool iShowBox, const bool iAffectChildren=false) |
Show or hide the boundary box for this object, optionally propagating the change to children. | |
bool | getShowBox () const |
Read the display status of boundary box. (true means it's visible). | |
void | setBoxColor (const cColorf &a_boxColor, const bool a_affectChildren=false) |
Set the color of boundary box for this object, optionally propagating the change to children. | |
cColorf | getBoxColor () const |
Read the color of boundary box. | |
void | showCollisionTree (const bool a_showCollisionTree, const bool a_affectChildren=false) |
Show or hide the collision tree for this object, optionally propagating the change to children. | |
virtual void | onDisplayReset (const bool a_affectChildren=true) |
This function should get called when it's necessary to re-initialize the OpenGL context. | |
virtual void | finalize (const bool a_affectChildren=true) |
This function tells children that you're not going to change their contents any more. | |
virtual void | unfinalize (const bool a_affectChildren=true) |
This function tells objects that you may modify their contents. | |
bool | setFrameSize (const double a_size=1.0, const double a_thickness=1.0, const bool a_affectChildren=false) |
Set the size of the rendered reference frame, optionally propagating the change to children. | |
double | getFrameSize () const |
Read the size of the rendered reference frame. | |
cVector3d | getBoundaryMin () const |
Read the minimum point of this object's boundary box. | |
cVector3d | getBoundaryMax () const |
Read the maximum point of this object's boundary box. | |
cVector3d | getBoundaryCenter () const |
Compute the center of this object's boundary box. | |
void | computeBoundaryBox (const bool a_includeChildren=true) |
Re-compute this object's bounding box, optionally forcing it to bound child objects. | |
void | setCollisionDetector (cGenericCollision *a_collisionDetector) |
Set a collision detector for current object. | |
cGenericCollision * | getCollisionDetector () const |
Get pointer to this object's current collision detector. | |
void | setCollisionDetectorProperties (unsigned int a_displayDepth, cColorf &a_color, const bool a_affectChildren=false) |
Set collision rendering properties. | |
void | deleteCollisionDetector (const bool a_affectChildren=false) |
Delete any existing collision detector and set the current cd to null (no collisions). | |
cGenericObject * | getChild (const unsigned int a_index) const |
Read an object from my list of children. | |
void | addChild (cGenericObject *a_object) |
Add an object to my list of children. | |
bool | removeChild (cGenericObject *a_object) |
Remove an object from my list of children, without deleting it. | |
bool | containsChild (cGenericObject *a_object, bool a_includeChildren=false) |
Does this object have the specified object as a child? | |
bool | deleteChild (cGenericObject *a_object) |
Remove an object from my list of children and delete it. | |
void | clearAllChildren () |
Clear all objects from my list of children, without deleting them. | |
void | deleteAllChildren () |
Clear and delete all objects from my list of children. | |
unsigned int | getNumChildren () |
Return the number of children on my list of children. | |
unsigned int | getNumDescendants (bool a_includeCurrentObject=false) |
Return my total number of descendants, optionally including this object. | |
void | enumerateChildren (std::list< cGenericObject * > &a_childList, bool a_includeCurrentObject=true) |
Fill this list with all of my descendants. | |
bool | removeFromGraph () |
Remove me from my parent's CHAI scene graph. | |
void | scale (const double &a_scaleFactor, const bool a_includeChildren=true) |
Scale this object by a_scaleFactor (uniform scale). | |
void | scale (const cVector3d &a_scaleFactors, const bool a_includeChildren=true) |
Non-uniform scale. | |
virtual void | setTag (const int a_tag, const bool a_affectChildren=0) |
Set the tag for this object and - optionally - for my children. | |
virtual void | setUserData (void *a_data, const bool a_affectChildren=0) |
Set the m_userData pointer for this object and - optionally - for my children. | |
virtual void | setName (const char *a_name, const bool a_affectChildren=0) |
Set the name for this object and - optionally - for my children. | |
Public Attributes | |
bool | m_historyValid |
Are m_lastPos and m_lastRot up-to-date? | |
cVector3d | m_lastPos |
A previous position; exact interpretation up to user. | |
cMatrix3d | m_lastRot |
A previous rotation; exact interpretation up to user. | |
int | m_tag |
An arbitrary tag, not used by CHAI. | |
void * | m_userData |
An arbitrary data pointer, not used by CHAI. | |
char | m_objectName [CHAI_MAX_OBJECT_NAME_LENGTH] |
A name for this object, automatically assigned by mesh loaders (for example). | |
Protected Member Functions | |
virtual void | render (const int a_renderMode=CHAI_RENDER_MODE_RENDER_ALL) |
Render this object in OpenGL. | |
virtual void | updateGlobalPositions (const bool a_frameOnly) |
Update the m_globalPos and m_globalRot properties of any members of this object (e.g. all triangles). | |
virtual void | updateBoundaryBox () |
Update the bounding box of this object, based on object-specific data (e.g. triangle positions). | |
virtual void | scaleObject (const cVector3d &a_scaleFactors) |
Scale current object with scale factors along x, y and z. | |
Protected Attributes | |
cGenericObject * | m_parent |
Parent object. | |
vector< cGenericObject * > | m_children |
My list of children. | |
cVector3d | m_localPos |
The position of this object in my parent's reference frame. | |
cVector3d | m_globalPos |
The position of this object in the world's reference frame. | |
cMatrix3d | m_localRot |
The rotation matrix that rotates my reference frame into my parent's reference frame. | |
cMatrix3d | m_globalRot |
The rotation matrix that rotates my reference frame into the world's reference frame. | |
cVector3d | m_boundaryBoxMin |
Minimum position of boundary box. | |
cVector3d | m_boundaryBoxMax |
Maximum position of boundary box. | |
double | m_frameSize |
Size of graphical representation of frame (X-Y-Z). | |
bool | m_show |
If true, this object is rendered. | |
bool | m_hapticEnabled |
IF true, this object can be felt. | |
bool | m_showFrame |
If true, this object's reference frame is rendered as a set of arrows. | |
bool | m_showBox |
If true, this object's boundary box is displayed as a set of lines. | |
bool | m_showTree |
If true, the skeleton of the scene graph is rendered at this node. | |
bool | m_showCollisionTree |
If true, the collision tree is displayed (if available) at this node. | |
cColorf | m_treeColor |
The color of the collision tree. | |
cColorf | m_boundaryBoxColor |
The color of the bounding box. | |
cGenericCollision * | m_collisionDetector |
The collision detector used to test for contact with this object. | |
cMatrixGL | m_frameGL |
OpenGL matrix describing my position and orientation transformation. |
This class also defines basic methods for maintaining a scene graph, and propagating rendering passes and reference frame changes through a hierarchy of cGenericObjects.
Besides subclassing, a useful way to extend cGenericObject is to store custom data in the m_tag and m_userData member fields, which are not used by CHAI.
The most important methods to look at here are probably the virtual methods, which are listed last in CGenericObject.h . These methods will be called on each cGenericObject as operations propagate through the scene graph.
cGenericObject::cGenericObject | ( | ) |
Constructor of cGenericObject.
Constructor of cGenericObject.
cGenericObject::~cGenericObject | ( | ) | [virtual] |
Destructor of cGenericObject.
Destructor of cGenericObject. This function deletes all children starting from this point in the scene graph, so if you have objects that shouldn't be deleted, be sure to remove them from the scene graph before deleting their parents.
void cGenericObject::renderSceneGraph | ( | const int | a_renderMode = CHAI_RENDER_MODE_RENDER_ALL |
) | [virtual] |
Render the entire scene graph, starting from this object.
Render the scene graph starting at this object. This method is called for each object and optionally renders the object itself, its reference frame and the collision and/or scenegraph trees.
The object itself is rendered by calling render(), which should be defined for each subclass that has a graphical representation. renderSceneGraph does not generally need to be over-ridden in subclasses.
The a_renderMode parameter is used to allow multiple rendering passes, and takes one of the following values:
CHAI_RENDER_MODE_NON_TRANSPARENT_ONLY=0, CHAI_RENDER_MODE_TRANSPARENT_BACK_ONLY, CHAI_RENDER_MODE_TRANSPARENT_FRONT_ONLY, CHAI_RENDER_MODE_RENDER_ALL
If you have multipass transparency disabled (see cCamera), your objects will only be rendered once per frame, with a_renderMode set to CHAI_RENDER_MODE_RENDER_ALL. This is the default, and unless you enable multipass transparency, you don't ever need to care about a_renderMode.
a_renderMode | Rendering mode |
Reimplemented in cGenericShader.
void cGenericObject::translate | ( | const cVector3d & | a_translation | ) |
Translate this object by a specified offset.
Translate this object by a specified offset
a_translation | Translation offset |
void cGenericObject::translate | ( | const double | a_x, | |
const double | a_y, | |||
const double | a_z | |||
) |
Translate this object by a specified offset.
Translate an object by a specified offset
a_x | Translation component X | |
a_y | Translation component Y | |
a_z | Translation component Z |
void cGenericObject::rotate | ( | const cMatrix3d & | a_rotation | ) |
Rotate this object by multiplying with a specified rotation matrix.
Rotate this object by multiplying with a specified rotation matrix
a_rotation | Rotation matrix |
void cGenericObject::rotate | ( | const cVector3d & | a_axis, | |
const double | a_angle | |||
) |
Rotate this object around axis a_axis by angle a_angle (radians).
Rotate this object around axis a_axis by angle a_angle (radians). a_axis is not normalized, so unless you know what you're doing, normalize your axis before supplying it to this function.
a_axis | Rotation axis | |
a_angle | Rotation angle in radians |
void cGenericObject::computeGlobalPositions | ( | const bool | a_frameOnly = true , |
|
const cVector3d & | a_globalPos = cVector3d(0.0, 0.0, 0.0) , |
|||
const cMatrix3d & | a_globalRot = cIdentity3d() | |||
) |
Compute the global position and rotation of this object and its children.
Compute globalPos and globalRot given the localPos and localRot of this object and its parents. Optionally propagates to children.
If a_frameOnly is set to false, additional global positions such as vertex positions are computed (which can be time-consuming).
Call this method any time you've moved an object and will need to access to globalPos and globalRot in this object or its children. For performance reasons, these values are not kept up-to-date by default, since almost all operations use local positions and rotations.?
a_frameOnly | If true then only the global frame is computed | |
a_globalPos | Global position of my parent | |
a_globalRot | Global rotation matrix of my parent |
void cGenericObject::computeGlobalCurrentObjectOnly | ( | const bool | a_frameOnly = true |
) |
Compute the global position and rotation of current object only.
Compute globalPos and globalRot for this object only, by recursively climbing up the scene graph tree until the root is reached.
If a_frameOnly is set to false, additional global positions such as vertex positions are computed.
a_frameOnly | If true then only the global frame is computed |
bool cGenericObject::computeCollisionDetection | ( | cVector3d & | a_segmentPointA, | |
const cVector3d & | a_segmentPointB, | |||
cGenericObject *& | a_colObject, | |||
cTriangle *& | a_colTriangle, | |||
cVector3d & | a_colPoint, | |||
double & | a_colSquareDistance, | |||
const bool | a_visibleObjectsOnly = false , |
|||
const int | a_proxyCall = -1 | |||
) | [virtual] |
Compute collision detection using collision trees.
Determine whether the given segment intersects a triangle in this object (or any of its descendants). The segment is described by a start point a_segmentPointA and end point a_segmentPointB. Collision detection functions of all children of this object are called, which recursively call the collision detection functions for all of this object's descendants. 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.
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_colSquareDistance | Squared 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 in cWorld.
void cGenericObject::AdjustCollisionSegment | ( | cVector3d & | a_segmentPointA, | |
cVector3d & | a_localSegmentPointA, | |||
const cGenericObject * | a_object | |||
) | [virtual] |
Adjust collision segment for dynamic objects.
Adjust the given segment such that it tests for intersection of the ray with objects at their previous positions at the last haptic loop so that collision detection will work in a dynamic environment.
a_segmentPointA | Start point of segment. | |
a_localSegmentPointA | Same segment, adjusted to be in local space. | |
a_object | Object that may have moved since last iteration. |
Descend through child objects to compute interaction forces for all cGenericPotentialFields.
Descend through child objects to compute interaction forces for all cGenericPotentialField objects.
a_probePosition | Position of the probe in my parent's coordinate frame |
Reimplemented in cGenericPotentialField.
void cGenericObject::setShow | ( | const bool | a_show, | |
const bool | a_affectChildren = false | |||
) |
Show or hide this object, optionally propagating the change to children.
Show or hide this object.
If a_affectChildren is set to true then all children are updated with the new value.
a_show | If true object shape is visible. | |
a_affectChildren | If true all children are updated. |
void cGenericObject::setHapticEnabled | ( | const bool | a_hapticEnabled, | |
const bool | a_affectChildren = false | |||
) |
Allow this object to be felt (when visible), optionally propagating the change to children.
Allow or disallow the object to be felt (when visible).
If a_affectChildren is set to true then all children are updated with the new value.
a_hapticEnabled | If true object can be felt when visible. | |
a_affectChildren | If true all children are updated. |
void cGenericObject::setShowTree | ( | const bool | a_showTree, | |
const bool | a_affectChildren = false | |||
) |
Show or hide the child/parent tree, optionally propagating the change to children.
Show or hide the graphic representation of the scene graph at this node.
If a_affectChildren is set to true then all children are updated with the new value.
a_showTree | If true then tree is displayed. | |
a_affectChildren | If true all children are updated. |
void cGenericObject::setTreeColor | ( | const cColorf & | a_treeColor, | |
const bool | a_affectChildren = false | |||
) |
Set the tree color, optionally propagating the change to children.
Set the color of the graphic representation of the scene graph at this node.
If a_affectChildren is set to true then all children are updated with the new value.
a_treeColor | Color of tree. | |
a_affectChildren | If true all children are updated. |
void cGenericObject::setShowFrame | ( | const bool | a_showFrame, | |
const bool | a_affectChildren = false | |||
) |
Show or hide the reference frame arrows for this object, optionally propagating the change to children.
Show or hide the set of arrows that represent this object's reference frame.
If a_affectChildren is set to true then all children are updated with the new value.
a_showFrame | If true then frame is displayed. | |
a_affectChildren | If true all children are updated. |
void cGenericObject::setShowBox | ( | const bool | a_showBox, | |
const bool | a_affectChildren = false | |||
) |
Show or hide the boundary box for this object, optionally propagating the change to children.
Show or hide the graphic representation of the boundary box of this object.
If a_affectChildren is set to true then all children are updated with the new value.
a_showBox | If true, boundary box is displayed. | |
a_affectChildren | If true all children are updated. |
void cGenericObject::setBoxColor | ( | const cColorf & | a_boxColor, | |
const bool | a_affectChildren = false | |||
) |
Set the color of boundary box for this object, optionally propagating the change to children.
Set the color of the graphic representation of the boundary boundary box of this object.
a_boxColor | Color of boundary box. | |
a_affectChildren | If true all children are updated. |
void cGenericObject::showCollisionTree | ( | const bool | a_showCollisionTree, | |
const bool | a_affectChildren = false | |||
) |
Show or hide the collision tree for this object, optionally propagating the change to children.
Show or hide the graphic representation of the collision tree at this node.
If a_affectChildren is set to true then all children are updated with the new value.
a_showCollisionTree | If true, small normals are rendered graphicaly. | |
a_affectChildren | If true all children are updated |
void cGenericObject::onDisplayReset | ( | const bool | a_affectChildren = true |
) | [virtual] |
This function should get called when it's necessary to re-initialize the OpenGL context.
Users should call this function when it's necessary to re-initialize the OpenGL context; e.g. re-initialize textures and display lists. Subclasses should perform whatever re-initialization they need to do.
Note that this is not an event CHAI can easily detect, so it's up to the application-writer to call this function on the root of the scenegraph.
a_affectChildren | If true, the operation propagates through the scene graph |
Reimplemented in cGenericShader, cCamera, cMesh, cVBOMesh, cWorld, and cLabelPanel.
void cGenericObject::finalize | ( | const bool | a_affectChildren = true |
) | [virtual] |
This function tells children that you're not going to change their contents any more.
This call tells an object that you're not going to modify him any more. For example, a mesh-like object might optimize his vertex arrangement when he gets this call. Always optional; just for performance...
a_affectChildren | If true, the operation propagates through the scene graph |
Reimplemented in cVBOMesh.
void cGenericObject::unfinalize | ( | const bool | a_affectChildren = true |
) | [virtual] |
This function tells objects that you may modify their contents.
This call tells an object that you may modify his contents. See finalize() for more information.
a_affectChildren | If true, the operation propagates through the scene graph |
Reimplemented in cVBOMesh.
bool cGenericObject::setFrameSize | ( | const double | a_size = 1.0 , |
|
const double | a_thickness = 1.0 , |
|||
const bool | a_affectChildren = false | |||
) |
Set the size of the rendered reference frame, optionally propagating the change to children.
Set the display size of the arrows representing my reference frame. The size corresponds to the length of each displayed axis (X-Y-Z).
If a_affectChildren is set to true then all children are updated with the new value.
a_size | Length of graphical representation of frame. | |
a_thickness | Thickness of graphical representation of frame. | |
a_affectChildren | If true all children are updated. |
void cGenericObject::computeBoundaryBox | ( | const bool | a_includeChildren = true |
) |
Re-compute this object's bounding box, optionally forcing it to bound child objects.
Compute the bounding box of this object and (optionally) its children.
If parameter a_includeChildren is set to true then each object's bounding box covers its own volume and the volume of its children.
Note that regardless of this parameter's value, this operation propagates down the scene graph.
a_includeChildren | If true, then children are included. |
void cGenericObject::setCollisionDetectorProperties | ( | unsigned int | a_displayDepth, | |
cColorf & | a_color, | |||
const bool | a_affectChildren = false | |||
) |
Set collision rendering properties.
Set the rendering properties for the graphic representation of collision detection tree at this node.
If a_affectChildren is set to true then all children are updated with the new values.
a_color | Color used to render collision detector. | |
a_displayDepth | Indicated which depth of collision tree needs to be displayed (see cGenericCollision) | |
a_affectChildren | If true, all children are updated |
void cGenericObject::deleteCollisionDetector | ( | const bool | a_affectChildren = false |
) |
Delete any existing collision detector and set the current cd to null (no collisions).
Delete any existing collision detector and set the current cd to null. It's fine for an object to have a null collision detector (that's the default for a new object, in fact), it just means that no collisions will be found.
a_affectChildren | If true, all my children's cd's are also deleted |
void cGenericObject::addChild | ( | cGenericObject * | a_object | ) |
Add an object to my list of children.
Adds an object to the scene graph below this object
a_object | Object to be added to children list. |
bool cGenericObject::removeChild | ( | cGenericObject * | a_object | ) |
Remove an object from my list of children, without deleting it.
Removes an object from my list of children, without deleting the child object from memory.
This method assigns the child object's parent point to null, so if you're moving someone around in your scene graph, make sure you call this function _before_ you add the child to another node in the scene graph.
a_object | Object to be removed from my list of children |
bool cGenericObject::containsChild | ( | cGenericObject * | a_object, | |
bool | a_includeChildren = false | |||
) |
Does this object have the specified object as a child?
Does this object have the specified object as a child?
a_object | Object to search for | |
a_includeChildren | Should we also search this object's descendants? |
bool cGenericObject::deleteChild | ( | cGenericObject * | a_object | ) |
Remove an object from my list of children and delete it.
Removes an object from my list of children, and deletes the child object from memory.
a_object | Object to be removed from my list of children and deleted |
void cGenericObject::clearAllChildren | ( | ) |
Clear all objects from my list of children, without deleting them.
Clear all objects from my list of children, without deleting them
void cGenericObject::deleteAllChildren | ( | ) |
Clear and delete all objects from my list of children.
Delete and clear all objects from my list of children
unsigned int cGenericObject::getNumDescendants | ( | bool | a_includeCurrentObject = false |
) |
Return my total number of descendants, optionally including this object.
Return my total number of descendants, optionally including this object
a_includeCurrentObject | Should I include myself in the count? |
void cGenericObject::enumerateChildren | ( | std::list< cGenericObject * > & | a_childList, | |
bool | a_includeCurrentObject = true | |||
) |
Fill this list with all of my descendants.
Fill this list with all of my descendants. The current object is optionally included in this list. Does not clear the list before appending to it.
a_childList | The list to write our enumerated results to | |
a_includeCurrentObject | Should I include myself on the list? |
void cGenericObject::scale | ( | const double & | a_scaleFactor, | |
const bool | a_includeChildren = true | |||
) |
Scale this object by a_scaleFactor (uniform scale).
Uniform scale, optionally include children. Not necessarily implemented in all subclasses. Does nothing at the cGenericObject level; subclasses should scale themselves, then call the superclass method.
a_scaleFactor | Scale factor | |
a_includeChildren | If true, this message is passed to children. |
void cGenericObject::scale | ( | const cVector3d & | a_scaleFactors, | |
const bool | a_includeChildren = true | |||
) |
Non-uniform scale.
Non-uniform scale, optionally include children. Not necessarily implemented in all subclasses. Does nothing at the cGenericObject level; subclasses should scale themselves, then call the superclass method.
a_scaleFactors | Possibly non-uniform scale factors | |
a_includeChildren | If true, this message is passed to children. |
void cGenericObject::setTag | ( | const int | a_tag, | |
const bool | a_affectChildren = 0 | |||
) | [virtual] |
Set the tag for this object and - optionally - for my children.
Set the tag for this object and - optionally - for my children.
a_tag | The tag we'll assign to this object | |
a_affectChildren | If true, the operation propagates through the scene graph. |
void cGenericObject::setUserData | ( | void * | a_data, | |
const bool | a_affectChildren = 0 | |||
) | [virtual] |
Set the m_userData pointer for this object and - optionally - for my children.
Set the m_userData pointer for this object and - optionally - for my children.
a_data | The pointer to which we will set m_userData | |
a_affectChildren | If true, the operation propagates through the scene graph. |
void cGenericObject::setName | ( | const char * | a_name, | |
const bool | a_affectChildren = 0 | |||
) | [virtual] |
Set the name for this object and - optionally - for my children.
Set the name for this object and - optionally - for my children.
a_name | The name we'll assign to this object | |
a_affectChildren | If true, the operation propagates through the scene graph. |
void cGenericObject::render | ( | const int | a_renderMode = CHAI_RENDER_MODE_RENDER_ALL |
) | [protected, virtual] |
Render this object in OpenGL.
Render this object. Subclasses will generally override this method. This is called from renderSceneGraph, which subclasses generally do not need to override.
The a_renderMode parameter is used to allow multiple rendering passes, and takes one of the following values:
CHAI_RENDER_MODE_NON_TRANSPARENT_ONLY=0, CHAI_RENDER_MODE_TRANSPARENT_BACK_ONLY, CHAI_RENDER_MODE_TRANSPARENT_FRONT_ONLY, CHAI_RENDER_MODE_RENDER_ALL
If you have multipass transparency disabled (see cCamera), your objects will only be rendered once per frame, with a_renderMode set to CHAI_RENDER_MODE_RENDER_ALL. This is the default, and unless you enable multipass transparency, you don't ever need to care about a_renderMode.
A word on OpenGL conventions:
CHAI does not re-initialize the OpenGL state at every rendering pass. The only OpenGL state variables that CHAI sets explicitly in a typical rendering pass are:
lighting is enabled (cWorld) depth-testing is enabled (cWorld) glColorMaterial is enabled and set to GL_AMBIENT_AND_DIFFUSE/GL_FRONT_AND_BACK (cWorld) a perspective projection matrix is set up (cCamera)
This adherence to the defaults is nice because it lets an application change an important piece of state globally and not worry about it getting changed by CHAI objects.
It is expected that objects will "clean up after themselves" if they change any rendering state besides:
color (glColor) material properties (glMaterial) normals (glNormal)
For example, if my object changes the rendering color, I don't need to set it back before returning, but if my object turns on vertex buffering, I should turn it off before returning. Consequently if I care about the current color, I should set it up in my own render() function, because I shouldn't count on it being meaningful when my render() function is called.
Necessary exceptions to these conventions include:
cLight will change the lighting state for his assigned GL_LIGHT cCamera sets up relevant transformation matrices
a_renderMode | Rendering mode; see above |
Reimplemented in cMesh, cShapeSphere, cShapeTorus, cWorld, cGeneric3dofPointer, cGenericTool, cBitmap, cLabelPanel, and cPanel.