Bug (feature?): Camera doesn't interpolate rotations correctly
by Matthew Shapiro · in Torque X 2D · 03/25/2008 (7:30 pm) · 4 replies
So, create a new project and create a new T2dSceneCamera. Put a background or some image so that you can notice the direction you turn.
Now, take the new camera, set the rotation to 300. Now do Camera.AnimateRotation(5,1000);.
Notice the camera tries to rotate the long way around.
Is this intended or just an oversight?
Now, take the new camera, set the rotation to 300. Now do Camera.AnimateRotation(5,1000);.
Notice the camera tries to rotate the long way around.
Is this intended or just an oversight?
#2
03/25/2008 (8:51 pm)
Well wouldn't it be better for the engine to figure out the shortest rotation path? Otherwise every time you want to animate the camera's rotation you have to manually figure out which way you need to go, instead of leaving it up to the engine.
#3
Try Camera.AnimateRotation(365,1000), this will rotate the 'correct' direction.
Of course you still have to figure out which is the correct direction first, AFAIK there is no engine method for this.
03/26/2008 (1:25 pm)
Matt,Try Camera.AnimateRotation(365,1000), this will rotate the 'correct' direction.
Of course you still have to figure out which is the correct direction first, AFAIK there is no engine method for this.
bool isDestLarger = (TargetRotation > Camera.Rotation) ? true:false;
if (isDestLarger)
ModifiedTargetRotation = (Math.Abs(TargetRotation - Camera.Rotation) > 180f) ? TargetRotation - (360f + Camera.Rotation) : TargetRotation;
else
ModifiedTargetRotation = (Math.Abs(TargetRotation - Camera.Rotation) > 180f) ? 360f + TargetRotation : TargetRotation;
Camera.AnimateRotation(ModifiedTargetRotation,1000);I haven't tested this code so I make no guarantees :)
Associate John Kanalakis
EnvyGames
John K.