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
Code: Select all
// 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));
Code: Select all
// 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);
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.zip
I hope you like it