Particle Problems

BlitzMax Forums/BlitzMax Beginners Area/Particle Problems

Matt McFarland(Posted 2005) [#1]
Two concepts I only know of and am disatisfied.

Concept one: Each particle moves by X and Y, even if X and Y change by one pixel per frame, the particles are moving too fast or to "uniform"

Concept two: sin/cos and rotation. Each particle is rotated and then moves "forward", this has a better look but I cannot figure out how to add gravity to them because sin/cos is hard to apply an extra vector.

Scott Shaver's Tutorials: They're not tutorials they're demos and they use math I do not understand therefore I cannot comprehend his code. I need more guidance and handholding to comprehend it and examples arent getting me to enlightenment.

Does anyone know of any good particle tutorials for even C++ or something that just goes over the math in a step-by-step process? I'm really having a hard time learning how to make good particle effects and I spent all night last night coding crummy ones. Perhaps anything that you may have read that gave you enlightenment? Is there anything out there that you think may give a particle-newbie but fair coder enlightenment?


LarsG(Posted 2005) [#2]
about the X and Y's moving too fast.. use float values, and use smaller speed steps.. (this will also often solve "jerkiness").

regarding the Sin/Cos values.. just subract (or add) a given gravity constant from the y value *after* you have calculated the new speed vectors (or coords, whatever you use).
(well.. it's the simple way anyway...)


[edit] I'm sure there are some "tutorials" on the subject, but I don't have any links handy.. maybe someone else has one [/edit]


tonyg(Posted 2005) [#3]
Use floats for the X,Y values.
After applying the sin/cos add a value to your yspeed (i.e. +0.2


Matt McFarland(Posted 2005) [#4]
http://www.wondertouch.com/se_info.asp

Is there anything like this that exports raw data?

I tried floats with X,Y and it didnt solve the problem, in fact, it wouldn't move unless X = 1 or -1, so if X was say .5 it wouldn't move. I dont know why either because I did set X and Y to be as floats, but the sprite wouldn't moev at all unless X was a solid number. I was getting very frustrated with it!!!! :S

cos/sin I will try the Y speed thing, thanks.


tonyg(Posted 2005) [#5]
Have you got any code to show?
The firepaint demo has float positioned, gravity including particles.


Tom Darby(Posted 2005) [#6]
Matt,

When you're using floats, make sure you're adjusting them with floats, as well. That is,

i = 0.5    ' i is an integer, and will round 0.5 to an integer value
x# = x# + i


is not the same as

i# = 0.5
x# = x# + i#



Matt McFarland(Posted 2005) [#7]
Global i:float

i=0.5


isn't that a float because it is declared a float?


tonyg(Posted 2005) [#8]
Yes, but without seeing any code people can only make suggestions.
btw, there are B3D Particle Editors (CandyStore for Particle Candy) but none that I know of for Bmax yet.
ParticleDreams was to have an editor when the GUI mode was released but I'm not sure what's happening with it.
ParticleSky going to get one?


Scott Shaver(Posted 2005) [#9]

Scott Shaver's Tutorials: They're not tutorials they're demos and they use math I do not understand therefore I cannot comprehend his code. I need more guidance and handholding to comprehend it and examples arent getting me to enlightenment.



If you can tell me which one you are looking at and show me what part of the code you don't understand I may be able to help. That code is very messy.


Tom Darby(Posted 2005) [#10]
Matt,

It's still a good idea to explicitly mark floats in your code as floats to help avoid forehead-smackers:

Global i:float

i#=0.5


is better than

Global i:float

i=0.5


I reiterate this because if 0.5 isn't moving things along but 1.0 is, I'm about 85% certain that the root of the problem is that the 0.5 is being converted to an integer at some point in your calculations, probably by performing arithmetic against an integer.


Matt McFarland(Posted 2005) [#11]
Thank you Tom, you have solved my problem ;)


Tom Darby(Posted 2005) [#12]
Great! (If only float/int operations would convert to float instead of int...)


Steve Elliott(Posted 2006) [#13]
I'd like to ask the same question so I won't start a new thread.

I also had a look at Scott's code and it looked kinda scaring so I left none the wiser.

I've written particle effects in BlitzPlus - see Invasion Force Turbo at my website. But these don't use the much better techniques that can be used in BlitzMax - and I only used them for explosions.

The type of particle effect I'm after is a jet exhaust type effect (as used by a spaceship). I guess Lightblend would be used, but I'm not really sure how to tackle the problem, and yes I've searched the web.

Any code would be appreciated to get me started (with comments please).


tonyg(Posted 2006) [#14]
Does this help...
Particle tutorial


Steve Elliott(Posted 2006) [#15]
I looked at that - but it just resembles what I produced in BlitzPlus. It doesn't seem to use the more advanced techniques that BlitzMax offers - lightblend and such.

I'd like to produce the kind of particle effects seen in modern games these days - rather than oldschool Virus/Zarch particle effects.


tonyg(Posted 2006) [#16]
I would probably add an alpha value field to the TSpark and maybe a blend mode.
If you're looking for fully fledged particle systems then you might want to look for ParticleDreams and ParticleSky.
'Special Effects Game Programming with DirectX' has a great section on Particle Engines and can be bought quite cheap.
If you're simply after code the ZombieBlast sample might help although it's not commented.


Grey Alien(Posted 2006) [#17]
Steve: You've got my framework, that's got a particle engine. You just setup the dx and dy params and Move() should make them move in the correct direction. Or you override the Move() and do you own. It's possible to do lots with the particle type and list in my framework (you'll see when my latest game is out (any day now)).


Steve Elliott(Posted 2006) [#18]
Tony, thanks I'll take a look at the ZombieBlast game.

LOL - I should take a look at your code then Grey! I'm only using the frame compensation module, mixed with my own code. To be honest I didn't know it was so sophisticated.


Steve Elliott(Posted 2006) [#19]
Oh I get it now! Being a bit slow there - just seemed more complicated than first thought.

Guess I won't be using your Framework for this either Grey. However, it was worth buying for the Frame Compensation Module alone - everything runs silky smooth.

A basic example is to draw a grey scale sphere which gets tinted to the colour you require. Drawing using Lightblend Mode, scaling up if required and fading using alpha.