Particle system woes

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
qwe
Posts: 112
Joined: Sun Dec 28, 2003 12:54 am
Location: Oregon, USA

Particle system woes

Post by qwe »

how do you move a particle emitter without moving the whole system? What I would like is a particle emitter attached to a moving object, but when you attach the whole system(as a child) the particles that are already there move with the object, when they should just continue as they are...

any suggestions?
keless_guest

Post by keless_guest »

well, mathematically speaking, if you add to your particles the opposite of the offset of the origin of the emitter-- they'll end up in their original positions.

i havent used PE in IrrLicht yet, so i dont know if/how you could do that.
qwe
Posts: 112
Joined: Sun Dec 28, 2003 12:54 am
Location: Oregon, USA

Post by qwe »

yeah, but they're moving, and i don't think the individual particles can be accessed; you can only control the particle system node. :P
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

well, if you modify the controller (which is what sets all of their positions) that will be able to add this vector.

It does not matter if they are moving-- this will not affect their normal behavior because you will only add to their position, not their velocity.

EX:
a particle emitter creates a particle 'A' at (0,0,0) with velocity (10,0,0)

the particle emitter is attached to an object moving (0,0,10)

next frame the particle 'A' would have been shifted up to (0,0,10)+(10,0,0) because of its emitter's new position and its velocity.

But we dont want that, we just want it to be at (10,0,0) right? So, we have the controller add the negative of the emitter's velocity to it: its new position would be (0,0,10)+(10,0,0)-(0,0,10) = (10,0,0)

get it?

of course, if you're able to add the negative of this velocity from somewhere, perhaps you can just not add the value. (which would be less computationally expensive-- we are talking about particles here after all). as I said, I dont know IrrLicht particle systems. It would be good if someone who did could chime in here.
a screen cap is worth 0x100000 DWORDS
qwe
Posts: 112
Joined: Sun Dec 28, 2003 12:54 am
Location: Oregon, USA

Post by qwe »

keless wrote: But we dont want that, we just want it to be at (10,0,0) right? So, we have the controller add the negative of the emitter's velocity to it: its new position would be (0,0,10)+(10,0,0)-(0,0,10) = (10,0,0)
but I don't think you can control particles individually from the system. And the emitter isn't in the scene node hierarchy, it's derived directly from IUnknown.
Maybe I could modify it to spit out billboards, but that many scene nodes would take up a lot of processor power. :P
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

again, I dont know how Irrlicht exactly implements this -- dont currently have time to thuroughly investigate either -- but the general idea behind a particle system is:
A) some points
B) a controller which creates and updates the position of those points based on a forumla/algorithm

that controller is in charge of constantly updating the positions of ALL the points EVERY update. so, simply hijack this controller, and make it add the emitter's velocity to ALL of the points EVERY update, in addition to how its already modifying their positions

its important to note, however, that you need to do things in this order:
1) update all points (including adding the negative of the emitter's velocity)
2) create new points

otherwise, all of your new points will be shifted by the emitters velocity immediately upon entry, and your system will look wrong.

its not a matter of procesor power, because we're simply modifying how the controller updates these positions every update, not adding a new routine. if the processor could handle a particle system in the first place (as most can), this will have no impact.
a screen cap is worth 0x100000 DWORDS
Post Reply