Page 1 of 1

Procedural Fire Scene Node For Ya.

Posted: Thu Oct 27, 2005 9:29 pm
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

Posted: Thu Oct 27, 2005 9:34 pm
by omaremad_
looks more like those really cool light rays in splinter cell welldone

Posted: Thu Oct 27, 2005 10:03 pm
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.

Posted: Fri Oct 28, 2005 8:54 am
by Guest
I agree it looks more like light shards than fire but nonetheless it looks very nice and will come in handy!

thanks

Posted: Fri Oct 28, 2005 3:07 pm
by etcaptor
@CZestmyr, very nice! Thanks for posting.

Posted: Fri Oct 28, 2005 3:51 pm
by Fernando Alonso
Congratulations!!! very nice, i hope youy continue with your projects

Posted: Sun Oct 30, 2005 12:30 am
by Guest
Hi all .. cool custom node.. do you know where I can get the cool.tga file?

Posted: Sun Oct 30, 2005 1:32 pm
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.

Posted: Sun Oct 30, 2005 2:39 pm
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.

Posted: Sun Oct 30, 2005 3:04 pm
by CZestmyr
Spintz: Post a pic of your results and a piece of your code. I hope I'll be able to help.

Posted: Sun Oct 30, 2005 3:17 pm
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)