Sign in to follow this  
Redline

Particles, Emitters and Transformations

Recommended Posts

Hi there. I'm currently working on a particle system and have got a lot of the functionality implemented that I'd like, however there's something else I've been looking into that'd I'd appreciate some advice on. I'd like to be able to have the ability to position the particles based on the orientation of the emitter itself. I figure this would be good for spell effects or holograms or just generally anything that needs to be oriented about the emitter itself. :D I figure I'd have to orient each particle manually with respect to the emitters orientation, so (as I am using DX) I was looking into D3DXVec3TransformCoord to orient the particle position. I've tried a few things, but don't seem to be getting the results I require. I've tried taking the rotation of the emitter and applying it to each individual particle, which works fine unless I try to apply the position of the particle in the calculation (i.e, the particles will orbit the Y axis following the orientation of the base emitter). I figured I could just create a rotation matrix (D3DXMatrixRotationYawPitchRoll) and apply that along with the translation of the particle (based on it's current position from the particle class) along with it. That however just caused the particles or fly around all over the place. :) So, from this does anyone have an idea about what I am doing wrong or a better way to do this? I am trying to approach this like it's basically just another hierarchy but I seem to be missing something! I'm pretty sure that my mind is simply thinking of this problem the wrong 'way'. Thanks for reading. :)

Share this post


Link to post
Share on other sites
Hi python_regious.

No, I have that part done (using similar method to Dunlops billboarding style). This is to actually orient the particles around the emitter itself.

i.e The emitter could be at (-5.0, 6.0, 3.0) and it rotates 45 degrees around it's Z-axis and all the particles rotate with it, while still moving as required by their velocity but with respect to the emitters local orientation.

Kind of like a hologram that is being emitted out of a point. :)

Share this post


Link to post
Share on other sites
I use a scene graph with a ParticleSystemNode type which pretty much covers what you're trying to do. In theory, I store the world matrix, set it back to Identity, translate and apply my emitter's rotation to the new world matrix then draw the particles from the emitter. Restore the original matrix afterwards and continue rendering the scene. Note that the particle's positions have to be stored in local (to the emitter) co-ordinates.

Share this post


Link to post
Share on other sites
Hi evolutional.

Yeah, I tried that one, but it has the curious side-effect of breaking the billboarding, it transforms the passed in quads so they will (at some point) face away completely from the camera. At lesser rotations, they can appear distorted.

I'm using a dynamic vertex buffer and updating the positions of the particles manually through the particles update function (which the mitter calls) and then the emitter (during it's render pass) calcs the six vertex positions from that position according to the size of the particle.

Drawing the particles with the emitters transformation set as the world matrix causes the billboarding to 'break'.

Share this post


Link to post
Share on other sites
Howdy ShadowDancer,

Hmm, all of my particles are pushed into the vertex buffer during a single frame, then I call DrawPrimitive on that vertex buffer in the same frame to render all them all. Setting the world matrix to that of my emitter only causes them to be transformed by the GFX card, and hence de-billboardified. :)

However, I'll keep looking into it, I get the feeling I'm missing something obvious. :P

Share this post


Link to post
Share on other sites
If I understand you correctly, this is how you would get your desired result:

Say your emiter is described as a position vector and a orientation matrix (or a orientation vector, but then you would have to build the orientation matrix from it), and say that your particles are described by a position vector relative to the emitter (I guess your problem is that your particle's position vector is in world-space, not in emitter-space). At rendering you would have to:

1. Transform the particles by the emitter's orientation matrix with D3DXVec3TransformCoord

2. Translate the particles by the emitter's position vector (particle_pos += emitter_pos)

3. Render

BTW, if you don't want to use emitter-space particles but world-space then before step 1. substract the position of the emitter from the particle (particle_pos -= emitter_pos)

Sorry about my bad english :)

Share this post


Link to post
Share on other sites
Hi Krun.

I worked it out. Actually, I worked out that the problem with the transformation had virtually nothing to do with my math, the problems actually existed in other parts of the code, due to an implmentation phase that consisted of little more than on-the-fly implementation of my emitter update code. :P

Thanks.

P.S Your English is looking pretty damn good! :)

Share this post


Link to post
Share on other sites
assuming:

1. particles are given a velocity and direction
2. only force acting on them is gravity, which would create the standard arcing or fountain-like effect

I would think that all you have to do is adjust the particles direction vector to match the emitter and adjust the gravity direction vector.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this