1 registered members (AndrewAMD),
911
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Particles in Lite-C that actually works.
[Re: Hitsch]
#248193
01/25/09 08:38
01/25/09 08:38
|
Joined: Jan 2009
Posts: 34
DrunkenPirate
OP
Newbie
|
OP
Newbie
Joined: Jan 2009
Posts: 34
|
Yea, I have a copy of EasyParticle3 but as I said, it generates C-Script. I've tried converting the code from many different examples. I can't convert it to Lite-C. It won't run. That's why I want a running example of Lite-C particles, so I can look at it and see where I'm going wrong in my conversion from C-Script to Lite-C. My Current Code: Declarations:
function snow();
function infinity();
function effect_snowflake();
function createParticles();
BMAP* particle_map;
particle_map = bmap_create("particle.pcx");
VECTOR g_snowbox;
function createParticles() {
snow(4000,4000,2000,5000);
}
function infinity(PARTICLE* p)
{
vec_set(p.x,vector(cycle(p.x,camera.x-g_snowbox.x,camera.x+g_snowbox.x),
cycle(p.y,camera.y-g_snowbox.y,camera.y+g_snowbox.y),
cycle(p.z,camera.z-g_snowbox.z,camera.z+g_snowbox.z)));
p.lifespan=1; // live forever
}
function effect_snowflake(PARTICLE* p)
{
vec_set(p.x,vector(camera.x+random(g_snowbox.x*2)-g_snowbox.x,
camera.y+random(g_snowbox.y*2)-g_snowbox.y,
camera.z+random(g_snowbox.z*2)-g_snowbox.z));
vec_set(p.vel_z,vector(-(random(4)+4), random(2)-1, random(2)-1));
p.bmap=particle_map;
p.size=random(1)+2;
p.alpha=random(30)+10;
//p.move=on;
}
function snow(cx,cy,cz,numparticles)
{
g_snowbox.x=cx/2;
g_snowbox.y=cy/2;
g_snowbox.z=cz/2;
effect(effect_snowflake,numparticles,nullvector,nullvector);
}
|
|
|
Re: Particles in Lite-C that actually works.
[Re: DrunkenPirate]
#248202
01/25/09 10:24
01/25/09 10:24
|
Joined: May 2008
Posts: 331 Lithuania, Vilnius
Jaxas
Senior Member
|
Senior Member
Joined: May 2008
Posts: 331
Lithuania, Vilnius
|
Here's working Lite-C example:
//// Particle movement handling ///////
function vec_randomize (var* vec, var range)
{
vec[0] = random(0.5) - 0.25;
vec[1] = random(0.5) - 0.25;
vec[2] = random(1) - 0.25;
vec_normalize(vec,random(range));
}
//// particle alpha handling ////////
function part_alphafade(PARTICLE *p)
{
p.alpha -= 1*time_step;
if (p.alpha <= 0) p.lifespan = 0;
}
///// particle creating /////////
function effect_smokes(PARTICLE *p)
{
p.red = 100;
p.blue = 100;
p.green = 100;
var temp[3];
vec_randomize(temp,3);
vec_add (p.vel_x, temp);
p.alpha = 50 + random(25);
p.size = 30;
p.bmap = rauch2_farbe6;
p.flags |= (MOVE);
p.event = part_alphafade; // change to a shorter, faster function
}
//// particle using /////////
action destroyed_tank()
{
while(1)
{
effect(effect_smokes,50,my.x,normal);
wait(20);
}
}
Study code, manual, and you'll learn to use it, modify, and create lots of effect Jaxas
The smaller the bug, the harder it is to kill. _________________________________________ Forklift DEMO (3dgs)
|
|
|
Re: Particles in Lite-C that actually works.
[Re: DrunkenPirate]
#248216
01/25/09 13:24
01/25/09 13:24
|
Joined: May 2008
Posts: 331 Lithuania, Vilnius
Jaxas
Senior Member
|
Senior Member
Joined: May 2008
Posts: 331
Lithuania, Vilnius
|
Try this sample: (ship.x+100*cos(ship.pan), ship.y+100*sin(ship.pan), 0)) It's not tested,but in theory should work
The smaller the bug, the harder it is to kill. _________________________________________ Forklift DEMO (3dgs)
|
|
|
Re: Particles in Lite-C that actually works.
[Re: Jaxas]
#248307
01/25/09 22:37
01/25/09 22:37
|
Joined: Jan 2009
Posts: 34
DrunkenPirate
OP
Newbie
|
OP
Newbie
Joined: Jan 2009
Posts: 34
|
Jaxas: Thank you for all your help. I didn't really describe whats going on correctly so that last bit didn't work for me. Particles have a few options: Velocity is a local vector. Meaning that you would make a vector much like this to place the particle stream: Location: vector(shipWing.x,shipWing.y,shipWing.z) <-Not really important to problem. Velocity: vector(10,2,2) <-This vector gets a "exhaust" stream like I want, but only when the ship is oriented straight (Zero pan). The reason this is difficult is I don't know how to calculate the correct velocity. I'm not sure how to incorporate the ship's pan so that the exhaust always shoots out straight back from the wings. I'll post some screen shots of what I'm talking about in a few minutes.
|
|
|
Re: Particles in Lite-C that actually works.
[Re: DrunkenPirate]
#248309
01/25/09 22:51
01/25/09 22:51
|
Joined: Jan 2009
Posts: 34
DrunkenPirate
OP
Newbie
|
OP
Newbie
Joined: Jan 2009
Posts: 34
|
Correct Exhaust: Right Turn (Incorrect Exhaust) Left Turn (Incorrect Exhaust) Reverse (Wrong Exhaust) (I know the exhaust "drift" is inverse what it should be for an atmospheric environment, but that doesn't matter. I want no drift.)
Last edited by DrunkenPirate; 01/25/09 22:57.
|
|
|
Re: Particles in Lite-C that actually works.
[Re: DrunkenPirate]
#248311
01/25/09 23:06
01/25/09 23:06
|
Joined: May 2008
Posts: 331 Lithuania, Vilnius
Jaxas
Senior Member
|
Senior Member
Joined: May 2008
Posts: 331
Lithuania, Vilnius
|
I'm not very sure,but i think this should work: function effect_smokes(PARTICLE *p) { p.red = 100; p.blue = 100; p.green = 100; var temp[3]; vec_for_angle(temp,ship.pan); vec_randomize(temp,3); vec_add (p.vel_x, temp); p.alpha = 50 + random(25); p.size = 30; p.bmap = rauch2_farbe6; p.flags |= (MOVE); p.event = part_alphafade; // change to a shorter, faster function }
or
function effect_smokes(PARTICLE *p) { p.red = 100; p.blue = 100; p.green = 100; var temp[3]; vec_randomize(temp,3); vec_add (p.vel_x, temp); vec_for_angle(p.vel_x,ship.pan); p.alpha = 50 + random(25); p.size = 30; p.bmap = rauch2_farbe6; p.flags |= (MOVE); p.event = part_alphafade; // change to a shorter, faster function }
The smaller the bug, the harder it is to kill. _________________________________________ Forklift DEMO (3dgs)
|
|
|
|