It could be due to gimbal lock.
It could be due to gimbal lock.
I was reading about this a few hours ago and I think you may be right, so I think I will add in some quaternion routines and see if I can solve it. Thanks
Download the Ziron Assembler
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Glad you got it solved, although not by my tip This is how the function ended up to:
Didn't test yet, but i realized that normalized vectors, when their length is multiplied is 1. That leaves it with just dot product.Code:function Angle(v1, v2: TVector): single; begin norm(v1.x, v1.y, v1.z); norm(v2.x, v2.y, v2.z); result:=arccos(dot(v1, v2)); end;
what I suggest you do if you want to achieve smooth camera tranitions is interpolate direction vectors. or even better - spherically interpolate rotation quaternions.Code:rV := D3DXVector3( arctan2(diff.z, diff.x), arcsin(diff.y), diff.z //why do you need this? ); D3DXVec3Lerp(rotation, rV, rotation, 0.1); // interpolating angles is almost never a good idea, I would bet that whatever trouble you are having is probably caused by this. gimbal lock is a fairly rare phenomenon in 3d graphics and doesn't happen consistently, especially not in your case.
That sounds good, but I seem to be having a lot of problems trying to incorporate this into my camera class, could you give some example? I appreciate the help. Thanks
I have made some changes and changed the lerp call to some linear interpolation which is working very smoothly and looks fantastic, i will post the code tomorrow when i'm able.
Last edited by Colin; 16-11-2012 at 10:20 PM.
Download the Ziron Assembler
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
well first of all remove the interpolation and make sure everything is working like this:
rotation := rV;
Bookmarks