Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
Lapsa's very own thread
by rki. 06/19/24 11:27
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 692 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Mino, squik, AemStones, LucasJoshua, Baklazhan
19061 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Particles in Lite-C that actually works. #248140
01/24/09 19:49
01/24/09 19:49
Joined: Jan 2009
Posts: 34
D
DrunkenPirate Offline OP
Newbie
DrunkenPirate  Offline OP
Newbie
D

Joined: Jan 2009
Posts: 34
Working example of particles in Lite-C? I've looked EVERYWHERE, even tried a script generating programs buts it's all WDL and C-SCRIPT.

Re: Particles in Lite-C that actually works. [Re: DrunkenPirate] #248146
01/24/09 20:20
01/24/09 20:20
Joined: May 2008
Posts: 331
Lithuania, Vilnius
Jaxas Offline
Senior Member
Jaxas  Offline
Senior Member

Joined: May 2008
Posts: 331
Lithuania, Vilnius
try EasyParticle 3 , the easiest way to create a particle in 3dgs wink


The smaller the bug, the harder it is to kill.
_________________________________________
Forklift DEMO (3dgs)
Re: Particles in Lite-C that actually works. [Re: Jaxas] #248186
01/25/09 05:46
01/25/09 05:46
Joined: May 2008
Posts: 150
Switzerland
Hitsch Offline
Member
Hitsch  Offline
Member

Joined: May 2008
Posts: 150
Switzerland
It really is a great way go generate some simple particles and then study the code.

It does generate C-Script though, but that's not that hard to translate over to Lite-C, it takes rather small changes.

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
D
DrunkenPirate Offline OP
Newbie
DrunkenPirate  Offline OP
Newbie
D

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:
Code:
function snow();
function infinity();
function effect_snowflake();
function createParticles();
BMAP* particle_map;
particle_map = bmap_create("particle.pcx");
VECTOR g_snowbox;



Code:
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 Offline
Senior Member
Jaxas  Offline
Senior Member

Joined: May 2008
Posts: 331
Lithuania, Vilnius
Here's working Lite-C example:
Code:
 

//// 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 wink

Jaxas


The smaller the bug, the harder it is to kill.
_________________________________________
Forklift DEMO (3dgs)
Re: Particles in Lite-C that actually works. [Re: Jaxas] #248211
01/25/09 12:43
01/25/09 12:43
Joined: Jan 2009
Posts: 34
D
DrunkenPirate Offline OP
Newbie
DrunkenPirate  Offline OP
Newbie
D

Joined: Jan 2009
Posts: 34
Thank you, that example works great. Now one more question:

When using particles how do I keep them coming out in one direction no matter what the pan is of the object it's attached to? E.G. I have a space ship with a particle stream coming from the left and right wings. When I turn the ship the particles don't continue to shoot straight out the back like they should, they curve around to continually shoot out at one stationary point. (I want to particles to shoot at a local (ent) set of coordinates. (ship.x+100, ship.y+100, 0))

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 Offline
Senior Member
Jaxas  Offline
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 wink


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
D
DrunkenPirate Offline OP
Newbie
DrunkenPirate  Offline OP
Newbie
D

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:

  • Location
  • Velocity


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
D
DrunkenPirate Offline OP
Newbie
DrunkenPirate  Offline OP
Newbie
D

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 Offline
Senior Member
Jaxas  Offline
Senior Member

Joined: May 2008
Posts: 331
Lithuania, Vilnius
I'm not very sure,but i think this should work:

Quote:
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)
Page 1 of 3 1 2 3

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1