I am having some success aligning a particle to a direction and then rotating it along its axis. At the moment I am just constantly rotating it. How do I calculate the correct rotation so it always faces the camera?

Please have a look at this video: Quad Slowly Rotating Along Axis

I am using DPSF. I have modified the "FlyingSparks" demo.

To calculate the orientation Quaternion I run this code:

private void UpdateOrientation(DefaultTextureQuadTextureCoordinatesParticle cparticle, float felapsedtimeinseconds) { var normalized = cparticle.Velocity; normalized.Normalize(); cparticle.Orientation = Quaternion.Identity; cparticle.Right = -normalized; _rotation += 0.03f; cparticle.Orientation = Quaternion.CreateFromAxisAngle(normalized, _rotation) * cparticle.Orientation; }

After some trial and error the above code produces what you see in the video.

Line 5: resets the orientation.

Line 6: aligns the quad to the velocity direction.

Line 7: increments the rotation.

Line 8: further rotates the quad along its axis by the rotation.

What I am asking is how do I calculate the rotation?

I am not a maths expert. I can guess that I need the normal of the particle, calculated within line 6 and then use that to determine it's difference from the camera direction. I have looked at some billboarding techniques but they don't offer exactly what I want.

I am very close to finishing my game and this is the last hurdle, any help or pointers would be greatly appreciated, thank you for taking the time to look at this