Hi:
I try to rotate camera with animation. The camera does extra rotation when animation around angle -180 and 0 degree.
here is my code..
pAnim->setInterpolationMode (Animation::IM_SPLINE);
KeyFrame* key = pTrack->createKeyFrame(0); // startposition
key->setTranslate (pNode->getPosition ());
key->setRotation (pNode->getOrientation ());
// last frame
key = pTrack->createKeyFrame (fAnimLen);
key->setTranslate (pos);
// rotate axis = Y, angle = lookAt - pos on x-z plane
Vector3 dir = lookAt - pos;
float angle = atan2 (dir.x, dir.z) - Math::PI; // Camera point neg. z
Quaternion q (Radian (angle), Vector3::UNIT_Y);
key->setRotation (q);
My camera's up vector is the same with Y axis.
I checked the forum that this problem is supposed to be fixed, right?
I also try the following code
if (angle > Math::PI)
angle -= 2*Math::PI;
else if (angle < -Math::PI)
angle += 2*Math::PI;
But the problem only fixed partially.
Can anyone help? Thank you.
Camera roation animation problem.
-
y721
- Gremlin
- Posts: 153
- Joined: Mon Nov 08, 2004 3:15 am
- Location: Taiwan
-
PeterNewman
- Greenskin
- Posts: 128
- Joined: Mon Jun 21, 2004 2:34 am
- Location: Victoria, Australia