Page 1 of 5

Simple cloud layer SceneNode

Posted: Mon May 16, 2011 6:50 pm
by tbw
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)

Image

The CloudSceneNode is a dome that is spanned between the skybox and the scene

Image

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));
The integration into the scene is done as usual:

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);
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.zip

I hope you like it

Posted: Mon May 16, 2011 7:38 pm
by Virror
One word: AMAZING!
Looks so good i think i will cry : p
Btw, is this free to use?

Posted: Mon May 16, 2011 7:42 pm
by Luben
It looks very good, thanks for sharing :)

Posted: Mon May 16, 2011 8:05 pm
by tbw
Sorry I forgot: license is zlib. So have fun with it! :D

Posted: Mon May 16, 2011 8:07 pm
by Virror
Then i will try it out in my game right now : )

Posted: Mon May 16, 2011 8:32 pm
by shadowslair
Looks good. Thanks. :wink:

awesome

Posted: Tue May 17, 2011 5:06 am
by netpipe
amazing demo, thanks much!

Posted: Tue May 17, 2011 7:14 am
by hendu
That looks excellent :D

Note it doesn't build as-is:
In file included from CloudSceneNode.cpp:20:
CloudSceneNode.h:132:7: warning: no newline at end of file
In file included from main.cpp:7:
CloudSceneNode.h:132:7: warning: no newline at end of file
main.cpp: In function 'int main()':
main.cpp:91: error: no matching function for call to 'irr::scene::CCloudSceneNode::setTranslation(irr::core::vector2d<float>)'
CloudSceneNode.h:85: note: candidates are: virtual void irr::scene::CCloudSceneNode::setTranslation(irr::core::vector2d<float>&)
main.cpp:97: error: no matching function for call to 'irr::scene::CCloudSceneNode::setTranslation(irr::core::vector2d<float>)'
CloudSceneNode.h:85: note: candidates are: virtual void irr::scene::CCloudSceneNode::setTranslation(irr::core::vector2d<float>&)
main.cpp:104: error: no matching function for call to 'irr::scene::CCloudSceneNode::setTranslation(irr::core::vector2d<float>)'
CloudSceneNode.h:85: note: candidates are: virtual void irr::scene::CCloudSceneNode::setTranslation(irr::core::vector2d<float>&)
And the skybox isn't loaded, as they are named .PNG, while you call .png.

But after fixing those, it does look very nice ;)


(WTF is VC++ doing with a 650kb exe, it's 46kb here :P)

Posted: Tue May 17, 2011 8:20 am
by tbw
Thank you for the hint!
As you mentioned I compiled the code on a windows machine with visual studio 2008. The compiler doesn't care about the newline at the end of the header files and the file extension is resolved correctly, but only on windows.
Looks like I've been a little bit lazy :oops:

So I will fix the code and reupload the sample!

EDIT:

Fixed the issues and updated the download

Posted: Tue May 17, 2011 8:24 am
by REDDemon
Very good work. I will add it immediatly to the snippets folder.

Posted: Tue May 17, 2011 1:49 pm
by Buck1000
That looked AWESOME. Good job :D

Is there any way you could randomly generate the cloud layer textures at runtime?

Posted: Tue May 17, 2011 3:18 pm
by Murloc992
Buck1000 wrote:That looked AWESOME. Good job :D

Is there any way you could randomly generate the cloud layer textures at runtime?
LibNoise is there to do exactly what you want. :P

Posted: Tue May 17, 2011 3:50 pm
by greenya
Just wow!
This looks really really good :!:

Posted: Tue May 17, 2011 4:01 pm
by serengeor
I was watching this thread for a few days and after all those replies I got tempted to try it out.
Simply astonishing :wink:
This could make many games look more pretty/dynamic :)

Posted: Tue May 17, 2011 11:27 pm
by Tannz0rz
How nice! Runs quite fluently, might I add.