My Project
Loading...
Searching...
No Matches
cODEWorld Class Reference

This class implements an ODE dynamic world. More...

#include <CODEWorld.h>

Inheritance diagram for cODEWorld:

Public Member Functions

 cODEWorld (chai3d::cWorld *a_parentWorld)
 Constructor of cODEWorld.
 
virtual ~cODEWorld ()
 Destructor of cODEWorld.
 
void setGravity (chai3d::cVector3d a_gravity)
 This method sets the gravity field vector.
 
chai3d::cVector3d getGravity ()
 This method returns the gravity field vector.
 
void setLinearDamping (double a_value)
 This method sets a general linear damping term to the objects in the world.
 
void setAngularDamping (double a_value)
 This method sets a general angular damping term to the objects in the world.
 
void setMaxAngularSpeed (double a_value)
 This method sets a maximum angular speed for objects in the world.
 
void updateDynamics (double a_interval)
 This method updates the simulation over a time interval.
 
void updateBodyPositions (void)
 This method updates the position and orientation from ODE models to CHAI3D models.
 
void updateGlobalPositions (const bool a_frameOnly)
 This method updates all global position frames.
 
virtual bool computeCollisionDetection (const chai3d::cVector3d &a_segmentPointA, const chai3d::cVector3d &a_segmentPointB, chai3d::cCollisionRecorder &a_recorder, chai3d::cCollisionSettings &a_settings)
 This method computes any collision between a segment and all objects in this world.
 
- Public Member Functions inherited from chai3d::cGenericObject
 cGenericObject ()
 
virtual ~cGenericObject ()
 
virtual std::string getClassName ()
 
virtual void setEnabled (bool a_enabled, const bool a_affectChildren=false, const bool a_affectComponents=true)
 
bool getEnabled () const
 
cGenericObject * getObject (std::string &a_name)
 
virtual cGenericObject * copy (const bool a_duplicateMaterialData=false, const bool a_duplicateTextureData=false, const bool a_duplicateMeshData=false, const bool a_buildCollisionDetector=true)
 
virtual void setLocalPos (const cVector3d &a_localPos)
 
void setLocalPos (const double a_x=0.0, const double a_y=0.0, const double a_z=0.0)
 
cVector3d getLocalPos () const
 
cVector3d getGlobalPos () const
 
virtual void setLocalRot (const cMatrix3d &a_localRot)
 
cMatrix3d getLocalRot () const
 
cMatrix3d getGlobalRot () const
 
void setLocalTransform (const cTransform &a_transform)
 
cTransform getLocalTransform ()
 
cTransform getGlobalTransform ()
 
void translate (const cVector3d &a_translation)
 
void translate (const double a_x, const double a_y, const double a_z=0.0)
 
void rotateAboutLocalAxisRad (const cVector3d &a_axis, const double a_angleRad)
 
void rotateAboutLocalAxisDeg (const cVector3d &a_axis, const double a_angleDeg)
 
void rotateAboutLocalAxisRad (const double a_axisX, const double a_axisY, const double a_axisZ, const double a_angleRad)
 
void rotateAboutLocalAxisDeg (const double a_axisX, const double a_axisY, const double a_axisZ, const double a_angleDeg)
 
void rotateAboutGlobalAxisRad (const cVector3d &a_axis, const double a_angleRad)
 
void rotateAboutGlobalAxisDeg (const cVector3d &a_axis, const double a_angleDeg)
 
void rotateAboutGlobalAxisRad (const double a_axisX, const double a_axisY, const double a_axisZ, const double a_angleRad)
 
void rotateAboutGlobalAxisDeg (const double a_axisX, const double a_axisY, const double a_axisZ, const double a_angleDeg)
 
void rotateExtrinsicEulerAnglesRad (const double &a_angleRad1, const double &a_angleRad2, const double &a_angleRad3, const cEulerOrder a_eulerOrder)
 
void rotateExtrinsicEulerAnglesDeg (const double &a_angleDeg1, const double &a_angleDeg2, const double &a_angleDeg3, const cEulerOrder a_eulerOrder)
 
void rotateIntrinsicEulerAnglesRad (const double &a_angleRad1, const double &a_angleRad2, const double &a_angleRad3, const cEulerOrder a_eulerOrder)
 
void rotateIntrinsicEulerAnglesDeg (const double &a_angleDeg1, const double &a_angleDeg2, const double &a_angleDeg3, const cEulerOrder a_eulerOrder)
 
virtual void computeGlobalPositions (const bool a_frameOnly=true, const cVector3d &a_globalPos=cVector3d(0.0, 0.0, 0.0), const cMatrix3d &a_globalRot=cIdentity3d())
 
void computeGlobalPositionsFromRoot (const bool a_frameOnly=true)
 
bool addEffect (cGenericEffect *a_effect)
 
bool removeEffect (cGenericEffect *a_effect)
 
void deleteAllEffects ()
 
void createEffectMagnetic (const bool a_affectChildren=false, const bool a_affectComponents=true)
 
void deleteEffectMagnetic (const bool a_affectChildren=false, const bool a_affectComponents=true)
 
void createEffectStickSlip (const bool a_affectChildren=false, const bool a_affectComponents=true)
 
void deleteEffectStickSlip (const bool a_affectChildren=false, const bool a_affectComponents=true)
 
void createEffectSurface (const bool a_affectChildren=false, const bool a_affectComponents=true)
 
void deleteEffectSurface (const bool a_affectChildren=false, const bool a_affectComponents=true)
 
void createEffectVibration (const bool a_affectChildren=false, const bool a_affectComponents=true)
 
void deleteEffectVibration (const bool a_affectChildren=false, const bool a_affectComponents=true)
 
void createEffectViscosity (const bool a_affectChildren=false, const bool a_affectComponents=true)
 
void deleteEffectViscosity (const bool a_affectChildren=false, const bool a_affectComponents=true)
 
virtual void setHapticEnabled (const bool a_hapticEnabled, const bool a_affectChildren=true, const bool a_affectComponents=true)
 
bool getHapticEnabled () const
 
virtual void setStiffness (const double a_stiffness, const bool a_affectChildren=true, const bool a_affectComponents=true)
 
virtual void setFriction (double a_staticFriction, double a_dynamicFriction, const bool a_affectChildren=true, const bool a_affectComponents=true)
 
virtual void setShowEnabled (const bool a_show, const bool a_affectChildren=true, const bool a_affectComponents=true)
 
bool getShowEnabled () const
 
virtual void setWireMode (const bool a_showWireMode, const bool a_affectChildren=false, const bool a_affectComponents=true)
 
bool getWireMode () const
 
virtual void setUseCulling (const bool a_useCulling, const bool a_affectChildren=false, const bool a_affectComponents=true)
 
bool getUseCulling () const
 
virtual void setUseTransparency (const bool a_useTransparency, const bool a_affectChildren=false, const bool a_affectComponents=true)
 
bool getUseTransparency () const
 
virtual void setTransparencyLevel (const float a_level, const bool a_applyToVertices=false, const bool a_applyToTextures=false, const bool a_affectChildren=false, const bool a_affectComponents=true)
 
virtual void setUseDisplayList (const bool a_useDisplayList, const bool a_affectChildren=false, const bool a_affectComponents=true)
 
bool getUseDisplayList () const
 
virtual void markForUpdate (const bool a_affectChildren=false, const bool a_affectComponents=true)
 
virtual void setUseVertexColors (const bool a_useColors, const bool a_affectChildren=false, const bool a_affectComponents=true)
 
bool getUseVertexColors () const
 
virtual void setUseMaterial (const bool a_useMaterial, const bool a_affectChildren=false, const bool a_affectComponents=true)
 
bool getUseMaterial () const
 
virtual void setMaterial (cMaterialPtr a_material, const bool a_affectChildren=false, const bool a_affectComponents=true)
 
virtual void setMaterial (cMaterial &a_material, const bool a_affectChildren=false, const bool a_affectComponents=true)
 
virtual void backupMaterialColors (const bool a_affectChildren=false, const bool a_affectComponents=true)
 
virtual void restoreMaterialColors (const bool a_affectChildren=false, const bool a_affectComponents=true)
 
virtual void setUseTexture (const bool a_useTexture, const bool a_affectChildren=false, const bool a_affectComponents=true)
 
bool getUseTexture () const
 
virtual void setTexture (cTexture1dPtr a_texture, const bool a_affectChildren=false, const bool a_affectComponents=true)
 
virtual void setShaderProgram (cShaderProgramPtr a_shaderProgram, const bool a_affectChildren=false, const bool a_affectComponents=true)
 
virtual cShaderProgramPtr getShaderProgram ()
 
virtual void setShowBoundaryBox (const bool a_showBoundaryBox, const bool a_affectChildren=false, const bool a_affectComponents=true)
 
bool getShowBoundaryBox () const
 
cVector3d getBoundaryMin () const
 
cVector3d getBoundaryMax () const
 
cVector3d getBoundaryCenter () const
 
bool getBoundaryBoxEmpty ()
 
virtual void computeBoundaryBox (const bool a_includeChildren=true)
 
virtual void setShowFrame (const bool a_showFrame, const bool a_affectChildren=false, const bool a_affectComponents=true)
 
bool getShowFrame (void) const
 
virtual void setFrameSize (const double a_size=1.0, const bool a_affectChildren=false, const bool a_affectComponents=true)
 
double getFrameSize () const
 
void setCollisionDetector (cGenericCollision *a_collisionDetector)
 
cGenericCollision * getCollisionDetector () const
 
virtual void deleteCollisionDetector (const bool a_affectChildren=false, const bool a_affectComponents=true)
 
virtual void setShowCollisionDetector (const bool a_showCollisionDetector, const bool a_affectChildren=false, const bool a_affectComponents=true)
 
bool getShowCollisionDetector ()
 
virtual void setCollisionDetectorProperties (unsigned int a_displayDepth, cColorf &a_color, const bool a_affectChildren=false, const bool a_affectComponents=true)
 
void setParent (cGenericObject *a_parent)
 
cGenericObject * getParent () const
 
void setOwner (cGenericObject *a_owner)
 
cGenericObject * getOwner ()
 
cGenericObject * getRootObject ()
 
cGenericObject * getChild (const unsigned int a_index) const
 
bool addChild (cGenericObject *a_object)
 
bool removeChild (cGenericObject *a_object)
 
bool removeFromGraph ()
 
bool deleteChild (cGenericObject *a_object)
 
void clearAllChildren ()
 
void deleteAllChildren ()
 
unsigned int getNumChildren ()
 
unsigned int getNumDescendants (bool a_includeCurrentObject=false)
 
bool addComponent (cGenericObject *a_component)
 
bool removeComponent (cGenericObject *a_object)
 
bool deleteComponent (cGenericObject *a_object)
 
void clearAllComponents ()
 
void deleteAllComponents ()
 
unsigned int getNumComponents ()
 
void setGhostEnabled (bool a_ghostEnabled)
 
bool getGhostEnabled ()
 
virtual void scale (const double &a_scaleFactor, const bool a_affectChildren=true, const bool a_affectComponents=true)
 
virtual void renderSceneGraph (cRenderOptions &a_options)
 
virtual void adjustCollisionSegment (cVector3d &a_segmentPointA, cVector3d &a_segmentPointAadjusted)
 
virtual cVector3d computeInteractions (const cVector3d &a_toolPos, const cVector3d &a_toolVel, const unsigned int a_IDN, cInteractionRecorder &a_interactions)
 
- Public Member Functions inherited from chai3d::cGenericType
 cGenericType ()
 
virtual ~cGenericType ()
 
virtual int getObjectCounter ()
 

Public Attributes

std::list< cODEGenericBody * > m_bodies
 List of all ODE dynamic bodies in world.
 
dWorldID m_ode_world
 ODE dynamics world.
 
dSpaceID m_ode_space
 ODE collision space.
 
dJointGroupID m_ode_contactgroup
 ODE contact group.
 
- Public Attributes inherited from chai3d::cGenericObject
cMaterialPtr m_material
 
cTexture1dPtr m_texture
 
cNormalMapPtr m_normalMap
 
int m_userTag
 
void * m_userData
 
std::string m_userName
 
cGenericObject * m_userExternalObject
 
cVector3d m_interactionPoint
 
cVector3d m_interactionNormal
 
bool m_interactionInside
 
- Public Attributes inherited from chai3d::cGenericType
std::string m_name
 
std::string m_filename
 
void * m_userPtr
 
int m_userIndex
 

Protected Member Functions

virtual void render (chai3d::cRenderOptions &a_options)
 This method render graphically all objects in the world.
 
- Protected Member Functions inherited from chai3d::cGenericObject
virtual void updateBoundaryBox ()
 
virtual void scaleObject (const double &a_scaleFactor)
 
virtual void computeLocalInteraction (const cVector3d &a_toolPos, const cVector3d &a_toolVel, const unsigned int a_IDN)
 
virtual cVector3d computeOtherInteractions (const cVector3d &a_toolPos, const cVector3d &a_toolVel, const unsigned int a_IDN, cInteractionRecorder &a_interactions)
 
virtual bool computeOtherCollisionDetection (cVector3d &a_segmentPointA, cVector3d &a_segmentPointB, cCollisionRecorder &a_recorder, cCollisionSettings &a_settings)
 
void copyGenericObjectProperties (cGenericObject *a_objDest, const bool a_duplicateMaterialData, const bool a_duplicateTextureData, const bool a_duplicateMeshData, const bool a_buildCollisionDetector)
 

Static Protected Member Functions

static void nearCallback (void *data, dGeomID o1, dGeomID o2)
 This method is an ODE callback that reports collisions.
 

Protected Attributes

double m_simulationTime
 Current time of simulation.
 
chai3d::cWorld * m_parentWorld
 Parent CHAI3D world.
 
- Protected Attributes inherited from chai3d::cGenericObject
cGenericObject * m_parent
 
cGenericObject * m_owner
 
std::vector< cGenericObject * > m_components
 
std::vector< cGenericObject * > m_children
 
cVector3d m_localPos
 
cVector3d m_globalPos
 
cMatrix3d m_localRot
 
cMatrix3d m_globalRot
 
cVector3d m_prevGlobalPos
 
cMatrix3d m_prevGlobalRot
 
cVector3d m_boundaryBoxMin
 
cVector3d m_boundaryBoxMax
 
bool m_boundaryBoxEmpty
 
double m_frameSize
 
double m_frameThicknessScale
 
bool m_enabled
 
bool m_showEnabled
 
bool m_hapticEnabled
 
bool m_ghostEnabled
 
bool m_showFrame
 
bool m_showBoundaryBox
 
bool m_showCollisionDetector
 
bool m_useTextureMapping
 
bool m_useMaterialProperty
 
bool m_useVertexColors
 
bool m_useDisplayList
 
cDisplayList m_displayList
 
int m_triangleMode
 
bool m_useTransparency
 
bool m_cullingEnabled
 
cShaderProgramPtr m_shaderProgram
 
cTransform m_frameGL
 
cGenericCollision * m_collisionDetector
 
std::vector< cGenericEffect * > m_effects
 

Additional Inherited Members

- Static Public Attributes inherited from chai3d::cGenericObject
static cColorf s_boundaryBoxColor
 
- Static Protected Attributes inherited from chai3d::cGenericObject
static cMaterialPtr s_defaultMaterial
 
- Static Protected Attributes inherited from chai3d::cGenericType
static int s_objectCounter
 

Detailed Description

cODEWorld implements a virtual world to handle ODE based objects (cODEGenericBody).

Constructor & Destructor Documentation

◆ cODEWorld()

cODEWorld::cODEWorld ( chai3d::cWorld *  a_parentWorld)

Constructor of cODEWorld.

Parameters
a_parentWorldPointer to parent CHAI3D world.

◆ ~cODEWorld()

cODEWorld::~cODEWorld ( )
virtual

Destructor of cODEWorld.

Member Function Documentation

◆ setGravity()

void cODEWorld::setGravity ( chai3d::cVector3d  a_gravity)

This methods defines a gravity field passed as argument.

Parameters
a_gravityGravity field vector.

◆ getGravity()

cVector3d cODEWorld::getGravity ( )

This methods returns the current gravity field vector.

Returns
Current gravity field vector.

◆ setLinearDamping()

void cODEWorld::setLinearDamping ( double  a_value)
inline

◆ setAngularDamping()

void cODEWorld::setAngularDamping ( double  a_value)
inline

◆ setMaxAngularSpeed()

void cODEWorld::setMaxAngularSpeed ( double  a_value)
inline

◆ updateDynamics()

void cODEWorld::updateDynamics ( double  a_interval)

This methods updates the simulation over a time interval passed as argument

Parameters
a_intervalTime increment.

◆ updateBodyPositions()

void cODEWorld::updateBodyPositions ( void  )

This methods updates the position and orientation from ODE models to CHAI3D models.

◆ updateGlobalPositions()

void cODEWorld::updateGlobalPositions ( const bool  a_frameOnly)
virtual

This methods computes globalPos and globalRot given the localPos and localRot of this object and its parents.

If a_frameOnly is set to false, additional global positions such as vertex positions are computed (which can be time-consuming).

Parameters
a_frameOnlyIf true then only the global frame is computed.

Reimplemented from chai3d::cGenericObject.

◆ computeCollisionDetection()

bool cODEWorld::computeCollisionDetection ( const chai3d::cVector3d &  a_segmentPointA,
const chai3d::cVector3d &  a_segmentPointB,
chai3d::cCollisionRecorder &  a_recorder,
chai3d::cCollisionSettings &  a_settings 
)
virtual

This method checks if the given line segment intersects any object located inside the virtual world.

Parameters
a_segmentPointAInitial point of segment.
a_segmentPointBEnd point of segment.
a_recorderRecorder which stores all collision events.
a_settingsStructure which contains some rules about how the collision detection should be performed.
Returns
true if a collision occurred, false otherwise.

Reimplemented from chai3d::cGenericObject.

◆ nearCallback()

void cODEWorld::nearCallback ( void *  a_data,
dGeomID  a_object1,
dGeomID  a_object2 
)
staticprotected

This methods is an ODE callback for handling collision detection.

Parameters
a_dataNot used here.
a_object1Reference to ODE object 1.
a_object2Reference to ODE object 2.

◆ render()

void cODEWorld::render ( chai3d::cRenderOptions &  a_options)
protectedvirtual

This methods renders the world graphically using OpenGL.

Parameters
a_optionsRendering options.

Reimplemented from chai3d::cGenericObject.

Member Data Documentation

◆ m_bodies

std::list<cODEGenericBody*> cODEWorld::m_bodies

◆ m_ode_world

dWorldID cODEWorld::m_ode_world

◆ m_ode_space

dSpaceID cODEWorld::m_ode_space

◆ m_ode_contactgroup

dJointGroupID cODEWorld::m_ode_contactgroup

◆ m_simulationTime

double cODEWorld::m_simulationTime
protected

◆ m_parentWorld

chai3d::cWorld* cODEWorld::m_parentWorld
protected

The documentation for this class was generated from the following files: