by tbw » Mon May 16, 2011 6:50 pm
I want to share a litte experiment with you.
I needed a shifting cloud layer in my scene and decided to encapsulate it in a scene node. Here is the result (source code and example link at the bottom of the post)
The CloudSceneNode is a dome that is spanned between the skybox and the scene
The interface of the SceneNode offers access to the geometry and the color of the SceneNode
// returns the inner radius
virtual f32 getInnerRadius() { return InnerRadius; }
// returns the outer radius
virtual f32 getOuterRadius() { return OuterRadius; }
// returns the center height
virtual f32 getCenterHeight() { return CenterHeight; }
// returns the inner height
virtual f32 getInnerHeight() { return InnerHeight; }
// returns the outer height
virtual f32 getOuterHeight() { return OuterHeight; }
// returns the center color
virtual video::SColor& getCenterColor() { return CenterColor; }
// returns the inner color
virtual video::SColor& getInnerColor() { return InnerColor; }
// returns the outer color
virtual video::SColor& getOuterColor() { return OuterColor; }
// sets the cloud radius
virtual void setCloudRadius(
f32 innerRadius,
f32 outerRadius);
// sets the cloud height
virtual void setCloudHeight(
f32 centerHeight,
f32 innerHeight,
f32 outerHeight);
// sets the cloud colors
virtual void setCloudColor(
const video::SColor& centerColor = video::SColor(220,220,220,220),
const video::SColor& innerColor = video::SColor(180,180,180,180),
const video::SColor& outerColor = video::SColor(0,0,0,0));
The integration into the scene is done as usual:
// add 1st cloud layer
cloudLayer1 = new scene::CCloudSceneNode(smgr->getRootSceneNode(), smgr);
// set translation (speed of the clouds)
cloudLayer1->setTranslation(core::vector2d<f32>(0.008f, 0.0f));
cloudLayer1->getMaterial(0).setTexture(0, driver->getTexture("media/clouds/cloud01.png"));
// set the geometry
cloudLayer1->setCloudHeight(0.5f, 0.1f, -0.05f);
For further details please have a look into the source code.
Here is a small example with the source included (build with a 1.8 svn irrlicht version) with three cloudlayers. You can turn them on or off by pressing the keys 1, 2 or 3.
http://www.van-helsing-band.de/irrlicht ... nenode.zipI hope you like it
Last edited by
tbw on Fri Jan 13, 2012 7:35 pm, edited 2 times in total.