#include <Ammo.h>
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 Ammo * | asAmmo () |
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
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 |
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.
Definition at line 62 of file Ammo.h.
Ammo::Ammo | ( | osg::MatrixTransform * | pModel, | |
Physics::Geom * | pGeom, | |||
C3DPhy::EInitOptions | options, | |||
const C3DPhy * | pInheritTeamAndPlayer = NULL | |||
) |
virtual Ammo* Ammo::asAmmo | ( | ) | [inline, virtual] |
float Ammo::getMinCollisionCineticToDestroy | ( | ) | const [inline] |
float Ammo::getParam | ( | WeaponEnergy::EEneryType | energyType | ) | const [inline] |
virtual EContainerType Ammo::getType | ( | ) | const [inline, virtual] |
void Ammo::hitAfter | ( | Physics::Contact * | pContacts, | |
unsigned int | nbContacts, | |||
Physics::Contact * | pMaxEnergyContact, | |||
Physics::Geom & | thisGeom, | |||
Physics::Geom & | otherGeom, | |||
bool | contactJointCreated | |||
) | [virtual] |
Effectively destroys the ammo if hitBefore() decided to AND if a contact joint has been created.
Reimplemented from C3DPhy.
Definition at line 173 of file Ammo.cpp.
References IGeomCollisionContainer::as3DPhy(), canBeDeletedOnNextFrame, PVLEGameHolder::get(), Physics::Geom::getCollisionContainer(), PVLEGame::getFriendlyFire(), Physics::Contact::getPos(), C3DPhy::getTeam(), Util::Singleton< PVLEGameHolder >::instance(), C3DPhy::isHitBy(), lastPerforationEnergy, WeaponEnergy::MAX_WEAPON_ENERGY, C3DPhy::onTTLZero(), WeaponEnergy::PERFORANT, C3DPhy::pTeam, and vParams.
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] |
Do all the computation to transfer energies (see setParam()) to the hit geom - also handles perforation.
Reimplemented from C3DPhy.
Definition at line 94 of file Ammo.cpp.
References C3DPhyOwner::addInScene(), Physics::Contact::arithmeticCineticEnergy, IGeomCollisionContainer::as3DPhy(), ASSERT, canBeDeletedOnNextFrame, Physics::dBodyGetLinearVelV(), Physics::dBodySetLinearVel(), SimulationHolder::get(), Physics::Geom::getBody(), Physics::Geom::getCollisionContainer(), Simulation::getCurPhyStep(), Physics::Geom::getGameplayDensity(), C3DPhy::getGeom(), Util::Singleton< SimulationHolder >::instance(), lastPerforationEnergy, LOG_ALWAYS, minCollisionCineticToDestroy, C3DPhy::p3DPhyOwner, WeaponEnergy::PERFORANT, perforationToCinetik, WeaponEnergy::RADIANT, C3DPhy::vGeoms, and vParams.
void Ammo::setMinCollisionCineticToDestroy | ( | float | energy | ) | [inline] |
void Ammo::setMinSpeed2 | ( | float | minSpeed2 | ) | [inline] |
void Ammo::setParam | ( | WeaponEnergy::EEneryType | energyType, | |
float | value | |||
) | [inline] |
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.
bool Ammo::canBeDeletedOnNextFrame [protected] |
float Ammo::lastPerforationEnergy [protected] |
float Ammo::minCollisionCineticToDestroy [protected] |
float Ammo::minSpeed2 [protected] |
float Ammo::vParams[WeaponEnergy::MAX_WEAPON_ENERGY] [protected] |