Physics::Geom Class Reference

Enhanced wrapper for physical geometries. More...

#include <Geom.h>

Inheritance diagram for Physics::Geom:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 Geom (GeometryHandler *pGeometryHandler, const SurfaceParams &surfaceParams=Materials::DEFAULT)
 Builds a geom by giving a GeometryHandler which will describe the geometry, and a SurfaceParams that will describe the surface.
 Geom (const Geom &v, UINT opts=COPY_ALL, IGeomCollisionContainer *pContainer=NULL, TDuplicatedBodiesMap *pDuplicatedBodies=NULL)
virtual GeomasGeom ()
virtual const GeomasGeom () const
GeometryHandlergetHandler ()
 Used to manipulate the geometry.
const GeometryHandlergetHandler () const
void setBody (Body *pBody)
 Set a physical body to this geometry.
BodygetBody ()
const BodygetBody () const
void resetAndApplyHints ()
 If attached to a body, sets the auto-disables parameters to the world's default, and applies the geometry handler's auto-disable hints.
virtual void accept (Visitor &v)
virtual void traverse (Visitor &v)
 Traverse children.
 operator dGeomID ()
 operator const dGeomID () const
Position and orientation
If attached to a body, setting these parameters will also set those of the body, and vice-versa.

If the geom has an offset (or is under a transform (deprecated)), then the methods will take into account the offset.

void translate (const osg::Vec3 &vec)
void rotate (const osg::Quat &quat)
void rotate (const osg::Quat &quat, const osg::Vec3 &center)
 Rotates the geom around a given point.
void setMatrix (const osg::Matrix &matrix)
 Convinience method for setting position and rotation at once.
osg::Matrix getMatrix () const
 Convinience method for getting position and rotation at once.
Offset from body
These methods can only be called if attached to a body, because an offset is computed from the body.

Please note that setting an offset will add a slight CPU overhead (computation is needed), so when offset becomes useless, call clearOffset() insetad of setting the offset position and rotation to identity.

void translateOffset (const osg::Vec3 &offset)
 Adds an offset translation from the body (or set it if the geom has no offset).
void rotateOffset (const osg::Quat &offsetQuat)
 Adds an offset rotation from the body (or set it if the geom has no offset).
void setOffsetMatrix (const osg::Matrix &offsetMatrix)
 Convinience method for setting offset position and rotation at once.
void setOffsetMatrixWorld (const osg::Matrix &worldMatrix)
 Convinience method for setting offset position and rotation at once by giving the geom new position and rotation in world coordinates.
void multOffset (const osg::Matrix &offsetMatrix)
 Convinience method for adding offset position and rotation at once.
osg::Matrix getOffsetMatrix () const
 Convinience method for getting offset position and rotation at once.
Collision methods
UINT collide (Geom *pGeom, UINT nbMaxContacts, Contact *pContacts)
 Do the collision detection (Used only by the main "near callback").
void addCategoryBits (ULONG mask)
 Convinience method for adding bits.
void removeCategoryBits (ULONG mask)
 Convinience method for removing bits.
void addCollideBits (ULONG mask)
 Convinience method for adding bits.
void removeCollideBits (ULONG mask)
 Convinience method for removing bits.

Protected Member Functions

void applyHints ()
 Applies the geometry handler's auto-disable hints.

Protected Attributes

osg::ref_ptr< BodypBody
 Attached body.
osg::ref_ptr< GeometryHandlerpGeomH
IGeomCollisionContainerpContainer
float gameplayDensity

PVLE's specific

SurfaceParams surface
 Surface parameters used on collision. These parameters are "merged" with others to determine the surface params of the contact.
IGeomCollisionContainergetCollisionContainer ()
 Gets the collision container if it exists, or NULL otherwise.
void setCollisionContainer (IGeomCollisionContainer *pContainer)
 Gets the collision container if it exists, or NULL otherwise.
void setGameplayDensity (float density)
 Sets a 'purely gameplay' density.
float getGameplayDensity ()


Detailed Description

Enhanced wrapper for physical geometries.

A geom is a physical geometry (used to perform collision detection), which can be attached to a body (In that case, it is a full physical object). Geoms in PVLE are generic, so you must provide a handler to create it. The handler is a class that will give you access to specific methods, such as setting the radius of the sphere (if the geom is a sphere), or the size of the box, etc. PVLE's geoms are specific (comparing to the ones they wrap) in the way they also :

Definition at line 87 of file Geom.h.


Constructor & Destructor Documentation

Physics::Geom::Geom ( GeometryHandler pGeometryHandler,
const SurfaceParams surfaceParams = Materials::DEFAULT 
)

Builds a geom by giving a GeometryHandler which will describe the geometry, and a SurfaceParams that will describe the surface.

Definition at line 39 of file Geom.cpp.

References pGeomH.

Physics::Geom::Geom ( const Geom v,
UINT  opts = COPY_ALL,
IGeomCollisionContainer pContainer = NULL,
TDuplicatedBodiesMap pDuplicatedBodies = NULL 
)


Member Function Documentation

void Physics::Geom::accept ( Visitor v  )  [virtual]

Reimplemented from Physics::AbstractGeom.

Definition at line 46 of file Geom.cpp.

References Physics::Visitor::apply().

Referenced by C3DPhy::accept().

void Physics::Geom::addCategoryBits ( ULONG  mask  )  [inline]

Convinience method for adding bits.

Definition at line 243 of file Geom.h.

void Physics::Geom::addCollideBits ( ULONG  mask  )  [inline]

Convinience method for adding bits.

Definition at line 256 of file Geom.h.

void Physics::Geom::applyHints (  )  [protected]

virtual const Geom* Physics::Geom::asGeom (  )  const [inline, virtual]

Reimplemented from Physics::AbstractGeom.

Definition at line 96 of file Geom.h.

virtual Geom* Physics::Geom::asGeom (  )  [inline, virtual]

Reimplemented from Physics::AbstractGeom.

Definition at line 95 of file Geom.h.

UINT Physics::Geom::collide ( Geom pGeom,
UINT  nbMaxContacts,
Contact pContacts 
)

Do the collision detection (Used only by the main "near callback").

Definition at line 145 of file Geom.cpp.

References Physics::AbstractGeom::id.

Referenced by Physics::NearCallback::operator()().

const Body* Physics::Geom::getBody (  )  const [inline]

Definition at line 116 of file Geom.h.

Body* Physics::Geom::getBody (  )  [inline]

IGeomCollisionContainer* Physics::Geom::getCollisionContainer (  )  [inline]

Gets the collision container if it exists, or NULL otherwise.

Definition at line 217 of file Geom.h.

Referenced by C3DPhy::addGeom(), Ammo::hitAfter(), Explosion::hitBefore(), Ammo::hitBefore(), Dummy3DPhy::hitBefore(), and Physics::NearCallback::operator()().

float Physics::Geom::getGameplayDensity (  )  [inline]

Definition at line 224 of file Geom.h.

Referenced by Ammo::hitBefore().

const GeometryHandler* Physics::Geom::getHandler (  )  const [inline]

Definition at line 100 of file Geom.h.

GeometryHandler* Physics::Geom::getHandler (  )  [inline]

Used to manipulate the geometry.

Definition at line 99 of file Geom.h.

Referenced by C3DPhy::createPhysicsDebugView(), Physics::NearCallback::operator()(), and PhysicsDebugUpdateCB::operator()().

osg::Matrix Physics::Geom::getMatrix (  )  const [inline]

Convinience method for getting position and rotation at once.

Definition at line 156 of file Geom.h.

References Physics::toGraphMatRotationPosition().

Referenced by Geom(), PhysicsUpdateCB::getLTWCamMatrix(), PhysicsUpdateCB::getWTLCamMatrix(), PhysicsUpdateCB::operator()(), and PhysicsDebugUpdateCB::operator()().

osg::Matrix Physics::Geom::getOffsetMatrix (  )  const [inline]

Convinience method for getting offset position and rotation at once.

Definition at line 200 of file Geom.h.

References Physics::toGraphMatRotationPosition().

Referenced by Geom().

void Physics::Geom::multOffset ( const osg::Matrix &  offsetMatrix  )  [inline]

Convinience method for adding offset position and rotation at once.

Definition at line 198 of file Geom.h.

Physics::Geom::operator const dGeomID (  )  const [inline]

Definition at line 265 of file Geom.h.

Physics::Geom::operator dGeomID (  )  [inline]

Definition at line 264 of file Geom.h.

void Physics::Geom::removeCategoryBits ( ULONG  mask  )  [inline]

Convinience method for removing bits.

Definition at line 245 of file Geom.h.

void Physics::Geom::removeCollideBits ( ULONG  mask  )  [inline]

Convinience method for removing bits.

Definition at line 258 of file Geom.h.

void Physics::Geom::resetAndApplyHints (  ) 

If attached to a body, sets the auto-disables parameters to the world's default, and applies the geometry handler's auto-disable hints.

If not attached to a body, calling this method will do nothing.

Definition at line 125 of file Geom.cpp.

References applyHints(), and pBody.

void Physics::Geom::rotate ( const osg::Quat &  quat,
const osg::Vec3 &  center 
) [inline]

Rotates the geom around a given point.

Definition at line 143 of file Geom.h.

void Physics::Geom::rotate ( const osg::Quat &  quat  )  [inline]

Todo:
Optimize this by avoiding ODE/OSG conversions.

Definition at line 141 of file Geom.h.

Referenced by GeomRotateVisitor::apply(), and C3DPhy::rotate().

void Physics::Geom::rotateOffset ( const osg::Quat &  offsetQuat  )  [inline]

Adds an offset rotation from the body (or set it if the geom has no offset).

Todo:
Optimize this by avoiding ODE/OSG conversions.

Definition at line 185 of file Geom.h.

void Physics::Geom::setBody ( Body pBody  ) 

Set a physical body to this geometry.

Once set, moving the body will move the geometry and vice versa. Also note that when setting a body, the geom will automatically modify the body so that it will match geometry handler's auto-disable hints.

Composite objects
Composite objects can easily be created by setting more than one geom attached to the same body, and using offsets.
There is one caveat with composite objects: You should never create a composite object that will result in collision points being generated very close together. For example, consider a table that is made up of a box for the top and four boxes for the legs. If the legs are flush with the top, and the table is lying on the ground on its side, then the contact points generated for the boxes may coincide where the legs join to the top.
Note that geometry handler's auto-disable hints are CUMULATED for composite objects ! For example, if you set 2 geoms (let's say A and B) having the same body ; if A has a step hint and a time hint, and B has a linear threshold hint and a step hint ; then setting A then B will:
  • Apply A's step and time hints to the body
  • Apply B's linear threshold hint and overwrite A's step hint... Anyway, you should set body's parameters yourself after if needed, or call resetAndApplyHints().

Definition at line 113 of file Geom.cpp.

References applyHints(), and Physics::Body::id.

Referenced by Physics::createCanonicalBox(), Physics::createCanonicalCapsule(), Physics::createCanonicalCylinder(), Physics::createCanonicalSphere(), and Geom().

void Physics::Geom::setCollisionContainer ( IGeomCollisionContainer pContainer  )  [inline]

Gets the collision container if it exists, or NULL otherwise.

Definition at line 219 of file Geom.h.

Referenced by C3DPhy::addGeom().

void Physics::Geom::setGameplayDensity ( float  density  )  [inline]

Sets a 'purely gameplay' density.

This parameter only inlfuences perforant ammunition.

See also:
Physical densities of various materials for indicative values.

Definition at line 223 of file Geom.h.

void Physics::Geom::setMatrix ( const osg::Matrix &  matrix  )  [inline]

Convinience method for setting position and rotation at once.

Definition at line 148 of file Geom.h.

References dGeomSetPosition(), and dGeomSetRotation().

Referenced by Geom().

void Physics::Geom::setOffsetMatrix ( const osg::Matrix &  offsetMatrix  )  [inline]

Convinience method for setting offset position and rotation at once.

Definition at line 188 of file Geom.h.

References dGeomSetOffsetPosition(), and dGeomSetOffsetRotation().

Referenced by Geom().

void Physics::Geom::setOffsetMatrixWorld ( const osg::Matrix &  worldMatrix  )  [inline]

Convinience method for setting offset position and rotation at once by giving the geom new position and rotation in world coordinates.

Definition at line 193 of file Geom.h.

References dGeomSetOffsetWorldPosition(), and dGeomSetOffsetWorldRotation().

void Physics::Geom::translate ( const osg::Vec3 &  vec  )  [inline]

Definition at line 134 of file Geom.h.

References dGeomSetPosition().

Referenced by GeomTranslateVisitor::apply(), and C3DPhy::translate().

void Physics::Geom::translateOffset ( const osg::Vec3 &  offset  )  [inline]

Adds an offset translation from the body (or set it if the geom has no offset).

Definition at line 173 of file Geom.h.

void Physics::Geom::traverse ( Visitor v  )  [virtual]

Traverse children.

Reimplemented from Physics::AbstractGeom.

Definition at line 47 of file Geom.cpp.

References Physics::Visitor::apply(), and pBody.


Member Data Documentation

float Physics::Geom::gameplayDensity [protected]

Definition at line 278 of file Geom.h.

Referenced by Geom().

osg::ref_ptr<Body> Physics::Geom::pBody [protected]

Attached body.

Definition at line 274 of file Geom.h.

Referenced by applyHints(), Geom(), resetAndApplyHints(), and traverse().

Definition at line 277 of file Geom.h.

osg::ref_ptr<GeometryHandler> Physics::Geom::pGeomH [protected]

Definition at line 275 of file Geom.h.

Referenced by applyHints(), and Geom().

Surface parameters used on collision. These parameters are "merged" with others to determine the surface params of the contact.

Definition at line 214 of file Geom.h.

Referenced by Geom(), and Physics::NearCallback::operator()().


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

Generated on Sun Jan 17 11:39:35 2010 for PVLE (Pro-Vocation Light Engine) by  doxygen 1.5.9