opal::ODESolid Class Reference

#include <ODESolid.h>

Inheritance diagram for opal::ODESolid:

opal::Solid List of all members.

Public Member Functions

 ODESolid (dWorldID worldID, dSpaceID spaceID)
virtual ~ODESolid ()
virtual void OPAL_CALL init (const SolidData &data)
virtual void OPAL_CALL setEnabled (bool e)
virtual void OPAL_CALL setSleeping (bool sleeping)
virtual void OPAL_CALL setSpace (Space *newSpace)
virtual bool OPAL_CALL isSleeping () const
virtual void OPAL_CALL setSleepiness (real s)
virtual void OPAL_CALL setStatic (bool s)
virtual void OPAL_CALL clearShapes ()
virtual void OPAL_CALL addShape (ShapeData &data)
virtual void OPAL_CALL setLocalLinearVel (const Vec3r &vel)
virtual Vec3r OPAL_CALL getLocalLinearVel () const
virtual Vec3r OPAL_CALL getLocalLinearVelAtLocalPos (const Point3r &p) const
virtual void OPAL_CALL setLocalAngularVel (const Vec3r &vel)
virtual Vec3r OPAL_CALL getLocalAngularVel () const
virtual void OPAL_CALL setGlobalLinearVel (const Vec3r &vel)
virtual Vec3r OPAL_CALL getGlobalLinearVel () const
virtual Vec3r OPAL_CALL getGlobalLinearVelAtLocalPos (const Point3r &p) const
virtual void OPAL_CALL setGlobalAngularVel (const Vec3r &vel)
virtual Vec3r OPAL_CALL getGlobalAngularVel () const
virtual void OPAL_CALL setMass (const Mass &newmass, const Matrix44r &offset)
virtual void OPAL_CALL translateMass (const Vec3r &offset)
virtual void OPAL_CALL zeroForces ()
virtual real OPAL_CALL getMass () const
virtual Matrix44r OPAL_CALL getInertiaTensor () const
virtual void OPAL_CALL internal_updateOPALTransform ()
virtual void OPAL_CALL internal_updateEngineTransform ()
dBodyID OPAL_CALL internal_getBodyID () const
void OPAL_CALL internal_setCollisionCount (long int count)
long int OPAL_CALL internal_getCollisionCount () const
const std::vector< GeomData
* > *OPAL_CALL 
internal_getGeomDataList () const
void OPAL_CALL internal_doAngularVelFix ()
void OPAL_CALL internal_setFreelySpinning (bool fs)

Protected Member Functions

void setupNewGeom (GeomData *newGeom)
void destroyGeoms ()
void moveToSpace ()
virtual void applyForce (const Force &f)
void addMass (dMass &newMass, const Matrix44r &offset)
void setMass (dMass &newMass, const Matrix44r &offset)
bool isInertiaNonSymmetric (const dMass &mass) const

Protected Attributes

dBodyID mBodyID
dWorldID mWorldID
dSpaceID mSpaceID
std::vector< GeomData * > mGeomDataList
long int mCollisionCount
bool mIsPlaceable
bool mNonSymmetricInertia
bool mIsFreelySpinning
real mPrevAngVelMagSquared

Detailed Description

The ODE implementation of the Solid class. Each ODE geom's user data pointer points to its corresponding ShapeData object.

Definition at line 62 of file ODESolid.h.


Constructor & Destructor Documentation

opal::ODESolid::ODESolid dWorldID  worldID,
dSpaceID  spaceID
 

Definition at line 43 of file ODESolid.cpp.

References init(), opal::SolidData::isStatic, mBodyID, mCollisionCount, opal::Solid::mData, mIsFreelySpinning, mIsPlaceable, mNonSymmetricInertia, mPrevAngVelMagSquared, mSpaceID, and mWorldID.

opal::ODESolid::~ODESolid  )  [virtual]
 

Definition at line 66 of file ODESolid.cpp.

References destroyGeoms(), opal::SolidData::isStatic, mBodyID, and opal::Solid::mData.


Member Function Documentation

void opal::ODESolid::addMass dMass &  newMass,
const Matrix44r offset
[protected]
 

Adds the given mass to this Solid's existing mass. The offset is relative to the Solid's center. This must be called before setupNewGeom is called.

Definition at line 1083 of file ODESolid.cpp.

References opal::SolidData::isStatic, mBodyID, opal::Solid::mData, and mGeomDataList.

Referenced by setStatic().

void opal::ODESolid::addShape ShapeData data  )  [virtual]
 

Adds a Shape to this Solid. Updates the Solid's axis-aligned bounding box.

Implements opal::Solid.

Definition at line 513 of file ODESolid.cpp.

References opal::BOX_SHAPE, opal::Material::density, opal::ShapeData::getType(), opal::ShapeData::material, mSpaceID, and opal::ShapeData::offset.

Referenced by init().

void opal::ODESolid::applyForce const Force f  )  [protected, virtual]
 

Physics engine-specific function for applying Forces to Solids.

Implements opal::Solid.

Definition at line 1009 of file ODESolid.cpp.

References opal::GLOBAL_FORCE, opal::GLOBAL_FORCE_AT_GLOBAL_POS, opal::GLOBAL_FORCE_AT_LOCAL_POS, opal::GLOBAL_TORQUE, internal_setFreelySpinning(), opal::LOCAL_FORCE, opal::LOCAL_FORCE_AT_GLOBAL_POS, opal::LOCAL_FORCE_AT_LOCAL_POS, opal::LOCAL_TORQUE, mBodyID, opal::Force::pos, opal::Force::type, and opal::Force::vec.

void opal::ODESolid::clearShapes  )  [virtual]
 

Removes all shapes from this Solid. Resets the Solid's axis-aligned bounding box.

Implements opal::Solid.

Definition at line 78 of file ODESolid.cpp.

References destroyGeoms(), opal::SolidData::destroyShapes(), opal::Solid::mData, and opal::Solid::resetAABB().

void opal::ODESolid::destroyGeoms  )  [protected]
 

Destroys all of this Solid's ODE geoms.

Definition at line 85 of file ODESolid.cpp.

References mGeomDataList.

Referenced by clearShapes(), init(), and ~ODESolid().

Vec3r opal::ODESolid::getGlobalAngularVel  )  const [virtual]
 

Returns the Solid's angular velocity in global coordinates.

Implements opal::Solid.

Definition at line 834 of file ODESolid.cpp.

References opal::SolidData::isStatic, mBodyID, opal::Solid::mData, and opal::toVec3r_RadToDeg().

Referenced by internal_doAngularVelFix().

Vec3r opal::ODESolid::getGlobalLinearVel  )  const [virtual]
 

Returns the Solid's linear velocity in global coordinates.

Implements opal::Solid.

Definition at line 794 of file ODESolid.cpp.

References opal::SolidData::isStatic, mBodyID, opal::Solid::mData, and opal::toVec3r().

Vec3r opal::ODESolid::getGlobalLinearVelAtLocalPos const Point3r p  )  const [virtual]
 

Given an offset point relative to the Solid's local origin, returns the linear velocity of the point in global coordinates.

Implements opal::Solid.

Definition at line 807 of file ODESolid.cpp.

References opal::SolidData::isStatic, mBodyID, opal::Solid::mData, and opal::toVec3r().

Matrix44r opal::ODESolid::getInertiaTensor  )  const [virtual]
 

Returns the Solid's inertia tensor as a 4x4 matrix. This will be the identity matrix if the Solid is static.

Implements opal::Solid.

Definition at line 930 of file ODESolid.cpp.

References opal::SolidData::isStatic, mBodyID, opal::Solid::mData, and opal::Matrix44r::set().

Vec3r opal::ODESolid::getLocalAngularVel  )  const [virtual]
 

Returns the Solid's angular velocity in local coordinates.

Implements opal::Solid.

Definition at line 766 of file ODESolid.cpp.

References opal::SolidData::isStatic, mBodyID, opal::Solid::mData, and opal::toVec3r_RadToDeg().

Vec3r opal::ODESolid::getLocalLinearVel  )  const [virtual]
 

Returns the Solid's linear velocity in local coordinates.

Implements opal::Solid.

Definition at line 716 of file ODESolid.cpp.

References opal::SolidData::isStatic, mBodyID, opal::Solid::mData, and opal::toVec3r().

Vec3r opal::ODESolid::getLocalLinearVelAtLocalPos const Point3r p  )  const [virtual]
 

Given an offset point relative to the Solid's local origin, returns the linear velocity of the point in local coordinates.

Implements opal::Solid.

Definition at line 733 of file ODESolid.cpp.

References opal::SolidData::isStatic, mBodyID, opal::Solid::mData, and opal::toVec3r().

real opal::ODESolid::getMass  )  const [virtual]
 

Returns the Solid's mass. This will return 0 if the Solid is static.

Implements opal::Solid.

Definition at line 916 of file ODESolid.cpp.

References opal::SolidData::isStatic, mBodyID, and opal::Solid::mData.

void opal::ODESolid::init const SolidData data  )  [virtual]
 

Initializes the Solid with the given data structure. Calling this more than once will automatically destroy all the old Shapes before adding new ones.

Implements opal::Solid.

Definition at line 111 of file ODESolid.cpp.

References addShape(), destroyGeoms(), opal::SolidData::destroyShapes(), opal::SolidData::getNumShapes(), opal::SolidData::getShapeData(), opal::SolidData::isStatic, opal::Solid::mData, setStatic(), opal::Solid::setTransform(), and opal::SolidData::transform.

Referenced by ODESolid().

void opal::ODESolid::internal_doAngularVelFix  ) 
 

Fix angular velocities for freely-spinning bodies that have gained angular velocity through explicit integrator inaccuracy. This usually only happens for long, thin objects.

Definition at line 1149 of file ODESolid.cpp.

References getGlobalAngularVel(), internal_setFreelySpinning(), opal::Vec3r::lengthSquared(), mIsFreelySpinning, mNonSymmetricInertia, mPrevAngVelMagSquared, and setGlobalAngularVel().

dBodyID opal::ODESolid::internal_getBodyID  )  const
 

Returns the ODE body ID of this ODESolid.

Definition at line 847 of file ODESolid.cpp.

References mBodyID.

long int opal::ODESolid::internal_getCollisionCount  )  const
 

Used internally by volume collision checking.

Definition at line 857 of file ODESolid.cpp.

References mCollisionCount.

Referenced by opal::ODESimulator::internal_addCollidedSolid().

const std::vector< GeomData * > * opal::ODESolid::internal_getGeomDataList  )  const
 

Returns all geom data objects in this ODESolid.

Definition at line 1144 of file ODESolid.cpp.

References mGeomDataList.

void opal::ODESolid::internal_setCollisionCount long int  count  ) 
 

Used internally by volume collision checking.

Definition at line 852 of file ODESolid.cpp.

References mCollisionCount.

Referenced by opal::ODESimulator::internal_addCollidedSolid().

void opal::ODESolid::internal_setFreelySpinning bool  fs  ) 
 

Sets whether this object is freely-spinning (i.e. no recent physical contacts, no user-generated forces, no user-defined velocity changes).

Definition at line 1182 of file ODESolid.cpp.

References mIsFreelySpinning.

Referenced by applyForce(), internal_doAngularVelFix(), setGlobalAngularVel(), setGlobalLinearVel(), setLocalAngularVel(), and setLocalLinearVel().

void opal::ODESolid::internal_updateEngineTransform  )  [virtual]
 

Update the physics engine transform using the OPAL transform.

Implements opal::Solid.

Definition at line 201 of file ODESolid.cpp.

References opal::SolidData::isStatic, mBodyID, opal::Solid::mData, mGeomDataList, mIsPlaceable, and opal::SolidData::transform.

void opal::ODESolid::internal_updateOPALTransform  )  [virtual]
 

Update the OPAL transform using the physics engine transform.

Implements opal::Solid.

Definition at line 190 of file ODESolid.cpp.

References mBodyID, opal::Solid::mData, opal::Matrix44r::set(), and opal::SolidData::transform.

bool opal::ODESolid::isInertiaNonSymmetric const dMass &  mass  )  const [protected]
 

Returns true if the given mass has a non-symmetric inertia tensor.

Definition at line 1187 of file ODESolid.cpp.

References opal::areEqual().

Referenced by setMass(), and translateMass().

bool opal::ODESolid::isSleeping  )  const [virtual]
 

Returns true if the Solid is sleeping. If the Solid is static, this will always return true.

Implements opal::Solid.

Definition at line 430 of file ODESolid.cpp.

References opal::SolidData::isStatic, mBodyID, and opal::Solid::mData.

void opal::ODESolid::moveToSpace  )  [protected]
 

move to geometry to current space

Definition at line 385 of file ODESolid.cpp.

References mGeomDataList, and mSpaceID.

Referenced by setSpace().

void opal::ODESolid::setEnabled bool  e  )  [virtual]
 

Sets whether the Solid can collide with other Solids and be physically simulated. Forces applied to this Solid while disabled will be ignored.

Reimplemented from opal::Solid.

Definition at line 154 of file ODESolid.cpp.

References opal::SolidData::isStatic, mBodyID, opal::Solid::mData, and mGeomDataList.

void opal::ODESolid::setGlobalAngularVel const Vec3r vel  )  [virtual]
 

Sets the Solid's angular velocity in global coordinates.

Implements opal::Solid.

Definition at line 822 of file ODESolid.cpp.

References opal::degToRad(), internal_setFreelySpinning(), opal::SolidData::isStatic, mBodyID, and opal::Solid::mData.

Referenced by internal_doAngularVelFix().

void opal::ODESolid::setGlobalLinearVel const Vec3r vel  )  [virtual]
 

Sets the Solid's linear velocity in global coordinates.

Implements opal::Solid.

Definition at line 783 of file ODESolid.cpp.

References internal_setFreelySpinning(), opal::SolidData::isStatic, mBodyID, and opal::Solid::mData.

void opal::ODESolid::setLocalAngularVel const Vec3r vel  )  [virtual]
 

Sets the Solid's angular velocity in local coordinates.

Implements opal::Solid.

Definition at line 752 of file ODESolid.cpp.

References internal_setFreelySpinning(), opal::SolidData::isStatic, mBodyID, opal::Solid::mData, and opal::toVec3r_DegToRad().

void opal::ODESolid::setLocalLinearVel const Vec3r vel  )  [virtual]
 

Sets the Solid's linear velocity in local coordinates.

Implements opal::Solid.

Definition at line 703 of file ODESolid.cpp.

References internal_setFreelySpinning(), opal::SolidData::isStatic, mBodyID, and opal::Solid::mData.

void opal::ODESolid::setMass dMass &  newMass,
const Matrix44r offset
[protected]
 

Sets the given mass ignoring previous settings.

Definition at line 1121 of file ODESolid.cpp.

References isInertiaNonSymmetric(), opal::SolidData::isStatic, mBodyID, opal::Solid::mData, and mNonSymmetricInertia.

void opal::ODESolid::setMass const Mass newmass,
const Matrix44r offset
[virtual]
 

Set a new mass, center, and intertia for the solid.

Implements opal::Solid.

Definition at line 1047 of file ODESolid.cpp.

References opal::Mass::center, opal::Mass::inertia, isInertiaNonSymmetric(), opal::SolidData::isStatic, opal::Mass::mass, mBodyID, opal::Solid::mData, mNonSymmetricInertia, opal::Vec3r::x, opal::Vec3r::y, and opal::Vec3r::z.

Referenced by setStatic().

void opal::ODESolid::setSleepiness real  s  )  [virtual]
 

If this Solid has no ODE body, just return. The sleepiness level will still be saved and applied if this Solid ever becomes dynamic.

Reimplemented from opal::Solid.

Definition at line 449 of file ODESolid.cpp.

References opal::defaults::ode::autoDisableAngularMax, opal::defaults::ode::autoDisableAngularMin, opal::defaults::ode::autoDisableLinearMax, opal::defaults::ode::autoDisableLinearMin, opal::defaults::ode::autoDisableStepsMax, opal::defaults::ode::autoDisableStepsMin, opal::defaults::ode::autoDisableTimeMax, opal::defaults::ode::autoDisableTimeMin, opal::SolidData::isStatic, mBodyID, opal::Solid::mData, and opal::Solid::setSleepiness().

Referenced by setStatic().

void opal::ODESolid::setSleeping bool  sleeping  )  [virtual]
 

Sets whether the Solid is sleeping (i.e. set this to false to wake up a sleeping Solid).

Implements opal::Solid.

Definition at line 411 of file ODESolid.cpp.

References opal::SolidData::isStatic, mBodyID, and opal::Solid::mData.

void opal::ODESolid::setSpace Space newSpace  )  [virtual]
 

Removes the Solid from its current Space and adds it to the new Space.

Implements opal::Solid.

Definition at line 240 of file ODESolid.cpp.

References moveToSpace(), and mSpaceID.

void opal::ODESolid::setStatic bool  s  )  [virtual]
 

Sets whether the Solid should be static or dynamic.

Implements opal::Solid.

Definition at line 248 of file ODESolid.cpp.

References addMass(), opal::BOX_SHAPE, opal::CAPSULE_SHAPE, opal::Material::density, opal::ShapeData::getType(), opal::SolidData::isStatic, opal::CapsuleShapeData::length, opal::ShapeData::material, mBodyID, opal::Solid::mData, opal::MESH_SHAPE, mGeomDataList, mWorldID, opal::PLANE_SHAPE, opal::CapsuleShapeData::radius, opal::SphereShapeData::radius, setMass(), setSleepiness(), opal::SolidData::sleepiness, opal::SPHERE_SHAPE, and opal::SolidData::transform.

Referenced by init().

void opal::ODESolid::setupNewGeom GeomData newGeom  )  [protected]
 

Adds a new GeomData object to the internal list and sets up the ODE geom.

Definition at line 952 of file ODESolid.cpp.

References opal::GeomData::geomID, opal::SolidData::isStatic, mBodyID, opal::Solid::mData, mGeomDataList, mIsPlaceable, opal::ShapeData::offset, opal::Solid::setTransform(), opal::GeomData::shape, opal::SolidData::transform, and opal::GeomData::transformID.

void opal::ODESolid::translateMass const Vec3r offset  )  [virtual]
 

Translate the Solid's mass using the given offset vector specified in global coordinates.

Implements opal::Solid.

Definition at line 499 of file ODESolid.cpp.

References isInertiaNonSymmetric(), opal::SolidData::isStatic, mBodyID, opal::Solid::mData, and mNonSymmetricInertia.

void opal::ODESolid::zeroForces  )  [virtual]
 

Removes all forces and torques currently affecting this Solid.

Implements opal::Solid.

Definition at line 902 of file ODESolid.cpp.

References opal::SolidData::isStatic, mBodyID, opal::Solid::mData, and opal::Solid::mForceList.


Member Data Documentation

dBodyID opal::ODESolid::mBodyID [protected]
 

The ODE body ID.

Definition at line 178 of file ODESolid.h.

Referenced by addMass(), applyForce(), getGlobalAngularVel(), getGlobalLinearVel(), getGlobalLinearVelAtLocalPos(), getInertiaTensor(), getLocalAngularVel(), getLocalLinearVel(), getLocalLinearVelAtLocalPos(), getMass(), internal_getBodyID(), internal_updateEngineTransform(), internal_updateOPALTransform(), isSleeping(), ODESolid(), setEnabled(), setGlobalAngularVel(), setGlobalLinearVel(), setLocalAngularVel(), setLocalLinearVel(), setMass(), setSleepiness(), setSleeping(), setStatic(), setupNewGeom(), translateMass(), zeroForces(), and ~ODESolid().

long int opal::ODESolid::mCollisionCount [protected]
 

Used internally by volume collision checking.

Definition at line 191 of file ODESolid.h.

Referenced by internal_getCollisionCount(), internal_setCollisionCount(), and ODESolid().

std::vector<GeomData*> opal::ODESolid::mGeomDataList [protected]
 

An internal list of this ODESolid's geom data objects.

Definition at line 188 of file ODESolid.h.

Referenced by addMass(), destroyGeoms(), internal_getGeomDataList(), internal_updateEngineTransform(), moveToSpace(), setEnabled(), setStatic(), and setupNewGeom().

bool opal::ODESolid::mIsFreelySpinning [protected]
 

Used to improve ODE's angular velocity calculations for objects with non-symmetric inertia tensors.

Definition at line 202 of file ODESolid.h.

Referenced by internal_doAngularVelFix(), internal_setFreelySpinning(), and ODESolid().

bool opal::ODESolid::mIsPlaceable [protected]
 

True if this ODESolid is "placeable." This is false only for Solids containing planes Shapes.

Definition at line 195 of file ODESolid.h.

Referenced by internal_updateEngineTransform(), ODESolid(), and setupNewGeom().

bool opal::ODESolid::mNonSymmetricInertia [protected]
 

True if the ODESolid has a non-symmetric inertia tensor.

Definition at line 198 of file ODESolid.h.

Referenced by internal_doAngularVelFix(), ODESolid(), setMass(), and translateMass().

real opal::ODESolid::mPrevAngVelMagSquared [protected]
 

Used to improve ODE's angular velocity calculations for objects with non-symmetric inertia tensors.

Definition at line 206 of file ODESolid.h.

Referenced by internal_doAngularVelFix(), and ODESolid().

dSpaceID opal::ODESolid::mSpaceID [protected]
 

The ODE space ID that contains this ODESolid's geoms.

Definition at line 185 of file ODESolid.h.

Referenced by addShape(), moveToSpace(), ODESolid(), and setSpace().

dWorldID opal::ODESolid::mWorldID [protected]
 

The ODE world ID that contains this ODESolid's ODE body, if this Solid is dynamic.

Definition at line 182 of file ODESolid.h.

Referenced by ODESolid(), and setStatic().


The documentation for this class was generated from the following files:
Generated on Tue May 16 17:49:57 2006 for OPAL by  doxygen 1.4.6-NO