Simple cloud layer SceneNode

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
tbw
Posts: 59
Joined: Sat Jan 15, 2011 9:51 am
Location: Germany

Simple cloud layer SceneNode

Post 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
Last edited by tbw on Fri Jan 13, 2012 7:35 pm, edited 2 times in total.
Virror
Posts: 191
Joined: Mon May 02, 2011 3:15 pm

Post by Virror »

One word: AMAZING!
Looks so good i think i will cry : p
Btw, is this free to use?
Luben
Posts: 568
Joined: Sun Oct 09, 2005 10:12 am
Location: #irrlicht @freenode

Post by Luben »

It looks very good, thanks for sharing :)
If you don't have anything nice to say, don't say anything at all.
tbw
Posts: 59
Joined: Sat Jan 15, 2011 9:51 am
Location: Germany

Post by tbw »

Sorry I forgot: license is zlib. So have fun with it! :D
Virror
Posts: 191
Joined: Mon May 02, 2011 3:15 pm

Post by Virror »

Then i will try it out in my game right now : )
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

Looks good. Thanks. :wink:
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
netpipe
Posts: 670
Joined: Fri Jun 06, 2008 12:50 pm
Location: Edmonton, Alberta, Canada
Contact:

awesome

Post by netpipe »

amazing demo, thanks much!
Live long and phosphor!
-- https://github.com/netpipe/Luna Game Engine Status 95%
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Post 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)
tbw
Posts: 59
Joined: Sat Jan 15, 2011 9:51 am
Location: Germany

Post 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
Last edited by tbw on Tue May 17, 2011 6:28 pm, edited 1 time in total.
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Post by REDDemon »

Very good work. I will add it immediatly to the snippets folder.
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
Buck1000
Posts: 93
Joined: Sun Dec 14, 2008 8:02 pm
Location: Seattle, WA

Post by Buck1000 »

That looked AWESOME. Good job :D

Is there any way you could randomly generate the cloud layer textures at runtime?
Murloc992
Posts: 272
Joined: Mon Apr 13, 2009 2:45 pm
Location: Utena,Lithuania

Post 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
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Post by greenya »

Just wow!
This looks really really good :!:
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post 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 :)
Working on game: Marrbles (Currently stopped).
Tannz0rz
Posts: 35
Joined: Fri May 08, 2009 12:25 am
Location: Orlando FL, USA

Post by Tannz0rz »

How nice! Runs quite fluently, might I add.
Post Reply