Commit 818b7985 authored by bitplane's avatar bitplane

Added a texture animator to volume light in special effects example to show...

Added a texture animator to volume light in special effects example to show off how cool it can look, and better integrated it into the tutorial.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1316 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 0e63486f
......@@ -24,6 +24,7 @@ int main()
printf("Please press 'y' if you want to use realtime shadows.\n");
std::cin >> i;
bool shadows = (i == 'y');
// ask user for driver
......@@ -191,6 +192,46 @@ int main()
ps->setMaterialTexture(0, driver->getTexture("../../media/fire.bmp"));
ps->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);
/*
Next we add a volumetric light node, which adds a glowing fake area light to
the scene. Like with the billboards and particle systems we also assign a
texture for the desired effect, though this time we'll use a texture animator
to create the illusion of a magical glowing area effect.
*/
scene::IVolumeLightSceneNode * n = smgr->addVolumeLightSceneNode(0, -1,
32, // Subdivisions on U axis
32, // Subdivisions on V axis
video::SColor(0, 255, 255, 255), // foot color
video::SColor(0, 0, 0, 0) // tail color
);
if (n)
{
n->setScale(core::vector3df(56.0f, 56.0f, 56.0f));
n->setPosition(core::vector3df(-120,50,40));
// load textures for animation
core::array<video::ITexture*> textures;
for (s32 g=7; g > 0; --g)
{
core::stringc tmp;
tmp = "../../media/portal";
tmp += g;
tmp += ".bmp";
video::ITexture* t = driver->getTexture( tmp.c_str () );
textures.push_back(t);
}
// create texture animator
scene::ISceneNodeAnimator *glow = smgr->createTextureAnimator(textures, 150);
// add the animator
n->addAnimator(glow);
// drop the animator because it was created with a create() function
glow->drop();
}
/*
As our last special effect, we want a dynamic shadow be casted from an animated
character. For this we load a DirectX .x model and place it into our world.
......@@ -214,21 +255,6 @@ int main()
anode->setPosition(core::vector3df(-50,20,-60));
anode->setAnimationSpeed(15);
//volumetric lighting
scene::IVolumeLightSceneNode * n = smgr->addVolumeLightSceneNode(NULL, -1,
32, //Sub Divid U
32, //Sub Divid V
video::SColor(0, 180, 180, 180), //foot colour
video::SColor(0, 0, 0, 0) //tail colour
);
if (n) {
n->setScale(core::vector3df(56.0f, 56.0f, 56.0f));
n->setPosition(core::vector3df(-120,60,40));
video::SMaterial& mat = n->getMaterial(0);
mat.setTexture(0, smgr->getVideoDriver()->getTexture("../../media/lightFalloff.png"));
}
// add shadow
anode->addShadowVolumeSceneNode();
smgr->setShadowColor(video::SColor(150,0,0,0));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment