#include <Explosion.h>
Classes | |
class | LSCallback |
Public Member Functions | |
virtual EContainerType | getType () const |
Gets the type of the current container. | |
Explosion (bool createAnimation=true, const C3DPhy *pInheritTeamAndPlayer=NULL) | |
Creates an explosion with default parameters. | |
Explosion (const ExplosionParams ¶ms, bool createAnimation=true, const C3DPhy *pInheritTeamAndPlayer=NULL) | |
Creates an explosion with given parameters. | |
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. | |
osg::ImageSequence * | getAnimation () |
const osg::ImageSequence * | getAnimation () const |
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. | |
Energy parameters | |
Values are generally energy values (in joules).
Please not here that WeaponEnergy::PERFORANT is not supported for explosions. | |
void | setParam (WeaponEnergy::EEneryType energyType, float value) |
Sets a value for a given energy type. | |
float | getParam (WeaponEnergy::EEneryType energyType) const |
Protected Member Functions | |
virtual | ~Explosion () |
void | init (bool createAnimation=true) |
void | createLight (UINT lightNumber) |
Protected Attributes | |
float | vParams [WeaponEnergy::MAX_WEAPON_ENERGY] |
float | radius |
Current radius. | |
osg::Group * | pSphere |
3D growing sphere. | |
osg::ImageSequence * | pSpriteIS |
Animated sprite image sequence, or NULL. | |
float | spriteTime |
osg::LightSource * | pLight |
Friends | |
class | LSCallback |
An explosion is a growing (or not) sphere that pushes away things and give them cinetic energy and potentially all WeaponEnergy::EEneryType energies. The explosion has no mass (no Body, just a Geom), and thus the force applied to the touched objects is absolutly not related to the cinetic energy produced by the velocity of the explosion. The force applied relies on given values: the initial force and attenuation factors.
Add sprites support for cool effects (How do we animate? How long? Which color of the polys?...).
Add debris support for cool effects? Or manually add them outside? Or support one or two default options?
Add sound support (sound played once).
(low) Support custom force attenuation.
(low) Support non-linear growth (logarithmic / sqrtf like) and explosion time as an equivalent of growingSpeed.
Add support for camera shaking.
Add support for creation via a factory (?).
Definition at line 103 of file Explosion.h.
Explosion::Explosion | ( | bool | createAnimation = true , |
|
const C3DPhy * | pInheritTeamAndPlayer = NULL | |||
) |
Creates an explosion with default parameters.
Definition at line 68 of file Explosion.cpp.
References init().
Explosion::Explosion | ( | const ExplosionParams & | params, | |
bool | createAnimation = true , |
|||
const C3DPhy * | pInheritTeamAndPlayer = NULL | |||
) |
Creates an explosion with given parameters.
Definition at line 78 of file Explosion.cpp.
References init().
Explosion::~Explosion | ( | ) | [protected, virtual] |
Definition at line 210 of file Explosion.cpp.
References pLight, ExplosionParams::pLightStateSet, ExplosionParams::pLSM, and LightSourceManager::remove().
void Explosion::createLight | ( | UINT | lightNumber | ) | [protected] |
Definition at line 188 of file Explosion.cpp.
References ASSERT, ExplosionParams::lightDiffuse, ExplosionParams::lightLinearAttenuation, pLight, ExplosionParams::pLightStateSet, and C3DPhy::pModel.
Referenced by init(), and Explosion::LSCallback::onSourceAvailable().
const osg::ImageSequence* Explosion::getAnimation | ( | ) | const [inline] |
Definition at line 116 of file Explosion.h.
osg::ImageSequence* Explosion::getAnimation | ( | ) | [inline] |
Definition at line 115 of file Explosion.h.
float Explosion::getParam | ( | WeaponEnergy::EEneryType | energyType | ) | const [inline] |
Definition at line 130 of file Explosion.h.
virtual EContainerType Explosion::getType | ( | ) | const [inline, virtual] |
Gets the type of the current container.
Reimplemented from C3DPhy.
Definition at line 105 of file Explosion.h.
bool Explosion::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] |
Default behaviour on hit is to do nothing.
Reimplemented from C3DPhy.
Definition at line 278 of file Explosion.cpp.
References IGeomCollisionContainer::as3DPhy(), ASSERT, clamp(), ExplosionParams::colorAttenuationPow, Physics::dBodyAddForceAtPos(), dGeomGetPositionV(), PVLEGameHolder::get(), Physics::Geom::getCollisionContainer(), PVLEGame::getFriendlyFire(), Physics::Contact::getPos(), C3DPhy::getTeam(), Util::Singleton< PVLEGameHolder >::instance(), C3DPhy::isHitBy(), WeaponEnergy::MAX_WEAPON_ENERGY, ExplosionParams::maxForce, ExplosionParams::maxRadius, WeaponEnergy::PERFORANT, C3DPhy::pTeam, radius, C3DPhy::vGeoms, and vParams.
void Explosion::init | ( | bool | createAnimation = true |
) | [protected] |
Definition at line 89 of file Explosion.cpp.
References C3DPhy::addGeom(), ASSERT, C3DPhy::bind(), Physics::createCanonicalSphereGeom(), createLight(), createShapeGeodeSphere(), ExplosionParams::growingSpeed, ExplosionParams::lightBasePriority, ExplosionParams::lightNumber, LSCallback, WeaponEnergy::MAX_WEAPON_ENERGY, ExplosionParams::maxForce, ExplosionParams::maxRadius, ExplosionParams::pLightStateSet, ExplosionParams::pLSM, C3DPhy::pModel, pSphere, pSpriteIS, radius, ExplosionParams::RENDER_BILLBOARD_DEPTH_ALWAYS, ExplosionParams::RENDER_SPRITE, ExplosionParams::renderMode, LightSourceManager::request(), C3DPhy::setModel(), ExplosionParams::spriteEmission, and vParams.
Referenced by Explosion().
void Explosion::setParam | ( | WeaponEnergy::EEneryType | energyType, | |
float | value | |||
) | [inline] |
Sets a value for a given energy type.
Be aware that values are attenuated over time, as the explosion grows, the same way the force is attenuated.
Definition at line 129 of file Explosion.h.
References ASSERT, and WeaponEnergy::PERFORANT.
void Explosion::step | ( | dReal | stepSize | ) | [virtual] |
Steps the 3D-Phy. Default is to do nothing but decreasing the TTL and call the onTTLZero() method if necessary.
Reimplemented from C3DPhy.
Definition at line 221 of file Explosion.cpp.
References ASSERT, clamp(), ExplosionParams::colorAttenuationPow, ExplosionParams::diffuseColor, ExplosionParams::emissionColor, ExplosionParams::growingSpeed, ExplosionParams::lightBasePriority, ExplosionParams::lightDiffuse, ExplosionParams::maxForce, ExplosionParams::maxRadius, C3DPhy::onTTLZero(), pLight, ExplosionParams::pLightStateSet, ExplosionParams::pLSM, pSphere, pSpriteIS, radius, spriteTime, LightSourceManager::updatePriority(), and C3DPhy::vGeoms.
friend class LSCallback [friend] |
osg::LightSource* Explosion::pLight [protected] |
Definition at line 150 of file Explosion.h.
Referenced by createLight(), Explosion::LSCallback::onSourceTaken(), step(), and ~Explosion().
osg::Group* Explosion::pSphere [protected] |
osg::ImageSequence* Explosion::pSpriteIS [protected] |
float Explosion::radius [protected] |
Current radius.
Definition at line 144 of file Explosion.h.
Referenced by hitBefore(), init(), and step().
float Explosion::spriteTime [protected] |
float Explosion::vParams[WeaponEnergy::MAX_WEAPON_ENERGY] [protected] |