Irrlicht Shield Effect: Irrlicht Shield Effect

# Irrlicht Shield Effect

Creating a shield is easy.
First you have to create a shield manager:

        CShieldManager *shieldmanager = new CShieldManager(smgr,device->getTimer());

This manager works like the ISceneManger from irrlicht, just for shields.

To add a shield, first create a scene node that you want to use as a shield e.g.

        scene::IMeshSceneNode shield_node = smgr->addSphereSceneNode(5);

Next configure the material of the node, to make the shield visible from in- and outside

        shield_node->setMaterialFlag(video::EMF_BACK_FACE_CULLING,false);

Then you make the node invisible, so that it does not interfere with the shield render pass

        shield_node->setbVisible(false);

In case you want to use rays to let the manager calculate impacts, you have to create a triangle selector for the node:

        scene::ITriangleSelector *selector = smgr->createTriangleSelector(shield_node->getMesh(),shield_node);
        shield_node->setTriangleSelector(selector);
        selector->drop();

At last you add the shield:

        shieldmanager->addShield(shield_node);

To add impacts you have to call the addImpact/addLocalImpact/addGlobalImpact function. To render the shields, call drawAll after the drawAll of the scene manager, otherwise the shields will be overdrawn by the rest of the scenery.

So thats that, have fun!
www.freetimestudio.de