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:
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
The camera *looks* down Z, and the X/Y axes are left/right and up/down respectively. Given the width & height of your quad, you can compute the points directly:
I'll try to see if I can use your method to edit the vertices directly, but it looks a little like the function it calls is doing as you suggest anyway.