Ammo Class Reference

Ammunition class ; for all 3D-Phy that carries energy other than cinetic, and that moves too fast for the simulation to compute as usual. More...

#include <Ammo.h>

Inheritance diagram for Ammo:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 Ammo (osg::MatrixTransform *pModel, Physics::Geom *pGeom, C3DPhy::EInitOptions options, const C3DPhy *pInheritTeamAndPlayer=NULL)
 Ammo (const C3DPhy &v, UINT copyOpts=COPY_3D|COPY_PHYSICS|COPY_OWNER)
 Ammo (const Ammo &v, UINT copyOpts=COPY_3D|COPY_PHYSICS|COPY_OWNER)
virtual EContainerType getType () const
 Gets the type of the current container.
virtual AmmoasAmmo ()
virtual void step (dReal stepSize)
 Steps the ammo (tests TTL as base class, and minimal speed).
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)
 Do all the computation to transfer energies (see setParam()) to the hit geom - also handles perforation.
virtual void hitAfter (Physics::Contact *pContacts, unsigned int nbContacts, Physics::Contact *pMaxEnergyContact, Physics::Geom &thisGeom, Physics::Geom &otherGeom, bool contactJointCreated)
 Effectively destroys the ammo if hitBefore() decided to AND if a contact joint has been created.
Self destruct parameters
void setMinSpeed2 (float minSpeed2)
 Sets minimal square speed of the first geom of the ammo (will be destroyed if under) ; values <=0 mean "no limit". When setting this parameter, think about cinetic energy, not simply speed. Ammo must have a 3D-Phy owner for self-destruct to be possible.
float getMinSpeed2 () const
void setMinCollisionCineticToDestroy (float energy)
 Sets cinetic energy above which the ammo is destroyed upon collision (0 means "destroy upon any collision"). Negative values are forbidden.
float getMinCollisionCineticToDestroy () const
Energy parameters
Values are generally energy values (in joules).

However, perforant value is a coefficient in [0, +inf[ that is used to compute how much energy is lost by ammo (= converted to heat, deformations, etc. = perforation damage) during perforation. The higher this value is, the more damage is does, but the less perforant it is. Near zero values mean "can traverse anything without loosing much energy", but <=0 means "not perforant ammo", which is much faster to compute. Perforant value generally depends on the size of the 3D-Phy. The actual formulae is globally similar to k * density * length = perforation_damage, where k is the coefficient, and length is the distance of perforation. Units generally react differently to this damage : an human or a zepplin would have a very high coefficient multiplicating the damage value (near 1), whereas a tank would not (near 0). Moreover, the tank would have a mush higher density than the other two ! Carefully define perforant parameter, especially with high-speed ammunition (A high speed ammo would tranfer too much cinetic energy if not perforant).

Radiant value will probably be used later for reflexion/refraction/absorption behaviors. In that way, you cannot set ammo to be radiant and perforant at the same time.

void setParam (WeaponEnergy::EEneryType energyType, float value)
 Sets a value for a given energy type.
float getParam (WeaponEnergy::EEneryType energyType) const

Protected Attributes

float vParams [WeaponEnergy::MAX_WEAPON_ENERGY]
bool canBeDeletedOnNextFrame
float minSpeed2
float minCollisionCineticToDestroy
float lastPerforationEnergy


Detailed Description

Ammunition class ; for all 3D-Phy that carries energy other than cinetic, and that moves too fast for the simulation to compute as usual.

Note : Other names for this class could be Damage3DPhy, or Ballistic.

v0.5 : All computations are done on the first geom, so ammo must have a geom, and the first one must have a body. Actually, ammo with more than one body will be a problem if perforant (because speed is modified on the first body, not on others). Ammo is a C3DPhy

v0.6 : Ammunition is a 3DPhy with no geom, and has only one body (directly in this class, because 3DPhy does not accept lone bodies). How to deal with missiles ???

Please note that missiles are units, not ammo : they create an "explosion" ammo on hit.

Author:
Sukender
Version:
0.2.0 - Under dev
See also:
Missile

Definition at line 62 of file Ammo.h.


Constructor & Destructor Documentation

Ammo::Ammo ( osg::MatrixTransform *  pModel,
Physics::Geom pGeom,
C3DPhy::EInitOptions  options,
const C3DPhy pInheritTeamAndPlayer = NULL 
)

Definition at line 62 of file Ammo.cpp.

References WeaponEnergy::MAX_WEAPON_ENERGY, and vParams.

Ammo::Ammo ( const C3DPhy v,
UINT  copyOpts = COPY_3D | COPY_PHYSICS | COPY_OWNER 
)

Definition at line 68 of file Ammo.cpp.

References WeaponEnergy::MAX_WEAPON_ENERGY, and vParams.

Ammo::Ammo ( const Ammo v,
UINT  copyOpts = COPY_3D | COPY_PHYSICS | COPY_OWNER 
)

Definition at line 73 of file Ammo.cpp.

References WeaponEnergy::MAX_WEAPON_ENERGY, and vParams.


Member Function Documentation

virtual Ammo* Ammo::asAmmo (  )  [inline, virtual]

Reimplemented from IGeomCollisionContainer.

Definition at line 71 of file Ammo.h.

float Ammo::getMinCollisionCineticToDestroy (  )  const [inline]

Definition at line 82 of file Ammo.h.

float Ammo::getMinSpeed2 (  )  const [inline]

Definition at line 78 of file Ammo.h.

float Ammo::getParam ( WeaponEnergy::EEneryType  energyType  )  const [inline]

Definition at line 106 of file Ammo.h.

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

Gets the type of the current container.

Reimplemented from C3DPhy.

Definition at line 70 of file Ammo.h.

void Ammo::hitAfter ( Physics::Contact pContacts,
unsigned int  nbContacts,
Physics::Contact pMaxEnergyContact,
Physics::Geom thisGeom,
Physics::Geom otherGeom,
bool  contactJointCreated 
) [virtual]

bool Ammo::hitBefore ( Physics::Contact pContacts,
unsigned int  nbContacts,
Physics::Contact pMaxEnergyContact,
Physics::Geom thisGeom,
Physics::Geom otherGeom,
Physics::Body *&  inout_pThisBody,
Physics::Body *&  inout_pOtherBody 
) [virtual]

void Ammo::setMinCollisionCineticToDestroy ( float  energy  )  [inline]

Sets cinetic energy above which the ammo is destroyed upon collision (0 means "destroy upon any collision"). Negative values are forbidden.

Definition at line 81 of file Ammo.h.

References ASSERT.

void Ammo::setMinSpeed2 ( float  minSpeed2  )  [inline]

Sets minimal square speed of the first geom of the ammo (will be destroyed if under) ; values <=0 mean "no limit". When setting this parameter, think about cinetic energy, not simply speed. Ammo must have a 3D-Phy owner for self-destruct to be possible.

Definition at line 77 of file Ammo.h.

void Ammo::setParam ( WeaponEnergy::EEneryType  energyType,
float  value 
) [inline]

Sets a value for a given energy type.

Definition at line 105 of file Ammo.h.

void Ammo::step ( dReal  stepSize  )  [virtual]

Steps the ammo (tests TTL as base class, and minimal speed).

Reimplemented from C3DPhy.

Definition at line 85 of file Ammo.cpp.

References ASSERT, Physics::dBodyGetLinearVelV(), minSpeed2, C3DPhy::onTTLZero(), C3DPhy::ttl, and C3DPhy::vGeoms.


Member Data Documentation

Definition at line 131 of file Ammo.h.

Referenced by hitAfter(), and hitBefore().

float Ammo::lastPerforationEnergy [protected]

Definition at line 133 of file Ammo.h.

Referenced by hitAfter(), and hitBefore().

Definition at line 132 of file Ammo.h.

Referenced by hitBefore().

float Ammo::minSpeed2 [protected]

Definition at line 132 of file Ammo.h.

Referenced by step().

float Ammo::vParams[WeaponEnergy::MAX_WEAPON_ENERGY] [protected]

Definition at line 130 of file Ammo.h.

Referenced by Ammo(), hitAfter(), and hitBefore().


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