Procedural Fire Scene Node For Ya.

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
CZestmyr
Posts: 72
Joined: Sat Feb 12, 2005 7:11 pm
Location: Czech Republic
Contact:

Procedural Fire Scene Node For Ya.

Post by CZestmyr »

Hello, dear fellas! I am pleased to present another scene node from my lab to you today. It is a nice fire scene node without the need to use particles. Watch the results:

Image

As with all custom scene nodes, all you have to do is create a new instance, make it a child of the root scene node and drop it.

Code: Select all

ISceneNode* fire = new CFireSceneNode(
    root, //Parent
    smgr, //Scene Manager
    device->getTimer(), //ITimer
    "cool.tga", //Fadeout texture
    SColor(255, 255, 128, 0), //Starting color
    2, //Fadeout color (2 - red, 1 - green, 0 - blue)
    0.95f, //Fadeout rate (0.0f - 1.0f -> the higher, the less the 
             //color fades into the fadeout color)
    64, //Texture X size
    64, //Texture Y size
    30, //Width
    70, //Height
    20, //Update speed
    -1, //id
    vector3df(0.0f, 20.0f, 0.0f), //Position
    vector3df(0.0f, 0.0f, 0.0f) //Rotation
);
fire->drop();
I'm still using Irrlicht 0.10.0, so there may be some difficulties for the 0.12.0 users because of the ITimer interface. But it shouldn't be too difficult to change, just change this line in the render() method, so that it uses the new timer interface:

u32 deltaTime = timer->getTime() - prevTime;

Link to the code is in my sig
Bugfree is not a synonym to dumbass-resistant

My irrlicht files and tutorials
My music in mp3
omaremad_

Post by omaremad_ »

looks more like those really cool light rays in splinter cell welldone
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

it crashes for me on this line -

Code: Select all

color_average = m(avg(pixels[prev_index + k], pixels[prev_index_minus1 + k], pixels[prev_index_plus1 + k]), pixels_cool[cool_index + k] / 128.0f);
It only crashes in DX, OpenGL works.


EDIT: Nevermind, it works, was a bug with something else I was doing to the DX driver, sorry.
Image
Guest

Post by Guest »

I agree it looks more like light shards than fire but nonetheless it looks very nice and will come in handy!

thanks
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

@CZestmyr, very nice! Thanks for posting.
ImageImage
Site development -Rock and metal online
--- etcaptor.com ------freenetlife.com
Fernando Alonso

Post by Fernando Alonso »

Congratulations!!! very nice, i hope youy continue with your projects
Guest

Post by Guest »

Hi all .. cool custom node.. do you know where I can get the cool.tga file?
CZestmyr
Posts: 72
Joined: Sat Feb 12, 2005 7:11 pm
Location: Czech Republic
Contact:

Post by CZestmyr »

The cooling texture just defines, how much the fire should cool in the place of a certain pixel. This texture then gets shifted, when animating the fire.

Just create your own grayscale texture, which defines the cooling. It should have the same dimensions as the generated flame texture.
Bugfree is not a synonym to dumbass-resistant

My irrlicht files and tutorials
My music in mp3
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

I can't get this scene node to look good at all. No matter what texture I use, it looks horrible. You need to give a better definition for how the texture should be formatted.
Image
CZestmyr
Posts: 72
Joined: Sat Feb 12, 2005 7:11 pm
Location: Czech Republic
Contact:

Post by CZestmyr »

Spintz: Post a pic of your results and a piece of your code. I hope I'll be able to help.
Bugfree is not a synonym to dumbass-resistant

My irrlicht files and tutorials
My music in mp3
CZestmyr
Posts: 72
Joined: Sat Feb 12, 2005 7:11 pm
Location: Czech Republic
Contact:

Post by CZestmyr »

I think I know where the problem is - the texture is not grayscale, but ordinary 24-bit, but if you have only grays in it, the colors fade out evenly (except for the fade-out color, which stays longer)
Bugfree is not a synonym to dumbass-resistant

My irrlicht files and tutorials
My music in mp3
Post Reply