CShieldManager Class Reference

The Shield Manager manages shields, impacts and rendering those. More...

#include <CShieldManager.h>

List of all members.

Classes

struct  SImpact
 Struct to handle the impacts.
struct  SShield
 Struct to handle the shield nodes.

Public Member Functions

 CShieldManager (scene::ISceneManager *psmgr, irr::ITimer *ptimer)
 Constructor.
 ~CShieldManager ()
 Destructor.
void drawAll ()
 Renders the shields.
virtual void OnSetConstants (video::IMaterialRendererServices *services, s32 userData)
 Sets the uniform variables for the shader.
bool addShield (scene::ISceneNode *node)
 Add a new shield.
bool removeShield (scene::ISceneNode *node)
 Remove a shield.
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))
 Add an impact in object space to the shield.
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))
 Add an impact in global space to the shield.
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))
 Let the manager determine the impact position by using a given ray.

Detailed Description

The Shield Manager manages shields, impacts and rendering those.

All shields and impacts are structs sorted in an array. The shields are managed in an array attribute of the manager and the impact in an array of the respective shield. The manager also has a drawAll method like the scene manager. It is used the same way. You can add any mesh node as a shield. However, it is recomended that you use nodes that are transparent with EMT_TRANSPARENT_ADD_COLOR or EMT_TRANSPARENT_ALPHA_CHANNEL.
The first texture of the node should be completely transparent (layer 0).
The second will be used as a base color map by the shader (layer 1).
The third texture will be used for a gradient effect (layer 2).


Constructor & Destructor Documentation

CShieldManager::CShieldManager ( scene::ISceneManager *  psmgr,
irr::ITimer *  ptimer 
)

Constructor.

Sets up the manager and creates the shader

Parameters:
psmgr SceneManager of the device
ptimer Timer of the device

GLSL Shader Code


Member Function Documentation

bool CShieldManager::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) 
)

Add an impact in global space to the shield.

Returns:
true if the shield exists and the impact has been added
Parameters:
node The node that acts as a shield
position The position of the impact on the shield in global space
radius The maximum radius of the impact
duration The impact's lifespan
color The Color of the impact
core::vector3df CShieldManager::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) 
)

Let the manager determine the impact position by using a given ray.

Returns:
the local position of the impact when successful, the ray's end otherwise
Parameters:
node The node that acts as a shield
ray The ray that hits the shield
radius The maximum radius of the impact
duration The impact's lifespan
color The Color of the impact
bool CShieldManager::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) 
)

Add an impact in object space to the shield.

Returns:
true if the shield exists and the impact has been added
Parameters:
node The node that acts as a shield
position The position of the impact on the shield in the shieldnode's local space
radius The maximum radius of the impact
duration The impact's lifespan
color The Color of the impact
bool CShieldManager::addShield ( scene::ISceneNode *  node  ) 

Add a new shield.

Returns:
true if it is a new shield, false if the shield already exists
Parameters:
node The node that shall act as a shield
void CShieldManager::drawAll (  ) 

Renders the shields.

Different effects for the shield: You can calculate the impacts radius with a function that uses "dif" as an argument. dif is betweeen 0.0 (life start) and 1.0 (life end)


These are two preset effects:

1. Absorbing effect:

                tmp_radius = array_Shields[i].array_Impacts[j].radius*(0.25 - pow((dif-0.5),2));
                tmp_color = array_Shields[i].array_Impacts[j].color;

2. Fade-out effect:

                tmp_radius = array_Shields[i].array_Impacts[j].radius*dif;
                tmp_color = array_Shields[i].array_Impacts[j].color;
                tmp_color.a = 1-dif;

bool CShieldManager::removeShield ( scene::ISceneNode *  node  ) 

Remove a shield.

Returns:
true if it shield was removed, false if the shield was not found
Parameters:
node The shield that shall be removed

The documentation for this class was generated from the following files:
Generated on Tue May 25 10:21:33 2010 for Irrlicht Shield Effect by  doxygen 1.6.3