Game Development Community

Camera Rotations

by uiuc (#0004) · in Torque Game Engine · 04/20/2005 (3:14 pm) · 3 replies

I have a key set to toggle between the player view and a camera view. I want the camera to be in a set location and face a set direction. The location was easy to specify, just changing camera.position. However, changing camera.rotation does not work. The camera always spawns facing the same direction. I was wondering if there is an easy way to say that I want the camera rotated by, say, 90 degrees around the z axis when it spawns. I've seen some code using quaternions, but that was complex and I couldn't get it to work. I was hoping there is an easier way. Thanks!

#1
04/20/2005 (7:37 pm)
Hey what's up Pat!

The camera doesn't have a rotation member as far as I know.

Do you know how to set transform by rotating? The specifics are on my page, but it's

(for transforms)
xpos SPC ypos SPC zpos SPS xaxis SPC yaxis SPC zaxis SPC rotation

where the rotatation is in radians

So for example to rotate a camera by 90 degrees and have the camera at 0,0,0 you'd say

camera.setTransform("0 0 0 0 0 1 0.785")

Did I answer the right question?
#2
04/20/2005 (7:45 pm)
%trans = %camera.getPosition() SPC "0 0 1 90";

%camera.setTransform(%trans);
#3
04/20/2005 (9:24 pm)
That works, thanks for the help guys. Camera does have a rotation member, but it seems you can't set it the same way as the position. Also, the rotation being in radians is correct.