Pivoting an object around a point
by Matthew Shapiro · in Torque X 2D · 03/24/2008 (5:07 pm) · 2 replies
Is there an easy way to pivot an object around a point without using T2dSceneObjects + linkpoints?
*edit*
aha got it
*edit*
aha got it
// Calculate angle from offset
angle = (float)Math.Atan(offset.Y / offset.X);
// Correct for negative values
if (offset.X < 0)
angle += MathHelper.Pi;
distance = offset.Length();
offset.X = (float)Math.Cos(angle + MathHelper.ToRadians(Camera.Rotation)) * distance;
offset.Y = (float)Math.Sin(angle + MathHelper.ToRadians(Camera.Rotation)) * distance;
#2
Also, if anyone cares I am working on a Camera Manager class right now. The purpose of this class is to allow advanced functions (such as following an object at an offset), queuing up camera commands (so you can do things like have the camera move along waypoints, so once it gets to the first waypoint it goes to the next, etc..), give time delayed effects (so fade the camera as you move towards a target), and manage all of these commands for multiple cameras.
I should have it released in a few days. Right now I'm writing it for 2d cameras, but (as far as I can tell) I've written it so it should be easy to add new functions as well as support 3d cameras.
03/25/2008 (8:00 pm)
Sorry, code I originally posted was old and wrong (didn't realize Math.Atan returns radians in first revision). Latest code works 100%.Also, if anyone cares I am working on a Camera Manager class right now. The purpose of this class is to allow advanced functions (such as following an object at an offset), queuing up camera commands (so you can do things like have the camera move along waypoints, so once it gets to the first waypoint it goes to the next, etc..), give time delayed effects (so fade the camera as you move towards a target), and manage all of these commands for multiple cameras.
I should have it released in a few days. Right now I'm writing it for 2d cameras, but (as far as I can tell) I've written it so it should be easy to add new functions as well as support 3d cameras.
Associate John Kanalakis
EnvyGames
John K.