flame particle effect

Posted By: mr_x

flame particle effect - 08/07/08 13:41

The goal of this example is that particle has start and end colors. And particle interpolate between this colors during life cycle.

DOWNLOAD
Code:
///////////////////////////////////////////////////////////////////
BMAP* flame_particle = "flame.tga"; // set here your particle image
///////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////
var start_color[3];		// start color of the particle
var end_color[3];			// end color of the particle
var current_color[3];	// current color of the particle
var flame_lifespan = 10;
///////////////////////////////////////////////////////////////////

// helper function: sets the vector to random direction and length
function flame_randomize (var* vec, var range)
{	
   vec[0] = random(1) - 0.5;
   vec[1] = random(1) - 0.5;
   vec[2] = random(3) + 0.5;
   vec_normalize(vec,random(range));
}

// helper function: fades out a particle
function flame_alphafade(PARTICLE *p)
{
	start_color[0] = 200;
	start_color[1] = 180;
	start_color[2] = 100;
	
	end_color[0] = 128;
	end_color[1] = 50;
	end_color[2] = 50;
	
	vec_lerp(current_color[0], end_color[0], start_color[0], p.lifespan / flame_lifespan);

	p.red = current_color[0];
	p.green = current_color[1];
	p.blue = current_color[2];
	
	p.alpha = p.lifespan / flame_lifespan * 100 * 0.3;
	if (p.alpha <= 0) p.lifespan = 0;
}

// particle function: generates a fading explosion into vel direction
function effect_flame(PARTICLE *p)
{
   var temp[3];
   flame_randomize(temp, 5);
   vec_add (p.vel_x, temp);
   p.bmap = flame_particle;
   p.flags |= (BRIGHT | MOVE | TRANSLUCENT);
   p.lifespan = flame_lifespan;
   p.size = 12;
   p.event = flame_alphafade; // change to a shorter, faster function
}

Posted By: croman

Re: flame particle effect - 08/07/08 13:44

Error
The uploader has removed this file from the server.

the file is deleted, upload again
Posted By: mr_x

Re: flame particle effect - 08/07/08 14:08

Sorry, try this.
http://www.megaupload.com/?d=5ZSJ8NH9
Posted By: ATOMIX

Re: flame particle effect - 08/29/08 13:29

That's just a come on to buy a download service!!!
Where's the file?
Thanx a lot!
Posted By: mr_x

Re: flame particle effect - 08/30/08 13:43

http://rapidshare.com/files/141303825/flame.rar.html
Posted By: ATOMIX

Re: flame particle effect - 08/30/08 13:58

Alright that did it!! Thanx a lot
Posted By: mr_x

Re: flame particle effect - 08/30/08 14:20

I hope it will be useful smile
Posted By: Tails01

Re: flame particle effect - 09/04/08 12:29

yeah simple and nice, thanks mr_x

Tails
Posted By: ATOMIX

Re: flame particle effect - 09/05/08 14:38

It's gorgeous and you made our Artist very happy.
Posted By: Frederick_Lim

Re: flame particle effect - 09/07/08 09:44

Very nice effect~!
Posted By: VeT

Re: flame particle effect - 04/19/09 12:01

great ^^
Posted By: Jaxas

Re: flame particle effect - 04/19/09 13:55

not bad, looks beter on 60 fps wink
© 2024 lite-C Forums