Particle trails

Moderator
Posts: 133
Joined: 2008.05
Post: #1
I want to add particle trails to my particle engine. Right now, I have it so you can specify the length, size difference, lag between and whether the particle trail size is exponential or constant. I made this up without knowing anything about particle trails because I figured it'd work out, and it does look pretty cool, I'm worried about the speed and I'm also worried if this is a technique that is actually used. Let me explain.

I loop through to draw each particle, inside each particle's draw routine I do another loop that is length long. Inside this loop, I draw another particle based on the other variables. First, I take the position the main particle is at, each time I go through the secondary loop, I subtract the velocity of the particle * the lag difference, which is a small fraction of a second. If the system has exponential trails, I divide the size by the size difference each time through, if it has constant trails, I only divide by the size difference once. So a constant trail with a size difference of one is just one streak that is the same size, and an exponential trail with a size difference of 1.1 or so, slowly tapers off. If you use a bigger size difference and a white color, it looks like a sperm. Smile

Here are my issues: 1. It's O(n^2), obviously, and that is usually not a good thing. If I get up to a couple thousand particles, it slows down to 20 fps, which is not fast, considering other things can and will be going on anytime I would use it in a game. Also, the particle trails are always straight, since I'm just using a linear calculation with the velocity. I could maybe add some acceleration in there to get some twisting, but maybe there is another way.

Like I said, I just made this up, so there's no way it's the correct way of doing it. Maybe someone has a tutorial somewhere I could look at, or has done this themselves and can fill me in. THanks.

edit: To see what I'm talking about, download the app: https://mywebspace.wisc.edu/josephconway...Writer.dmg
Click randomize so you don't have to finangle with all the other variables, then set trail size to 10, size difference to 1, and trail lag to .02. (requires gcc 4.0)
Quote this message in a reply
Member
Posts: 320
Joined: 2003.06
Post: #2
Looks to me like you're calling what essentially is a particle emitter a particle, which could do with changing just for clarification's sake.

Other than that, what you're doing sounds reasonable. A couple of thousand blended quads is always gonna slow things down a bit, and how many variables you add to your particles is really up to you. Assigning each particle (not emitter Wink) random velocity and acceleration vectors will do interesting things. I make tire dust in my car game by giving particles some of the emitter's velocity, and some of their own. I give them random growth rates, growth accelleration rates and initial sizes and rotations.

Have a look at keiths code: http://www.onesadcookie.com/svn/repos/Particles/ for a fast way to draw lots of billboarded quads.

David

Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #3
app would quit immediately on opening, no useful information:

Host Name: Antise
Date/Time: 2005-06-28 19:28:01.428 -0500
OS Version: 10.4.1 (Build 8B15)
Report Version: 3

Command: Particles
Path: /Volumes/Particle Writer/Particles.app/Contents/MacOS/Particles
Parent: WindowServer [81]

Version: ??? (1.0)

PID: 14236
Thread: 0

Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000000

Thread 0 Crashed:
0 <<00000000>> 0x00000000 0 + 0
1 com.apple.myCarbonApp 0x00001f6c start + 60
Quote this message in a reply
Moderator
Posts: 771
Joined: 2003.04
Post: #4
Running it from the Terminal shows the culprit:
Code:
./Particles
ZeroLink: could not load .o file: /Users/joeconway/Particles/build/Particles.build/Development/Particles.build/Objects-normal/ppc/xcamera.ob
ZeroLink: could not load .o file: /Users/joeconway/Particles/build/Particles.build/Development/Particles.build/Objects-normal/ppc/GeneralTools.ob
ZeroLink: could not load .o file: /Users/joeconway/Particles/build/Particles.build/Development/Particles.build/Objects-normal/ppc/main.ob
ZeroLink: could not load .o file: /Users/joeconway/Particles/build/Particles.build/Development/Particles.build/Objects-normal/ppc/particlewriter.ob
ZeroLink: could not load .o file: /Users/joeconway/Particles/build/Particles.build/Development/Particles.build/Objects-normal/ppc/Particles.ob
ZeroLink: could not load .o file: /Users/joeconway/Particles/build/Particles.build/Development/Particles.build/Objects-normal/ppc/varparticle.ob
ZeroLink: could not load .o file: /Users/joeconway/Particles/build/Particles.build/Development/Particles.build/Objects-normal/ppc/logger.ob
ZeroLink: could not load .o file: /Users/joeconway/Particles/build/Particles.build/Development/Particles.build/Objects-normal/ppc/aglString.ob
ZeroLink: could not load .o file: /Users/joeconway/Particles/build/Particles.build/Development/Particles.build/Objects-normal/ppc/tabview.ob
ZeroLink: unknown symbol '_main'
Abort trap


Perhaps Disk Utility should warn every developer with a "Hey, you seem to be trying to make a dmg out of a ZeroLink-ed app..." message. Blush
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #5
i could have ssworei i put it on deployment mode. i nynway i amd runk amdn iwlll fix that
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #6
i fixedad it, i must have hit the wong hign but i problasbly hit it right this time. ou guys love dirnkning
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #7
dusireagarging my hangover tomorrow ou hhould open this file with that program

https://mywebspace.wisc.edu/josephconway/wow

i dontknow why but it is reall fiuny tow watch

ps if ou change th eesintsdation to gloneminusdstalpha it look lsike cooze. man, this ishsit it nuts

pps look how good i typed th deinsation blnd fucn
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Particle Engine bronxbomber92 9 3,766 Oct 16, 2006 03:44 PM
Last Post: bronxbomber92
  Particle trails with OpenGL mars 19 8,681 Dec 12, 2003 08:02 AM
Last Post: deekpyro