Originally Posted by
Colin
the rotation variable is already a vector ?
no it's not=) you just store the angles it in a vector format that's it. what you need to do is convert these angles into a 3d direction vector.
ok, here's how you do it:
Code:
var
Dir: TD3DXVector3;
sh, ch, sv, cv: Single;
...
SinCos(rotation.x, sh, ch);
SinCos(rotation.y, sv, cv);
Dir.x := ch * cv; Dir.y := sv; Dir.z := sh * cv;
then you find the "diff" vector just as you do now.
interpolate between the Dir and diff vector (Dir is the old camera direction, diff is the new camera direction).
so you might want to do something like this:
Code:
Dir.x := Dir.x + (diff.x - Dir.x) * tween;
Dir.y := Dir.y + (diff.y - Dir.y) * tween;
Dir.z := Dir.z + (diff.z - Dir.z) * tween;
D3DXVec3Normalize(Dir, Dir);
and finally convert the Dir vector to rotation angles. I don't know why you are using a 3d vector for rotation
angles, but here it is:
Code:
rotation := D3DXVector3(
arctan2(Dir.z, Dir.x),
arcsin(Dir.y),
0
);
overall this approach should work fine. however, there is still a more consistent and reliable way of spherically interpolating quaternions instead of vectors,
but that is a tale for another time.
Bookmarks