Irrlicht Shield Effect: CShieldManager.h Source File

- Main Page
- Classes
- Files

- File List

# CShieldManager.h

    00001 #ifndef CSHIELDMANAGER_H_INCLUDED
    00002 #define CSHIELDMANAGER_H_INCLUDED
    00003
    00004 #include <irrlicht.h>
    00005 using namespace irr;
    00006
    00008
    00017 class CShieldManager: public video::IShaderConstantSetCallBack
    00018 {
    00019 private:
    00021         struct SImpact
    00022         {
    00023             //Position of the impact in local node space
    00024                 core::vector3df pos;
    00025                 //Color of the impact
    00026                 video::SColorf color;
    00027                 //Maximum radius
    00028                 f32 radius;
    00029                 //To determine when to delete the impact from the shield's array
    00030                 u32 startTime;
    00031                 u32 endTime;
    00032         };
    00033
    00035         struct SShield
    00036         {
    00037             //The node
    00038             scene::ISceneNode *shieldNode;
    00039             //The array of impacts on this shield
    00040             core::array<SImpact> array_Impacts;
    00041         };
    00042
    00043 public:
    00045
    00048         CShieldManager(scene::ISceneManager* psmgr, irr::ITimer *ptimer);
    00049
    00051         ~CShieldManager();
    00052
    00054         void drawAll();
    00055
    00057         virtual void OnSetConstants(video::IMaterialRendererServices* services,s32 userData);
    00058
    00060
    00062         bool addShield(scene::ISceneNode *node);
    00063
    00065
    00067         bool removeShield(scene::ISceneNode *node);
    00068
    00070
    00076         bool addLocalImpact(const scene::ISceneNode *node, const core::vector3df position,const f32 radius=1, const u32 duration=500, const video::SColorf color = video::SColorf(1,1,1,1));
    00077
    00079
    00085         bool addGlobalImpact(const scene::ISceneNode *node, core::vector3df &position,const f32 radius=1, const u32 duration=500, const video::SColorf color = video::SColorf(1,1,1,1));
    00086
    00088
    00094         core::vector3df addImpact(const scene::ISceneNode *node, const core::line3df ray, const f32 radius=1, const u32 duration=500, const video::SColorf color = video::SColorf(1,1,1,1));
    00095
    00096 private:
    00097     //To check if the shields are currently visible
    00098     scene::ISceneManager* smgr;
    00099
    00100     //To draw the shields/impacts
    00101     video::IVideoDriver* driver;
    00102
    00103     //To erase impacts after their lifetime
    00104     irr::ITimer *timer;
    00105
    00106     //Manage the shields
    00107         core::array<SShield> array_Shields;
    00108
    00109     //The shield shader
    00110     int shaderMaterial;
    00111
    00112     //For compatibility
    00113     //no shader: -1
    00114     //arb shader 0;
    00115     //glsl shader 1;
    00116     int ShaderType;
    00117
    00118         //The following attributes parameters for the OnSetConstants method
    00119         //Radius of the current impact
    00120         f32 tmp_radius;
    00121         //Position of the current impact
    00122         core::vector3df tmp_position;
    00123         //Color of the current impact
    00124         video::SColorf tmp_color;
    00125 };
    00126
    00127 #endif // CSHIELDMANAGER_H_INCLUDED