Particles Rotation

Started by
11 comments, last by Medo Mex 10 years, 8 months ago

@Burnt_Fyr: That works, however...

I might need in future to set rotation for the particles, how do I set the particles rotation (pitch, yaw, roll)?

Notice: Sometimes, I could want it to face the camera vertically and set the rotation horizontally or I could want it to face the camera horizontally and set the rotation vertically.

Advertisement

You should likely brush up on your math.

You have 2 vectors that you are using to describe your particle, it's vertical axis, and it's horizontal. I will consider pitching the movement i helped you with earlier, using your vertical vector, which i will now call the particles up vector.

When you don't want any pitching, you need to constrain the particles up vector to the world up axis(0,1,0). If you want to induce pitching, you can rotate the up vector by a certain degree, along the right vector. Because your front vector is constrained to pointing at your camera, your right vector will be perpedicular to that. You can get it via the cross product of the up and front vectors.

Vec3 right = crossproduct(up, -camera.forward);

once you have this vector, you can rotate a vector(0,1,0) using AxisAngleRotation

// might be wrong on the exact functions but something like this
 
D3DXMATRIX rotationMatrix;
 
D3DXMatrixRotationAxisAngle(right, angle_in_rads, &rotationMatrix);
 
D3DXVECTOR3 up(0,1,0 );
 
D3DXVec3TransformNormal(&up, &rotationMatrix);

This up vector can now be used to create your particles. If you rotate by the opposite amount that you have pitched the camera, this up vector will be the same as your view transform's up vector.

A similar process can be done to get yawing or pitching using the correct transforms/axis. There is likely a better method to get the results you are trying to acheive, perhaps you could give us a better idea of that that is.

I will check that out.

BTW, should the rain particles always face the camera in vertically and horizontally?

I have many rain drops in the same texture, but when the player look up, the particle rotate to face the camera which make the rain drops look like they are not pointed at the ground.

This topic is closed to new replies.

Advertisement