C3DPhy Class Reference

A 3D-Phy (or entity) is an object wich has physical and graphical properties. More...

#include <3DPhy.h>

Inheritance diagram for C3DPhy:

Inheritance graph
[legend]

List of all members.

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 C3DPhyas3DPhy ()
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.
C3DPhyOwnerget3DPhyOwner ()
 Gets its owner (owner is set when the 3D-Phy is added to / detatched from an owner).
const C3DPhyOwnerget3DPhyOwner () 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)
C3DPhyCallbackgetDeleteCallback ()
const C3DPhyCallbackgetDeleteCallback () const
Gameplay
PVLEPlayergetPlayer ()
 Player (human or IA) that has the 3D-Phy (unit, building...), or NULL.
const PVLEPlayergetPlayer () 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).
PVLETeamgetTeam ()
 Team that has the 3D-Phy (unit, building...), or NULL.
const PVLETeamgetTeam () 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::GeomfindGeomCopy (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::GeomfindGeomCopyInSpace (const Physics::Space &originalSpace, const Physics::Space &copySpace, 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.
C3DPhyOwnerp3DPhyOwner
 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< C3DPhyCallbackpDeleteCB
PVLEPlayerpPlayer
PVLETeampTeam
 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::GeomgetGeom (UINT index)
Physics::JointgetJoint (UINT index)
Physics::SpacegetSpace (UINT index)
Physics::BodygetAdditionalBody (UINT index)
const Physics::GeomgetGeom (UINT index) const
const Physics::JointgetJoint (UINT index) const
const Physics::SpacegetSpace (UINT index) const
const Physics::BodygetAdditionalBody (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.

Warning:
Until now, these methods only move physics classes. Unbound 3D models will thus not be affected.
Todo:
Move unbound models. Idea (is it ok ?): Simply affect the root MatrixTransform (bound or not, since the binding will overwrite the matrix) - All children will be moved... theorically.


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.


Detailed Description

A 3D-Phy (or entity) is an object wich has physical and graphical properties.

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).

Warning:
if 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.
Inserting a 3D-Phy
A C3DPhy class (or derivate) can be added to the scene graph and into a physical space in several ways :
    // 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);
Networking
C3DPhy class is a NetObject because derivate classes may potentially be created by the network system. A 3DPhy is not supposed to be created directly.
Author:
Sukender
Version:
0.2.0 - Support for "lonely" bodies (= bodies that are not in a geom), and spaces in hierarchy.

Definition at line 122 of file 3DPhy.h.


Member Typedef Documentation

typedef std::vector<Physics::Body *> C3DPhy::BodyList

Definition at line 179 of file 3DPhy.h.

typedef std::vector<Physics::Geom *> C3DPhy::GeomList

Definition at line 176 of file 3DPhy.h.

typedef std::vector<Physics::Joint *> C3DPhy::JointList

Definition at line 178 of file 3DPhy.h.

typedef std::vector<Physics::Space *> C3DPhy::SpaceList

Definition at line 177 of file 3DPhy.h.

typedef std::pair<osg::Vec3, osg::Quat> C3DPhy::TReferenceFrame

Reference frame type.

Definition at line 348 of file 3DPhy.h.


Member Enumeration Documentation

Enumerator:
COPY_3D  Copy the 3D part of the 3DPhy.
COPY_PHYSICS  Copy the physics part of the 3DPhy.
COPY_OWNER  Inserts the new 3DPhy into the same 3DPhyOwner (Prefer insert yourself the 3DPhy in the owner if possible... that's cleaner because you explicitly add in scene the 3DPhy).
COPY_TTL  Copy the "time to live" that still have the original 3DPhy.
COPY_DEFAULT  Default copy. Do not copy anything but the 3DPhy itself (Geoms, model, joints...).
COPY_ALL 

Definition at line 133 of file 3DPhy.h.

Enumerator:
INIT_NONE  Do nothing on initialisation.
INIT_BIND_ONCE  Position 3D to physics position on initialisation.
INIT_AUTO_BIND  Enable auto-bind on initialisation.

Definition at line 127 of file 3DPhy.h.

enum C3DPhy::EReferenceType [protected]

Different kind of objects that can bu used as a reference frame.

Enumerator:
NO_REF 
REF_GEOM 
REF_GEOM_IN_SPACE 
REF_ADDITIONAL_BODY 

Definition at line 437 of file 3DPhy.h.


Constructor & Destructor Documentation

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().

C3DPhy::C3DPhy ( const C3DPhy v,
UINT  copyOpts = COPY_DEFAULT 
)

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.


Member Function Documentation

void C3DPhy::accept ( Physics::Visitor v  ) 

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]

Adds a joint to the 3D-Phy (The joint will be destroyed by 3DPhyOwner at the same time geoms will be destroyed).

Definition at line 225 of file 3DPhy.h.

References ASSERT.

void C3DPhy::addSpace ( Physics::Space pSpace  ) 

Definition at line 535 of file 3DPhy.cpp.

References ASSERT, Physics::AbstractGeom::getParentSpace(), LOG_WARN, and vSpaces.

virtual C3DPhy* C3DPhy::as3DPhy (  )  [inline, virtual]

Reimplemented from IGeomCollisionContainer.

Definition at line 155 of file 3DPhy.h.

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.

See also:
bind(UINT), set3DtoPhy(), set3DtoPhy(UINT)

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).

See also:
bind(), set3DtoPhy(), set3DtoPhy(UINT)

Definition at line 554 of file 3DPhy.cpp.

References ASSERT, pModel, and vGeoms.

virtual const char* C3DPhy::className (  )  const [inline, virtual]

Implements IGeomCollisionContainer.

Definition at line 153 of file 3DPhy.h.

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).

Warning:
Can only be called after the 3DPhyOwner has been set (crashes otherwise, because it cannot create the 3D geometries).

This method induces an important slowdown because it uses alpha geometries (which are time-consuming) and should only be enabled for non-production applications.

Todo:
Allow something to delay the creation on the next frame if the 3DPhyOwner is not assigned yet (in constructors).

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]

Definition at line 282 of file 3DPhy.h.

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]

Definition at line 203 of file 3DPhy.h.

BodyList C3DPhy::getAdditionalBodies (  )  [inline]

Definition at line 199 of file 3DPhy.h.

const Physics::Body* C3DPhy::getAdditionalBody ( UINT  index  )  const [inline]

Definition at line 194 of file 3DPhy.h.

Physics::Body* C3DPhy::getAdditionalBody ( UINT  index  )  [inline]

Definition at line 190 of file 3DPhy.h.

const C3DPhyCallback* C3DPhy::getDeleteCallback (  )  const [inline]

Definition at line 299 of file 3DPhy.h.

C3DPhyCallback* C3DPhy::getDeleteCallback (  )  [inline]

Definition at line 298 of file 3DPhy.h.

const Physics::Geom* C3DPhy::getGeom ( UINT  index  )  const [inline]

Definition at line 191 of file 3DPhy.h.

Physics::Geom* C3DPhy::getGeom ( UINT  index  )  [inline]

Definition at line 187 of file 3DPhy.h.

Referenced by Ammo::hitBefore().

const GeomList C3DPhy::getGeoms (  )  const [inline]

Definition at line 200 of file 3DPhy.h.

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]

Definition at line 192 of file 3DPhy.h.

Physics::Joint* C3DPhy::getJoint ( UINT  index  )  [inline]

Definition at line 188 of file 3DPhy.h.

const JointList C3DPhy::getJoints (  )  const [inline]

Definition at line 201 of file 3DPhy.h.

JointList C3DPhy::getJoints (  )  [inline]

Definition at line 197 of file 3DPhy.h.

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]

Definition at line 161 of file 3DPhy.h.

osg::MatrixTransform* C3DPhy::getModel (  )  [inline]

UINT C3DPhy::getNumAdditionalBodies (  )  const [inline]

Definition at line 185 of file 3DPhy.h.

UINT C3DPhy::getNumGeoms (  )  const [inline]

Definition at line 182 of file 3DPhy.h.

UINT C3DPhy::getNumJoints (  )  const [inline]

Definition at line 183 of file 3DPhy.h.

UINT C3DPhy::getNumSpaces (  )  const [inline]

Definition at line 184 of file 3DPhy.h.

const PVLEPlayer* C3DPhy::getPlayer (  )  const [inline]

Const version of getPlayer().

Player (human or IA) that has the 3D-Phy (unit, building...), or NULL.

Definition at line 306 of file 3DPhy.h.

PVLEPlayer* C3DPhy::getPlayer (  )  [inline]

Player (human or IA) that has the 3D-Phy (unit, building...), or NULL.

Definition at line 305 of file 3DPhy.h.

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]

Definition at line 193 of file 3DPhy.h.

Physics::Space* C3DPhy::getSpace ( UINT  index  )  [inline]

Definition at line 189 of file 3DPhy.h.

const SpaceList C3DPhy::getSpaces (  )  const [inline]

Definition at line 202 of file 3DPhy.h.

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]

Const version of getTeam().

Team that has the 3D-Phy (unit, building...), or NULL.

Definition at line 310 of file 3DPhy.h.

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().

double C3DPhy::getTTL (  )  [inline]

Gets the remaining TTL.

Definition at line 290 of file 3DPhy.h.

virtual EContainerType C3DPhy::getType (  )  const [inline, virtual]

Gets the type of the current container.

Implements IGeomCollisionContainer.

Reimplemented in Ammo, and Explosion.

Definition at line 154 of file 3DPhy.h.

bool C3DPhy::hasReferenceFrameObject (  )  const [inline]

Tells if the 3D-Phy has a valid reference frame object; ie. if calls to getPos() are valid.

Definition at line 327 of file 3DPhy.h.

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.

Definition at line 237 of file 3DPhy.h.

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.

See also:
isHitByRadiant()

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]

Definition at line 268 of file 3DPhy.h.

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]

Definition at line 266 of file 3DPhy.h.

virtual void C3DPhy::isHitByRadiant ( double  energy,
const osg::Vec3 &  point 
) [inline, virtual]

Energy transfer towards this 3DPhy.

Default is to do nothing (completely loose energy).

Parameters:
energy Transferred energy
point Point of application, in world coordinates.

Definition at line 265 of file 3DPhy.h.

virtual void C3DPhy::isHitByThermal ( double  energy,
const osg::Vec3 &  point 
) [inline, virtual]

Definition at line 267 of file 3DPhy.h.

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.

Warning:
Cannot be called if the 3DPhy hasn't got an owner, of course.

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]

Definition at line 162 of file 3DPhy.h.

References pModel.

C3DPhy::operator osg::MatrixTransform * (  )  [inline]

Definition at line 160 of file 3DPhy.h.

References pModel.

void C3DPhy::rotate ( const osg::Quat &  quat  ) 

void C3DPhy::set3DPhyOwner ( C3DPhyOwner p3DPhyOwner  )  [inline, protected]

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().

See also:
bind(), bind(UINT), set3DtoPhy(UINT)

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().

See also:
bind(), bind(UINT), set3DtoPhy()

Definition at line 566 of file 3DPhy.cpp.

References ASSERT, getMatrix(), pModel, and vGeoms.

void C3DPhy::setDeleteCallback ( C3DPhyCallback pCB  )  [inline]

Definition at line 297 of file 3DPhy.h.

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

Convinience method for setting position and rotation at once.

Definition at line 357 of file 3DPhy.h.

void C3DPhy::setModel ( osg::MatrixTransform *  pModel  )  [inline]

Definition at line 164 of file 3DPhy.h.

Referenced by Explosion::init().

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::setPos ( const osg::Vec3 &  pos  )  [inline]

Definition at line 329 of file 3DPhy.h.

void C3DPhy::setQuaternion ( const osg::Quat &  quat  )  [inline]

Definition at line 338 of file 3DPhy.h.

References ASSERT.

void C3DPhy::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).

Definition at line 595 of file 3DPhy.cpp.

References pPlayer.

void C3DPhy::setTeamAndPlayer ( const C3DPhy v  ) 

Sets the team and the player by copying these parameters on another 3DPhy.

Definition at line 601 of file 3DPhy.cpp.

References ASSERT, getTeam(), PVLEPlayer::getTeam(), pPlayer, and pTeam.

Referenced by C3DPhy().

void C3DPhy::setTTL ( double  ttl  )  [inline]

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 !

Definition at line 288 of file 3DPhy.h.

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  ) 


Friends And Related Function Documentation

friend class C3DPhyOwner [friend]

Definition at line 415 of file 3DPhy.h.


Member Data Documentation

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]

Definition at line 422 of file 3DPhy.h.

Referenced by onTTLZero().

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().

Definition at line 424 of file 3DPhy.h.

Referenced by setTeam(), and setTeamAndPlayer().

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().

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 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().

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().


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

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