#include <3DPhy.h>
Public Types | |
enum | EInitOptions { INIT_NONE, INIT_BIND_ONCE, INIT_AUTO_BIND } |
enum | ECopyOptions { COPY_3D = 0x1, COPY_PHYSICS = 0x2, COPY_OWNER = 0x4, COPY_TTL = 0x8, COPY_DEFAULT = COPY_3D | COPY_PHYSICS, COPY_ALL = 0xffffffff } |
Public Member Functions | |
C3DPhy (const C3DPhy *pInheritTeamAndPlayer=NULL) | |
Creates an empty 3DPhy, without an owner. | |
C3DPhy (osg::MatrixTransform *pModel, Physics::Geom *pGeom, EInitOptions options=INIT_NONE, const C3DPhy *pInheritTeamAndPlayer=NULL) | |
Creates a complete 3DPhy with only one geom, without an owner. If parameter options is INIT_AUTO_BIND , then the method bind() will be called ; and if equal to INIT_BIND_ONCE, then the method set3DtoPhy() will be called. Note it will call setGeom(), so pGeom's collision container can be modified. | |
C3DPhy (const C3DPhy &v, UINT copyOpts=COPY_DEFAULT) | |
Copies a 3DPhy. | |
virtual const char * | className () const |
virtual EContainerType | getType () const |
Gets the type of the current container. | |
virtual C3DPhy * | as3DPhy () |
virtual void | step (dReal stepSize) |
Steps the 3D-Phy. Default is to do nothing but decreasing the TTL and call the onTTLZero() method if necessary. | |
C3DPhyOwner * | get3DPhyOwner () |
Gets its owner (owner is set when the 3D-Phy is added to / detatched from an owner). | |
const C3DPhyOwner * | get3DPhyOwner () const |
void | accept (Physics::Visitor &v) |
void | markAsRemoved () |
Self-destruct method: tells the owner of this 3DPhy to mark it as removed. | |
3D part | |
osg::MatrixTransform * | getModel () |
operator osg::MatrixTransform * () | |
const osg::MatrixTransform * | getModel () const |
operator const osg::MatrixTransform * () const | |
void | setModel (osg::MatrixTransform *pModel) |
Collisions | |
virtual bool | hitBefore (Physics::Contact *pContacts, unsigned int nbContacts, Physics::Contact *pMaxEnergyContact, Physics::Geom &thisGeom, Physics::Geom &otherGeom, Physics::Body *&inout_pThisBody, Physics::Body *&inout_pOtherBody) |
Default behaviour on hit is to do nothing. | |
virtual void | hitAfter (Physics::Contact *pContacts, unsigned int nbContacts, Physics::Contact *pMaxEnergyContact, Physics::Geom &thisGeom, Physics::Geom &otherGeom, bool contactJointCreated) |
Applies cinetic collision. Can be overloaded so that it takes into account armour parameters (ie. for units). | |
void | isHitBy (WeaponEnergy::EEneryType type, double energy, const osg::Vec3 &point) |
This method is a helper that handles an energy transfer towards this 3DPhy when you don't know the energy type at compile time. | |
virtual void | isHitByRadiant (double energy, const osg::Vec3 &point) |
Energy transfer towards this 3DPhy. | |
virtual void | isHitByPerforant (double energy, const osg::Vec3 &point) |
virtual void | isHitByThermal (double energy, const osg::Vec3 &point) |
virtual void | isHitByChemical (double energy, const osg::Vec3 &point) |
virtual void | isHitByCinetic (double energy, const osg::Vec3 &point) |
This method differs from others isHitBy* because it is not only about a weapon, but also for simple collisions. | |
void | createPhysicsDebugView (bool enable) |
Adds (or removes) 3D debug shapes that represent geoms, but only if REMOVE_DEV_FEATURES is not defined (this method does nothing otherwise). | |
TTL (Time To Live) | |
void | setTTL (double ttl) |
Sets the remaining TTL ; <0 means "infinite time". Warning : the ttl can be tested to be null with an epsilon. So do not set it to -1e-10, because even if it is <0, it can be considered as 0 and the 3D-Phy could be deleted ! | |
double | getTTL () |
Gets the remaining TTL. | |
virtual void | onTTLZero () |
Handles the event "TTL has expired". Defaults is to destroy istelf if the 3D-Phy has an owner (does nothing otherwise). | |
Callback | |
void | setDeleteCallback (C3DPhyCallback *pCB) |
C3DPhyCallback * | getDeleteCallback () |
const C3DPhyCallback * | getDeleteCallback () const |
Gameplay | |
PVLEPlayer * | getPlayer () |
Player (human or IA) that has the 3D-Phy (unit, building...), or NULL. | |
const PVLEPlayer * | getPlayer () const |
Const version of getPlayer(). | |
void | setPlayer (PVLEPlayer *pPlayer) |
Sets the player (and the 3DPhy's team becomes the player's team, to stay consistent). | |
PVLETeam * | getTeam () |
Team that has the 3D-Phy (unit, building...), or NULL. | |
const PVLETeam * | getTeam () const |
Const version of getTeam(). | |
void | setTeam (PVLETeam *pTeam) |
Sets this 3D-Phy to belong to a specific team (or NULL), and sets the player to NULL (only if team has changed). | |
void | setTeamAndPlayer (const C3DPhy &v) |
Sets the team and the player by copying these parameters on another 3DPhy. | |
Protected Types | |
enum | EReferenceType { NO_REF, REF_GEOM, REF_GEOM_IN_SPACE, REF_ADDITIONAL_BODY } |
Different kind of objects that can bu used as a reference frame. More... | |
Protected Member Functions | |
void | markAsRemoved (Physics::Geom *pGeom) |
Enques a geom for deletion into the 3DPhyOwner. | |
void | markAsRemoved (Physics::Space *pSpace) |
Enques a space for deletion into the 3DPhyOwner. | |
void | markAsRemoved (Physics::Joint *pJoint) |
Enques a joint for deletion into the 3DPhyOwner. | |
void | markAsRemoved (Physics::Body *pAdditionalBody) |
Enques an additional body for deletion into the 3DPhyOwner. | |
void | set3DPhyOwner (C3DPhyOwner *p3DPhyOwner) |
void | clearBodyContactPos () |
"Close contact check" cleanup (removes all contact positions in each body). | |
void | attachBodies (const GeomList &vOriginalGeoms, const SpaceList &vOriginalSpaces, const BodyList &vOriginalAdditionnalBodies, Physics::Joint *pOriginalJoint, Physics::Joint *pCopyJoint) |
Subroutine for the copy constructor that attach bodies (contained in geoms or additional ones) with pCopyJoint if pOriginalJoint joins original bodies. | |
Physics::Geom * | findGeomCopy (const GeomList &vOriginalGeoms, const SpaceList &vOriginalSpaces, const Physics::Geom *pOriginalGeom) |
Subroutine for the copy constructor that returns a copied geom that correspond to the given original one. | |
Physics::Geom * | findGeomCopyInSpace (const Physics::Space &originalSpace, const Physics::Space ©Space, const Physics::Geom *pOriginalGeom) |
Subroutine for the copy constructor that returns a copied geom that correspond to the given original one into a space. | |
std::pair< const void *, EReferenceType > | getReferenceFrameObject () const |
Returns the object that will be used as a reference frame for the 3D-Phy. | |
std::pair< const void *, EReferenceType > | getReferenceFrameObjectNoThrow () const |
Returns the object that will be used as a reference frame for the 3D-Phy, without throwing if none exist. | |
virtual | ~C3DPhy () |
Protected destructor forces the object to be deleted by being dereferenced. | |
Protected Attributes | |
osg::MatrixTransform * | pModel |
Model for rendering. Points to a node of the scenegraph (owned by its parent). Model is a matrix transform in order to be bound to physics. | |
osg::MatrixTransform * | pModel_debug |
Model for rendering geoms. | |
GeomList | vGeoms |
Physical geometries (associated or not with a body). Points to geoms owned by a space. | |
SpaceList | vSpaces |
Physical spaces that can be created for that 3DPhy to be more optimized. Points to spaces owned by a space. | |
JointList | vJoints |
Physical joints that have to be destroyed with the 3DPhy. 3DPhy are thus indirectly responsible for joints destruction, by the way of their 3DPhyOwner. | |
BodyList | vAdditionalBodies |
Physical bodies that have to be destroyed with the 3DPhy. 3DPhy are thus indirectly responsible for joints destruction, by the way of their 3DPhyOwner. | |
C3DPhyOwner * | p3DPhyOwner |
Inserter / deleter that allows 3D-Phys to create objects and put them into the world. | |
double | ttl |
Remaining time to live (<0 means "infinite time"). | |
osg::ref_ptr< C3DPhyCallback > | pDeleteCB |
PVLEPlayer * | pPlayer |
PVLETeam * | pTeam |
Team or NULL (Must be concordant with player's unit, if any). | |
Friends | |
class | C3DPhyOwner |
Physics part | |
typedef std::vector < Physics::Geom * > | GeomList |
typedef std::vector < Physics::Space * > | SpaceList |
typedef std::vector < Physics::Joint * > | JointList |
typedef std::vector < Physics::Body * > | BodyList |
UINT | getNumGeoms () const |
UINT | getNumJoints () const |
UINT | getNumSpaces () const |
UINT | getNumAdditionalBodies () const |
Physics::Geom * | getGeom (UINT index) |
Physics::Joint * | getJoint (UINT index) |
Physics::Space * | getSpace (UINT index) |
Physics::Body * | getAdditionalBody (UINT index) |
const Physics::Geom * | getGeom (UINT index) const |
const Physics::Joint * | getJoint (UINT index) const |
const Physics::Space * | getSpace (UINT index) const |
const Physics::Body * | getAdditionalBody (UINT index) const |
GeomList | getGeoms () |
JointList | getJoints () |
SpaceList | getSpaces () |
BodyList | getAdditionalBodies () |
const GeomList | getGeoms () const |
const JointList | getJoints () const |
const SpaceList | getSpaces () const |
const BodyList | getAdditionalBodies () const |
void | addGeom (Physics::Geom *pGeom) |
Adds a geom, and sets the geom's collision container to be this 3DPhy (but do not overwrite if a collision container has already been set). | |
void | addSpace (Physics::Space *pSpace) |
void | addBody (Physics::Body *pBody) |
Adds a body to the 3DPhy (sometimes it can be useful to add a body without a geom). | |
void | bind (UINT numGeom) |
Binds 3D and physics (Only the given geom is used) by using a PhysicsUpdateCB. | |
void | bind () |
Like bind(0) but writes a notice in debug mode if there are more than 1 geom. | |
void | set3DtoPhy (UINT numGeom) |
Similar to bind(), it sets the model to be at the same position of the given geom but only once. | |
void | set3DtoPhy () |
Similar to bind(), it sets the model to be at the same position of the first geom but only once. | |
void | addJoint (Physics::Joint *pJoint) |
Adds a joint to the 3D-Phy (The joint will be destroyed by 3DPhyOwner at the same time geoms will be destroyed). | |
Position and orientation | |
These utility methods can be called to move the entire 3D-Phy, but only if a geom (even if inside a space) or an additional body exists in the 3DPhy. The reason for the need of a geom or body is that a reference frame is needed to perform all operations (so getPos() will return its center, and rotate() will rotate around that frame). That reference frame is simply called "the position and the orientation of the 3D-Phy". See hasReferenceFrameObject(). The only exception is for translate(), which doesn't need a reference frame.
| |
typedef std::pair< osg::Vec3, osg::Quat > | TReferenceFrame |
Reference frame type. | |
bool | hasReferenceFrameObject () const |
Tells if the 3D-Phy has a valid reference frame object; ie. if calls to getPos() are valid. | |
void | setPos (const osg::Vec3 &pos) |
void | translate (const osg::Vec3 &vec) |
osg::Vec3 | getPos () const |
Returns the center of the 3D-Phy (first geom encountered, or first additional body). | |
void | setQuaternion (const osg::Quat &quat) |
void | rotate (const osg::Quat &quat) |
osg::Quat | getQuaternion () const |
Returns the orientation of the 3D-Phy (first geom encountered, or first additional body). | |
TReferenceFrame | getReferenceFrame () const |
Convinience method that returns the reference frame for the 3D-Phy (center and orientation at the same time). | |
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. |
A 3D object (an OSG node) combined with at least one physical object (generally a geom) is called a 3D-Phy. This class holds but do not own the two parts of a 3D-Phy object (a pointer to a model and pointers to physics objects). A C3DPhyOwner can own a 3D-Phy (but not its parts), and do the job of inserting these parts into owners (a parent node and a parent space).
PVLE_3DPHY_USES_REF_PTR
is not defined, then all 3DPhys must be added to a C3DPhyOwner or else graphical and physics parts of the 3DPhy will not be deleted, and thus lead to a memory leak.// Assuming p3DPhy is a C3DPhy* // Inserting a 3D-Phy manually ... pParentGroup->addChild(p3DPhy->getModel()); for(UINT i=0; i<p3DPhy->getNumGeoms(); ++i) pParentSpace->add(p3DPhy->getGeom(i)); // Here we could use BOOST_FOREACH() for readability. for(UINT i=0; i<p3DPhy->getNumSpaces(); ++i) pParentSpace->add(p3DPhy->getSpace(i)); // ... or simply using convinience methods ... pParentGroup->addChild(*p3DPhy); pParentSpace->add(*p3DPhy); // ... but the best way to do it is to use a C3DPhyOwner in which you simply add the 3D-PHy object by calling C3DPhyOwner::addInScene(). // Assuming p3DPhyOwner is a C3DPhyOwner* p3DPhyOwner->addInScene(p3DPhy);
Definition at line 122 of file 3DPhy.h.
typedef std::vector<Physics::Body *> C3DPhy::BodyList |
typedef std::vector<Physics::Geom *> C3DPhy::GeomList |
typedef std::vector<Physics::Joint *> C3DPhy::JointList |
typedef std::vector<Physics::Space *> C3DPhy::SpaceList |
typedef std::pair<osg::Vec3, osg::Quat> C3DPhy::TReferenceFrame |
enum C3DPhy::ECopyOptions |
enum C3DPhy::EInitOptions |
enum C3DPhy::EReferenceType [protected] |
C3DPhy::C3DPhy | ( | const C3DPhy * | pInheritTeamAndPlayer = NULL |
) |
Creates an empty 3DPhy, without an owner.
Definition at line 237 of file 3DPhy.cpp.
References setTeamAndPlayer().
C3DPhy::C3DPhy | ( | osg::MatrixTransform * | pModel, | |
Physics::Geom * | pGeom, | |||
EInitOptions | options = INIT_NONE , |
|||
const C3DPhy * | pInheritTeamAndPlayer = NULL | |||
) |
Creates a complete 3DPhy with only one geom, without an owner. If parameter options
is INIT_AUTO_BIND
, then the method bind() will be called ; and if equal to INIT_BIND_ONCE, then the method set3DtoPhy() will be called. Note it will call setGeom(), so pGeom's collision container can be modified.
Definition at line 248 of file 3DPhy.cpp.
References addGeom(), bind(), INIT_AUTO_BIND, INIT_BIND_ONCE, set3DtoPhy(), and setTeamAndPlayer().
Copies a 3DPhy.
Definition at line 263 of file 3DPhy.cpp.
References C3DPhyOwner::addInScene(), ASSERT, attachBodies(), COPY_3D, Physics::AbstractGeom::COPY_ALL, COPY_OWNER, COPY_PHYSICS, COPY_TTL, findGeomCopy(), PhysicsUpdateCB::getGeom(), CollectNodesVisitor::nodes, p3DPhyOwner, pModel, pModel_debug, setTeamAndPlayer(), ttl, vAdditionalBodies, vGeoms, vJoints, and vSpaces.
virtual C3DPhy::~C3DPhy | ( | ) | [inline, protected, virtual] |
Protected destructor forces the object to be deleted by being dereferenced.
Also avoids the object from beeing created on the stack.
Definition at line 455 of file 3DPhy.h.
References THROW_TRACED_EXCEPTION.
void C3DPhy::accept | ( | Physics::Visitor & | v | ) |
Definition at line 693 of file 3DPhy.cpp.
References Physics::Joint::accept(), Physics::Body::accept(), Physics::Space::accept(), Physics::Geom::accept(), vAdditionalBodies, vGeoms, vJoints, and vSpaces.
void C3DPhy::addBody | ( | Physics::Body * | pBody | ) |
Adds a body to the 3DPhy (sometimes it can be useful to add a body without a geom).
Definition at line 545 of file 3DPhy.cpp.
References ASSERT, and vAdditionalBodies.
void C3DPhy::addGeom | ( | Physics::Geom * | pGeom | ) |
Adds a geom, and sets the geom's collision container to be this 3DPhy (but do not overwrite if a collision container has already been set).
Definition at line 524 of file 3DPhy.cpp.
References ASSERT, Physics::Geom::getCollisionContainer(), LOG_WARN, Physics::Geom::setCollisionContainer(), and vGeoms.
Referenced by C3DPhy(), and Explosion::init().
void C3DPhy::addJoint | ( | Physics::Joint * | pJoint | ) | [inline] |
void C3DPhy::addSpace | ( | Physics::Space * | pSpace | ) |
virtual C3DPhy* C3DPhy::as3DPhy | ( | ) | [inline, virtual] |
void C3DPhy::attachBodies | ( | const GeomList & | vOriginalGeoms, | |
const SpaceList & | vOriginalSpaces, | |||
const BodyList & | vOriginalAdditionnalBodies, | |||
Physics::Joint * | pOriginalJoint, | |||
Physics::Joint * | pCopyJoint | |||
) | [protected] |
Subroutine for the copy constructor that attach bodies (contained in geoms or additional ones) with pCopyJoint if pOriginalJoint joins original bodies.
Definition at line 454 of file 3DPhy.cpp.
References Physics::Joint::attach(), Physics::combinedTraversal(), Physics::Joint::copyParameters(), Physics::Joint::getBody1(), Physics::Joint::getBody2(), LOG_INFO, vAdditionalBodies, vGeoms, and vSpaces.
Referenced by C3DPhy().
void C3DPhy::bind | ( | ) |
Like bind(0) but writes a notice in debug mode if there are more than 1 geom.
Definition at line 547 of file 3DPhy.cpp.
References LOG_NOTICE, and vGeoms.
Referenced by C3DPhy(), and Explosion::init().
void C3DPhy::bind | ( | UINT | numGeom | ) |
Binds 3D and physics (Only the given geom is used) by using a PhysicsUpdateCB.
Don't bind twice ! :) (performance will suffer of it).
virtual const char* C3DPhy::className | ( | ) | const [inline, virtual] |
void C3DPhy::clearBodyContactPos | ( | ) | [protected] |
"Close contact check" cleanup (removes all contact positions in each body).
Definition at line 684 of file 3DPhy.cpp.
References Physics::Body::contactPos, Physics::Geom::getBody(), and vGeoms.
Referenced by C3DPhyOwner::clearBodyContactPos().
void C3DPhy::createPhysicsDebugView | ( | bool | enable | ) |
Adds (or removes) 3D debug shapes that represent geoms, but only if REMOVE_DEV_FEATURES
is not defined (this method does nothing otherwise).
This method induces an important slowdown because it uses alpha geometries (which are time-consuming) and should only be enabled for non-production applications.
Definition at line 607 of file 3DPhy.cpp.
References Physics::GeometryHandler::addOrSetChangeCallback(), ASSERT, Physics::GeometryHandler::BOX, Physics::GeometryHandler::CAPSULE, createShapeGeodeBox(), createShapeGeodeCapsule(), createShapeGeodeCylinder(), createShapeGeodeSphere(), Physics::GeometryHandler::CYLINDER, Physics::Geom::getHandler(), C3DPhyOwner::getParentGroup(), Physics::GeometryHandler::MESH, p3DPhyOwner, pModel_debug, Physics::GeometryHandler::RAY, Physics::GeometryHandler::SPHERE, Physics::GeometryHandler::type(), and vGeoms.
Referenced by C3DPhyOwner::createPhysicsDebugView().
Physics::Geom * C3DPhy::findGeomCopy | ( | const GeomList & | vOriginalGeoms, | |
const SpaceList & | vOriginalSpaces, | |||
const Physics::Geom * | pOriginalGeom | |||
) | [protected] |
Subroutine for the copy constructor that returns a copied geom that correspond to the given original one.
Definition at line 508 of file 3DPhy.cpp.
References Physics::combinedTraversal(), FindGeomCopy::pCopyGeom, vGeoms, and vSpaces.
Referenced by C3DPhy().
Physics::Geom* C3DPhy::findGeomCopyInSpace | ( | const Physics::Space & | originalSpace, | |
const Physics::Space & | copySpace, | |||
const Physics::Geom * | pOriginalGeom | |||
) | [protected] |
Subroutine for the copy constructor that returns a copied geom that correspond to the given original one into a space.
const C3DPhyOwner* C3DPhy::get3DPhyOwner | ( | ) | const [inline] |
C3DPhyOwner* C3DPhy::get3DPhyOwner | ( | ) | [inline] |
Gets its owner (owner is set when the 3D-Phy is added to / detatched from an owner).
Definition at line 281 of file 3DPhy.h.
Referenced by C3DPhyOwner::addInScene().
const BodyList C3DPhy::getAdditionalBodies | ( | ) | const [inline] |
const Physics::Body* C3DPhy::getAdditionalBody | ( | UINT | index | ) | const [inline] |
Physics::Body* C3DPhy::getAdditionalBody | ( | UINT | index | ) | [inline] |
const C3DPhyCallback* C3DPhy::getDeleteCallback | ( | ) | const [inline] |
C3DPhyCallback* C3DPhy::getDeleteCallback | ( | ) | [inline] |
const Physics::Geom* C3DPhy::getGeom | ( | UINT | index | ) | const [inline] |
Physics::Geom* C3DPhy::getGeom | ( | UINT | index | ) | [inline] |
GeomList C3DPhy::getGeoms | ( | ) | [inline] |
Definition at line 196 of file 3DPhy.h.
Referenced by Physics::Space::add(), and Physics::Space::remove().
const Physics::Joint* C3DPhy::getJoint | ( | UINT | index | ) | const [inline] |
Physics::Joint* C3DPhy::getJoint | ( | UINT | index | ) | [inline] |
osg::Matrix C3DPhy::getMatrix | ( | ) | const [inline] |
Convinience method for getting position and rotation at once.
Definition at line 359 of file 3DPhy.h.
Referenced by set3DtoPhy().
const osg::MatrixTransform* C3DPhy::getModel | ( | ) | const [inline] |
osg::MatrixTransform* C3DPhy::getModel | ( | ) | [inline] |
Definition at line 159 of file 3DPhy.h.
Referenced by C3DPhyOwner::doDelayed3DPhy(), and C3DPhyOwner::doNetworkClientRemove3DPhy().
const PVLEPlayer* C3DPhy::getPlayer | ( | ) | const [inline] |
Const version of getPlayer().
Player (human or IA) that has the 3D-Phy (unit, building...), or NULL.
PVLEPlayer* C3DPhy::getPlayer | ( | ) | [inline] |
osg::Vec3 C3DPhy::getPos | ( | ) | const [inline] |
Returns the center of the 3D-Phy (first geom encountered, or first additional body).
Definition at line 332 of file 3DPhy.h.
References Physics::dBodyGetPositionV(), and dGeomGetPositionV().
Referenced by rotate().
osg::Quat C3DPhy::getQuaternion | ( | ) | const [inline] |
Returns the orientation of the 3D-Phy (first geom encountered, or first additional body).
Definition at line 341 of file 3DPhy.h.
References Physics::dBodyGetQuaternionV(), and dGeomGetQuaternionV().
TReferenceFrame C3DPhy::getReferenceFrame | ( | ) | const [inline] |
Convinience method that returns the reference frame for the 3D-Phy (center and orientation at the same time).
Definition at line 350 of file 3DPhy.h.
References Physics::dBodyGetPositionV(), Physics::dBodyGetQuaternionV(), dGeomGetPositionV(), and dGeomGetQuaternionV().
std::pair< const void *, C3DPhy::EReferenceType > C3DPhy::getReferenceFrameObject | ( | ) | const [protected] |
Returns the object that will be used as a reference frame for the 3D-Phy.
Definition at line 775 of file 3DPhy.cpp.
References getReferenceFrameObjectNoThrow(), NO_REF, and THROW_TRACED_EXCEPTION.
std::pair< const void *, C3DPhy::EReferenceType > C3DPhy::getReferenceFrameObjectNoThrow | ( | ) | const [protected] |
Returns the object that will be used as a reference frame for the 3D-Phy, without throwing if none exist.
Definition at line 784 of file 3DPhy.cpp.
References Physics::Space::accept(), NO_REF, REF_ADDITIONAL_BODY, REF_GEOM, REF_GEOM_IN_SPACE, FindVisitor::result, vAdditionalBodies, vGeoms, and vSpaces.
Referenced by getReferenceFrameObject().
const Physics::Space* C3DPhy::getSpace | ( | UINT | index | ) | const [inline] |
Physics::Space* C3DPhy::getSpace | ( | UINT | index | ) | [inline] |
SpaceList C3DPhy::getSpaces | ( | ) | [inline] |
Definition at line 198 of file 3DPhy.h.
Referenced by Physics::Space::add(), and Physics::Space::remove().
const PVLETeam* C3DPhy::getTeam | ( | ) | const [inline] |
PVLETeam* C3DPhy::getTeam | ( | ) | [inline] |
Team that has the 3D-Phy (unit, building...), or NULL.
Definition at line 309 of file 3DPhy.h.
Referenced by Ammo::hitAfter(), Explosion::hitBefore(), and setTeamAndPlayer().
virtual EContainerType C3DPhy::getType | ( | ) | const [inline, virtual] |
Gets the type of the current container.
Implements IGeomCollisionContainer.
bool C3DPhy::hasReferenceFrameObject | ( | ) | const [inline] |
void C3DPhy::hitAfter | ( | Physics::Contact * | pContacts, | |
unsigned int | nbContacts, | |||
Physics::Contact * | pMaxEnergyContact, | |||
Physics::Geom & | thisGeom, | |||
Physics::Geom & | otherGeom, | |||
bool | contactJointCreated | |||
) | [virtual] |
Applies cinetic collision. Can be overloaded so that it takes into account armour parameters (ie. for units).
Reimplemented from IGeomCollisionContainer.
Reimplemented in Ammo.
Definition at line 572 of file 3DPhy.cpp.
References Physics::Contact::arithmeticCineticEnergy, Physics::Contact::getPos(), and isHitByCinetic().
virtual bool C3DPhy::hitBefore | ( | Physics::Contact * | pContacts, | |
unsigned int | nbContacts, | |||
Physics::Contact * | pMaxEnergyContact, | |||
Physics::Geom & | thisGeom, | |||
Physics::Geom & | otherGeom, | |||
Physics::Body *& | inout_pThisBody, | |||
Physics::Body *& | inout_pOtherBody | |||
) | [inline, virtual] |
Default behaviour on hit is to do nothing.
Implements IGeomCollisionContainer.
Reimplemented in Ammo, Explosion, and Dummy3DPhy.
void C3DPhy::isHitBy | ( | WeaponEnergy::EEneryType | type, | |
double | energy, | |||
const osg::Vec3 & | point | |||
) | [inline] |
This method is a helper that handles an energy transfer towards this 3DPhy when you don't know the energy type at compile time.
So if you wish to transfer, for instance, thermal energy to it (and if you know it at compile time), you should call isHitByThermal() instead.
Definition at line 245 of file 3DPhy.h.
References WeaponEnergy::CHEMICAL, WeaponEnergy::CINETIC, WeaponEnergy::PERFORANT, WeaponEnergy::RADIANT, WeaponEnergy::THERMAL, and THROW_TRACED_EXCEPTION.
Referenced by Ammo::hitAfter(), and Explosion::hitBefore().
virtual void C3DPhy::isHitByChemical | ( | double | energy, | |
const osg::Vec3 & | point | |||
) | [inline, virtual] |
virtual void C3DPhy::isHitByCinetic | ( | double | energy, | |
const osg::Vec3 & | point | |||
) | [inline, virtual] |
This method differs from others isHitBy* because it is not only about a weapon, but also for simple collisions.
Definition at line 271 of file 3DPhy.h.
Referenced by hitAfter().
virtual void C3DPhy::isHitByPerforant | ( | double | energy, | |
const osg::Vec3 & | point | |||
) | [inline, virtual] |
virtual void C3DPhy::isHitByRadiant | ( | double | energy, | |
const osg::Vec3 & | point | |||
) | [inline, virtual] |
virtual void C3DPhy::isHitByThermal | ( | double | energy, | |
const osg::Vec3 & | point | |||
) | [inline, virtual] |
void C3DPhy::markAsRemoved | ( | Physics::Body * | pAdditionalBody | ) | [protected] |
Enques an additional body for deletion into the 3DPhyOwner.
Definition at line 806 of file 3DPhy.cpp.
References ASSERT, C3DPhyOwner::markAsRemoved(), and p3DPhyOwner.
void C3DPhy::markAsRemoved | ( | Physics::Joint * | pJoint | ) | [protected] |
Enques a joint for deletion into the 3DPhyOwner.
Definition at line 805 of file 3DPhy.cpp.
References ASSERT, C3DPhyOwner::markAsRemoved(), and p3DPhyOwner.
void C3DPhy::markAsRemoved | ( | Physics::Space * | pSpace | ) | [protected] |
Enques a space for deletion into the 3DPhyOwner.
Definition at line 804 of file 3DPhy.cpp.
References ASSERT, C3DPhyOwner::markAsRemoved(), and p3DPhyOwner.
void C3DPhy::markAsRemoved | ( | Physics::Geom * | pGeom | ) | [protected] |
Enques a geom for deletion into the 3DPhyOwner.
Definition at line 803 of file 3DPhy.cpp.
References ASSERT, C3DPhyOwner::markAsRemoved(), and p3DPhyOwner.
void C3DPhy::markAsRemoved | ( | ) |
Self-destruct method: tells the owner of this 3DPhy to mark it as removed.
The 3DPhy isn't deleted immediately.
Definition at line 802 of file 3DPhy.cpp.
References ASSERT, C3DPhyOwner::markAsRemoved(), and p3DPhyOwner.
void C3DPhy::onTTLZero | ( | ) | [virtual] |
Handles the event "TTL has expired". Defaults is to destroy istelf if the 3D-Phy has an owner (does nothing otherwise).
Definition at line 584 of file 3DPhy.cpp.
References C3DPhyOwner::markAsRemoved(), p3DPhyOwner, and pDeleteCB.
Referenced by Ammo::hitAfter(), Explosion::step(), Ammo::step(), and Dummy3DPhy::step().
C3DPhy::operator const osg::MatrixTransform * | ( | ) | const [inline] |
C3DPhy::operator osg::MatrixTransform * | ( | ) | [inline] |
void C3DPhy::rotate | ( | const osg::Quat & | quat | ) |
Definition at line 746 of file 3DPhy.cpp.
References Physics::Space::accept(), getPos(), Physics::Body::rotate(), Physics::Geom::rotate(), vAdditionalBodies, vGeoms, and vSpaces.
void C3DPhy::set3DPhyOwner | ( | C3DPhyOwner * | p3DPhyOwner | ) | [inline, protected] |
Definition at line 417 of file 3DPhy.h.
Referenced by C3DPhyOwner::addInScene(), C3DPhyOwner::detatch(), and C3DPhyOwner::detatch_nodelete().
void C3DPhy::set3DtoPhy | ( | ) |
Similar to bind(), it sets the model to be at the same position of the first geom but only once.
Can be called any number of times, contrary to bind().
Definition at line 559 of file 3DPhy.cpp.
References LOG_NOTICE, and vGeoms.
Referenced by C3DPhy().
void C3DPhy::set3DtoPhy | ( | UINT | numGeom | ) |
Similar to bind(), it sets the model to be at the same position of the given geom but only once.
Can be called any number of times, contrary to bind().
Definition at line 566 of file 3DPhy.cpp.
References ASSERT, getMatrix(), pModel, and vGeoms.
void C3DPhy::setDeleteCallback | ( | C3DPhyCallback * | pCB | ) | [inline] |
void C3DPhy::setMatrix | ( | const osg::Matrix & | matrix | ) | [inline] |
void C3DPhy::setModel | ( | osg::MatrixTransform * | pModel | ) | [inline] |
void C3DPhy::setPlayer | ( | PVLEPlayer * | pPlayer | ) |
Sets the player (and the 3DPhy's team becomes the player's team, to stay consistent).
Definition at line 590 of file 3DPhy.cpp.
References PVLEPlayer::getTeam(), and pTeam.
void C3DPhy::setQuaternion | ( | const osg::Quat & | quat | ) | [inline] |
void C3DPhy::setTeam | ( | PVLETeam * | pTeam | ) |
void C3DPhy::setTeamAndPlayer | ( | const C3DPhy & | v | ) |
void C3DPhy::setTTL | ( | double | ttl | ) | [inline] |
virtual void C3DPhy::step | ( | dReal | stepSize | ) | [inline, virtual] |
Steps the 3D-Phy. Default is to do nothing but decreasing the TTL and call the onTTLZero() method if necessary.
Reimplemented in Ammo, Explosion, and Dummy3DPhy.
Definition at line 231 of file 3DPhy.h.
Referenced by C3DPhyOwner::step().
void C3DPhy::translate | ( | const osg::Vec3 & | vec | ) |
Definition at line 718 of file 3DPhy.cpp.
References Physics::Space::accept(), Physics::Joint::translate(), Physics::Body::translate(), Physics::Geom::translate(), vAdditionalBodies, vGeoms, vJoints, and vSpaces.
friend class C3DPhyOwner [friend] |
C3DPhyOwner* C3DPhy::p3DPhyOwner [protected] |
Inserter / deleter that allows 3D-Phys to create objects and put them into the world.
Definition at line 416 of file 3DPhy.h.
Referenced by C3DPhy(), createPhysicsDebugView(), C3DPhyOwner::exists(), Ammo::hitBefore(), markAsRemoved(), and onTTLZero().
osg::ref_ptr<C3DPhyCallback> C3DPhy::pDeleteCB [protected] |
osg::MatrixTransform* C3DPhy::pModel [protected] |
Model for rendering. Points to a node of the scenegraph (owned by its parent). Model is a matrix transform in order to be bound to physics.
Definition at line 390 of file 3DPhy.h.
Referenced by bind(), C3DPhy(), Explosion::createLight(), Explosion::init(), operator const osg::MatrixTransform *(), operator osg::MatrixTransform *(), and set3DtoPhy().
osg::MatrixTransform* C3DPhy::pModel_debug [protected] |
Model for rendering geoms.
Definition at line 397 of file 3DPhy.h.
Referenced by C3DPhy(), createPhysicsDebugView(), C3DPhyOwner::doDelayed3DPhy(), and C3DPhyOwner::doNetworkClientRemove3DPhy().
PVLEPlayer* C3DPhy::pPlayer [protected] |
PVLETeam* C3DPhy::pTeam [protected] |
Team or NULL (Must be concordant with player's unit, if any).
Definition at line 425 of file 3DPhy.h.
Referenced by Ammo::hitAfter(), Explosion::hitBefore(), setPlayer(), and setTeamAndPlayer().
double C3DPhy::ttl [protected] |
Remaining time to live (<0 means "infinite time").
Definition at line 420 of file 3DPhy.h.
Referenced by C3DPhy(), and Ammo::step().
BodyList C3DPhy::vAdditionalBodies [protected] |
Physical bodies that have to be destroyed with the 3DPhy. 3DPhy are thus indirectly responsible for joints destruction, by the way of their 3DPhyOwner.
Definition at line 404 of file 3DPhy.h.
Referenced by accept(), addBody(), attachBodies(), C3DPhy(), C3DPhyOwner::doDelayed3DPhy(), C3DPhyOwner::doNetworkClientRemove3DPhy(), getReferenceFrameObjectNoThrow(), C3DPhyOwner::markAsRemoved(), rotate(), and translate().
GeomList C3DPhy::vGeoms [protected] |
Physical geometries (associated or not with a body). Points to geoms owned by a space.
Definition at line 401 of file 3DPhy.h.
Referenced by accept(), addGeom(), attachBodies(), bind(), C3DPhy(), clearBodyContactPos(), createPhysicsDebugView(), C3DPhyOwner::doDelayed3DPhy(), C3DPhyOwner::doNetworkClientRemove3DPhy(), findGeomCopy(), getReferenceFrameObjectNoThrow(), Explosion::hitBefore(), Ammo::hitBefore(), C3DPhyOwner::markAsRemoved(), rotate(), set3DtoPhy(), Explosion::step(), Ammo::step(), and translate().
JointList C3DPhy::vJoints [protected] |
Physical joints that have to be destroyed with the 3DPhy. 3DPhy are thus indirectly responsible for joints destruction, by the way of their 3DPhyOwner.
Definition at line 403 of file 3DPhy.h.
Referenced by accept(), C3DPhy(), C3DPhyOwner::doDelayed3DPhy(), C3DPhyOwner::doNetworkClientRemove3DPhy(), C3DPhyOwner::markAsRemoved(), and translate().
SpaceList C3DPhy::vSpaces [protected] |
Physical spaces that can be created for that 3DPhy to be more optimized. Points to spaces owned by a space.
Definition at line 402 of file 3DPhy.h.
Referenced by accept(), addSpace(), attachBodies(), C3DPhy(), C3DPhyOwner::doDelayed3DPhy(), C3DPhyOwner::doNetworkClientRemove3DPhy(), findGeomCopy(), getReferenceFrameObjectNoThrow(), C3DPhyOwner::markAsRemoved(), rotate(), and translate().