#include <Geom.h>
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 Geom * | asGeom () |
virtual const Geom * | asGeom () const |
GeometryHandler * | getHandler () |
Used to manipulate the geometry. | |
const GeometryHandler * | getHandler () const |
void | setBody (Body *pBody) |
Set a physical body to this geometry. | |
Body * | getBody () |
const Body * | getBody () 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 ¢er) |
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< Body > | pBody |
Attached body. | |
osg::ref_ptr< GeometryHandler > | pGeomH |
IGeomCollisionContainer * | pContainer |
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. | |
IGeomCollisionContainer * | getCollisionContainer () |
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 () |
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.
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 | |||
) |
Definition at line 58 of file Geom.cpp.
References ASSERT, Physics::AbstractGeom::COPY_BODIES, dGeomGetPositionV(), dGeomGetQuaternionV(), dGeomSetPosition(), dGeomSetQuaternion(), gameplayDensity, getMatrix(), getOffsetMatrix(), pBody, pGeomH, setBody(), setMatrix(), setOffsetMatrix(), and surface.
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] |
void Physics::Geom::addCollideBits | ( | ULONG | mask | ) | [inline] |
void Physics::Geom::applyHints | ( | ) | [protected] |
Applies the geometry handler's auto-disable hints.
Definition at line 132 of file Geom.cpp.
References Physics::GeometryHandler::AD_ANGULAR, Physics::GeometryHandler::AD_FLAG, Physics::GeometryHandler::AD_LINEAR, Physics::GeometryHandler::AD_SAMPLES_COUNT, Physics::GeometryHandler::AD_STEPS, Physics::GeometryHandler::AD_TIME, ASSERT, pBody, and pGeomH.
Referenced by resetAndApplyHints(), and setBody().
virtual const Geom* Physics::Geom::asGeom | ( | ) | const [inline, virtual] |
virtual Geom* Physics::Geom::asGeom | ( | ) | [inline, virtual] |
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()().
Body* Physics::Geom::getBody | ( | ) | [inline] |
Definition at line 115 of file Geom.h.
Referenced by C3DPhy::clearBodyContactPos(), Ammo::hitBefore(), Physics::NearCallback::operator()(), FindBodiesCopy::operator()(), and PhysicsDebugUpdateCB::operator()().
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] |
const GeometryHandler* Physics::Geom::getHandler | ( | ) | const [inline] |
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] |
void Physics::Geom::removeCategoryBits | ( | ULONG | mask | ) | [inline] |
void Physics::Geom::removeCollideBits | ( | ULONG | mask | ) | [inline] |
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] |
void Physics::Geom::rotate | ( | const osg::Quat & | quat | ) | [inline] |
Definition at line 141 of file Geom.h.
Referenced by GeomRotateVisitor::apply(), and C3DPhy::rotate().
void Physics::Geom::rotateOffset | ( | const osg::Quat & | offsetQuat | ) | [inline] |
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.
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.
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] |
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.
float Physics::Geom::gameplayDensity [protected] |
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().
IGeomCollisionContainer* Physics::Geom::pContainer [protected] |
osg::ref_ptr<GeometryHandler> Physics::Geom::pGeomH [protected] |
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()().