00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef ENT_EXPLOSION_H
00028 #define ENT_EXPLOSION_H
00029
00030 #include <PVLE/Export.h>
00031 #include <PVLE/Entity/3DPhy.h>
00032 #include <PVLE/Entity/WeaponEnergy.h>
00033 #include <PVLE/3D/LightSourceManager.h>
00034 #include <osg/Vec4>
00035
00036 namespace osg {
00037 class Group;
00038 class Geode;
00039 class Billboard;
00040 class ImageSequence;
00041 class LightSource;
00042 class StateSet;
00043 }
00044 class LightSourceManager;
00045
00046
00049 class PVLE_EXPORT ExplosionParams {
00050 public:
00051 ExplosionParams();
00052 enum ERenderMode {
00053 RENDER_SPRITE,
00054 RENDER_BILLBOARD,
00055 RENDER_BILLBOARD_DEPTH_ALWAYS
00056 };
00057 ERenderMode renderMode;
00058
00059 float maxRadius;
00060 float growingSpeed;
00061
00062 float maxForce;
00063
00064
00065
00066 float colorAttenuationPow;
00067 osg::Vec4f diffuseColor;
00068 osg::Vec4f emissionColor;
00069
00070 osg::Vec4f lightDiffuse;
00071 float lightLinearAttenuation;
00072 osg::StateSet * pLightStateSet;
00073
00074
00075
00076
00077 UINT lightNumber;
00078 LightSourceManager * pLSM;
00079 LightSourceManager::Priority lightBasePriority;
00080 osg::Vec4f spriteEmission;
00081
00082 };
00083
00084
00103 class PVLE_EXPORT Explosion : public C3DPhy, protected ExplosionParams {
00104 public:
00105 virtual EContainerType getType() const { return OTHER; }
00106
00108 Explosion(bool createAnimation = true, const C3DPhy * pInheritTeamAndPlayer = NULL);
00109
00111 Explosion(const ExplosionParams & params, bool createAnimation = true, const C3DPhy * pInheritTeamAndPlayer = NULL);
00112
00113 virtual void step(dReal stepSize);
00114
00115 inline osg::ImageSequence * getAnimation() { return pSpriteIS; }
00116 inline const osg::ImageSequence * getAnimation() const { return pSpriteIS; }
00117
00118 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);
00119
00120
00125
00129 void setParam(WeaponEnergy::EEneryType energyType, float value) { ASSERT(energyType != WeaponEnergy::PERFORANT); vParams[energyType] = value; }
00130 float getParam(WeaponEnergy::EEneryType energyType) const { return vParams[energyType]; }
00132
00133 protected:
00134 class LSCallback : public LightSourceUserCallback {
00135 public:
00136 virtual bool onSourceTaken(LightSourceManager * pLightSourceManager, osg::Referenced * pUserObject, UINT lightNumber);
00137 virtual bool onSourceAvailable(LightSourceManager * pLightSourceManager, osg::Referenced * pUserObject, UINT lightNumber);
00138 virtual void onUserDropped(LightSourceManager * pLightSourceManager, osg::Referenced * pUserObject);
00139 };
00140 friend class LSCallback;
00141
00142 float vParams[WeaponEnergy::MAX_WEAPON_ENERGY];
00143
00144 float radius;
00145
00146 osg::Group * pSphere;
00147
00148 osg::ImageSequence * pSpriteIS;
00149 float spriteTime;
00150 osg::LightSource * pLight;
00151
00152 virtual ~Explosion();
00153
00154 void init(bool createAnimation = true);
00155 void createLight(UINT lightNumber);
00156 };
00157
00158
00159 #endif // ENT_EXPLOSION_H