Particle trails with OpenGL

Member
Posts: 31
Joined: 2004.09
Post: #1
Hi all,

does anyone have some working code, or a link to a tutorial, for how to put together linked particle trails?

The particles side of thing is easy. What I want to do now is have stretched particles joined to other particles, seamlessly. I can do the particles and lists of them, but I'm not sure how to go about creating joined stretched particles.

Any ideas?

thanks.
Quote this message in a reply
Member
Posts: 156
Joined: 2002.11
Post: #2
With quadstrips that face the camera (billboarding) or not, I would guess.
Quote this message in a reply
BobimusPrime
Unregistered
 
Post: #3
By particle trail do you mean a 3D path that has width? Like, would it have a source (the particle's current location) and a path back to where the particle was before?

If the program you are working on is in 2D this shouldn't be too hard to do. You would probably want to use a quad strip for this and I can go into more detail if you'd like.

If the program you are working on is in 3D with perspective it becomes a little bit more complicated. The billboarding calculations for the individual line segments end up not connecting to each other and you need to do some averaging. If this is what you are trying to do I can put together an explanation for you. I had to figure it out when writing my uDevGame entry for this year Smile.

Robert
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #4
Quote:Originally posted by BobimusPrime
...If the program you are working on is in 3D with perspective it becomes a little bit more complicated. The billboarding calculations for the individual line segments end up not connecting to each other and you need to do some averaging. If this is what you are trying to do I can put together an explanation for you. I had to figure it out when writing my uDevGame entry for this year Smile.

Robert


What averaging? All billboards look in the same direction, they are co-planar with the screen.

I am not quite getting what this joined-particle trail is supposed to be. Do you want to connect the particles to form a line, basically? Can anyone explain?
Quote this message in a reply
Member
Posts: 353
Joined: 2002.04
Post: #5
How about a screenshot of it in an existing game to help us understand the effect?
Quote this message in a reply
Member
Posts: 31
Joined: 2004.09
Post: #6
Sorry, I should have been a bit clearer.

here is a picture, from this morning's news, of Brian Greenstone's new game Nanosaur 2.

Nanosaur 2 contrails

The effect I'm looking for is similar to those white contrails that are emitting from the wing tips of the Pterodactyl.

Oh, and this is for a 2D game, using OGL.

Thanks for your help.
Quote this message in a reply
deekpyro
Unregistered
 
Post: #7
I'm thinking about doing something similar in 3D, I REALLY like how trails were done in Homeworld 2 and recreating a similar effect could be an interesting experience, thanks!

great example:

[Image: screen_3.jpg]

-Derek
Quote this message in a reply
deekpyro
Unregistered
 
Post: #8
also see:

[Image: screen_8.jpg]
Quote this message in a reply
Member
Posts: 353
Joined: 2002.04
Post: #9
The board trails in Slope Rider:
http://www.isp.net.au/~monteboyd/images/sr_shot5.jpg

is a quad strip which simply places the front most vertices at the center of the board, then each side-by-side vertex set going back are updated to what the ones in front of them were in the previous frame. Does that make any sense?
Quote this message in a reply
BobimusPrime
Unregistered
 
Post: #10
mars:
I was in a weird mood so I wrote out a tutorial with pictures that explains how to draw the particle trails. Hopefully it doesn't make things even more confusing Smile.

http://www.bobbosoft.com/2dpath.html


deekpyro:
Doing the trails in 3D is a quite a bit more complicated but I can write out an explanation for you if you want.

Hope this helps!

Robert
Quote this message in a reply
Member
Posts: 269
Joined: 2005.04
Post: #11
Man have I been waiting for this thread. I've been trying to figure this very question out for the past few days.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #12
mars: Once you start coding this, if you follow the outline BobimusPrime gave (which I think is an accurate way to do what you want in 2D), you will find that most of your CPU time is going into sqrt();

To get around that, approximate the sqrt, which can be done with the PPC's frsqrte instruction and the Newton-Rhapson method. Replace:
Code:
float factor = dx*dx+dy*dy;
float normal = 1.0f/sqrt(factor);
with:
Code:
float factor = dx*dx+dy*dy;
float normal = __frsqrte(factor);                
normal *= (1.5f - (0.5f*factor * normal * normal));
You'll need to #include <ppc_intrinsics.h> and compile with -force_cpusubtype_ALL to get it to work.

This premature optimization tip brought to you by many hours of creating basic GL primitives that don't suck.
Quote this message in a reply
Member
Posts: 156
Joined: 2002.11
Post: #13
Quote:Originally posted by DoG
What averaging? All billboards look in the same direction, they are co-planar with the screen.


Nope. Billboards "face" the camera, but they are not coplanar with the screen; the quads may cross the screen plane.

The thing is that you would rotate the quads around each one's center (the pathline of the ship, for instance) so that the quads face the camera, sort of.

Now, if you want to do something similar to Homeworld, the quads don't need to be aligned to the screen; you just get two points on the tail of the ship and connect them to the last quad of the trail generated on the previous frame. It's like footprints in the sand, when you give a new step, you fade out the first footstep, and so on.
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #14
Wow, this thread is kickass! Two of the questions I wanted to figure out answered in the same thread! Bobimus, that tutorial really helped me - will it still be there in a week, or do you have to take it down eventually? (Would you like to turn it into a tutorial for iDevGames, by the way?)

Also, arekkusu, thanks for giving me a slot-in solution for my sqrts! Grin
Quote this message in a reply
Moderator
Posts: 365
Joined: 2002.04
Post: #15
Quote:Originally posted by FCCovett
Nope. Billboards "face" the camera, but they are not coplanar with the screen; the quads may cross the screen plane.

Nope. Billboards should be coplanar with the screen. If you point them directly at the camera they'll look distorted as they approach the edge of the screen. This is what you'd expect from a one-point perspective - objects which are aligned with the viewing plane look flat, objects which are not look skewed.

Trust me, I've tried it both ways! Wink

Neil Carter
Nether - Mac games and comic art
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Particle Engine bronxbomber92 9 3,761 Oct 16, 2006 03:44 PM
Last Post: bronxbomber92
  Particle trails LongJumper 6 3,280 Jun 29, 2005 12:42 AM
Last Post: LongJumper