반응형

http://irrlicht.sourceforge.net/forum//viewtopic.php?t=43873#p250538


Simple cloud layer SceneNode

Postby 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.zip

I hope you like it
Last edited by tbw on Fri Jan 13, 2012 7:35 pm, edited 2 times in total.
tbw
 
Posts: 58
Joined: Sat Jan 15, 2011 9:51 am
Location: Germany

Postby Virror » Mon May 16, 2011 7:38 pm

One word: AMAZING! 
Looks so good i think i will cry : p 
Btw, is this free to use?
Virror
 
Posts: 191
Joined: Mon May 02, 2011 3:15 pm

Postby Luben » Mon May 16, 2011 7:42 pm

It looks very good, thanks for sharing :)
If you don't have anything nice to say, don't say anything at all.
User avatar
Luben
 
Posts: 568
Joined: Sun Oct 09, 2005 10:12 am
Location: #irrlicht @freenode

Postby tbw » Mon May 16, 2011 8:05 pm

Sorry I forgot: license is zlib. So have fun with it! :D
tbw
 
Posts: 58
Joined: Sat Jan 15, 2011 9:51 am
Location: Germany

Postby Virror » Mon May 16, 2011 8:07 pm

Then i will try it out in my game right now : )
Virror
 
Posts: 191
Joined: Mon May 02, 2011 3:15 pm

Postby shadowslair » Mon May 16, 2011 8:32 pm

Looks good. Thanks. :wink:
Image
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
User avatar
shadowslair
 
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

awesome

Postby tecan » Tue May 17, 2011 5:06 am

amazing demo, thanks much!
Live long and phosphor! 
--Luna - Status 60%
User avatar
tecan
 
Posts: 277
Joined: Fri Jun 06, 2008 12:50 pm
Location: Edmonton, Alberta, Canada

Postby hendu » Tue May 17, 2011 7:14 am

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)
hendu
 
Posts: 1414
Joined: Sat Dec 18, 2010 12:53 pm

Postby tbw » Tue May 17, 2011 8:20 am

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

Postby REDDemon » Tue May 17, 2011 8:24 am

Very good work. I will add it immediatly to the snippets folder.
OpenGL is not hard. What you have to do is just explained in specifications. What is hard is dealing with poor OpenGL implementations.
User avatar
REDDemon
 
Posts: 827
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Postby Buck1000 » Tue May 17, 2011 1:49 pm

That looked AWESOME. Good job :D 

Is there any way you could randomly generate the cloud layer textures at runtime?
User avatar
Buck1000
 
Posts: 93
Joined: Sun Dec 14, 2008 8:02 pm
Location: Seattle, WA

Postby Murloc992 » Tue May 17, 2011 3:18 pm

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
User avatar
Murloc992
 
Posts: 272
Joined: Mon Apr 13, 2009 2:45 pm
Location: Utena,Lithuania

Postby greenya » Tue May 17, 2011 3:50 pm

Just wow! 
This looks really really good :!:
User avatar
greenya
 
Posts: 886
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine

Postby serengeor » Tue May 17, 2011 4:01 pm

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).
User avatar
serengeor
 
Posts: 1676
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Postby Tannz0rz » Tue May 17, 2011 11:27 pm

How nice! Runs quite fluently, might I add.

반응형

+ Recent posts