Game Development Community

Camera Rotation

by Daniel Fedor · in Torque X 2D · 02/20/2007 (9:43 pm) · 6 replies

Hey There,

Been fooling around with TorqueX, and having some fun. It was a bit daunting at first, with documentation still in the works and all. But once I found the Help docs under the trial TGB Editor, I was able to start making more and more sense. Looking forward to the release!

So, I was wondering if there is a preferred mechanism for rotating the T2DSceneCamera? I've been able to get it to track my user-controlled sprite via mount points:

T2DSceneCamera objCam = (T2DSceneCamera)T2DSceneGraph.Instance.Camera;
objCam.TrackMountRotation = true;
objCam.Mount(_owner, "1", true); //_owner is a T2DSceneObject that I can control

but it doesn't seem to track rotation as well. I tried setting the TrackMountRotation property to true, but no change there.

However, the camera's Position and Rotation properties both seem to update correctly. If I disable TrackMountRotation, only the Position property updates.

Directly assigning values to the Position and Rotation properties seems to correctly update said properties, but the camera does not seem to move/rotate at all. The same is true if I use SetPosition() and SetRotation(), with or without updateSpatialData set to true. Ditto for WarpToPosition().

And the Transform property appears to be read-only.

Am I going about this incorrectly?

Thanks,
Dan

About the author

Recent Threads


#1
02/20/2007 (11:49 pm)
I don't think you're going about it incorrectly. Remember, you are using open beta software and a lot of the functionality is not yet working in that version. I'm guessing your code would work in 1.0 if rotating cameras are officially supported.
#2
02/21/2007 (9:26 am)
The only properties i've heard of that are useable right now are extent (for zooming) and centerposition (for panning). Though I havn't tried extent.
#3
02/21/2007 (9:39 am)
I tried giving the camera a velocity, and it didn't work. I'm not sure what they have planned, but I'm guessing we will get more functionality out of the camera object eventually.
#4
02/22/2007 (6:33 pm)
Thanks for the replies. I had a feeling it might be intended for v1.0, and just broken in my beta. No worries, I can work around it for now.

Modern1: I'm pretty sure Extent worked. My code isn't handy right now, but I was able to get zoom-like effects by changing a Vector2 property. Not sure if I tried CenterPosition, though. The mounting seemed to solve that problem, so I didn't fool around as much with translation as I did with rotation.

Also, I'm not sure if the Velocity or other physics properties were intended to be accessible on the camera. It'd certainly be cool if they were. We've used this to handily detect 3D camera collisions against walls in other projects, to avoid occluding the main character during camera movement. But I suppose even being able to mount on a physics-enabled object amounts to pretty much the same thing. Something to play with, for sure.

Again, thanks for the input!
#5
02/22/2007 (8:16 pm)
I have also used the extent to emulate zooming. The tricky bookkeeping is to remember the original extent so you have a reference for your zoom (if that is important to you).

I'm not sure the camera will ever support things like velocity but you can mount the camera to an object! With your camera mounted to an "invisible" SceneObject you can then give the SceneObject velocity and any other properties and have the camera just follow it.
#6
02/22/2007 (8:27 pm)
I was able to add a Physics component to a camera, and it seemed to work fine. The only trick is that you can't add a component to something that's already registered, so I had to create a new one instead of using the existing default camera:
T2DSceneCamera MyCamera = T2DSceneGraph.Instance.DefaultCamera.Clone() as T2DSceneCamera;
MyCamera.Components.AddComponent(new T2DPhysicsComponent());
TorqueObjectDatabase.Instance.Register(MyCamera);
T2DSceneGraph.Instance.Camera = MyCamera;