as3 3D camera lookat

Posted by Johannes Jensen on Game Development See other posts from Game Development or by Johannes Jensen
Published on 2012-07-05T07:38:04Z Indexed on 2012/07/05 9:23 UTC
Read the original article Hit count: 420

Filed under:
|
|
|

I'm making a 3D camera scene in Flash, draw using drawTriangles() and rotated and translated using a Matrix3D. I've got the camera to look after a specific point, but only on the Y-axis, using the x and z coordinates, here is my code so far:

var dx:Number = camera.x - lookAt.x;
var dy:Number = camera.y - lookAt.y;
var dz:Number = camera.z - lookAt.z;

camera.rotationY = Math.atan2(dz, dx) * (180 / Math.PI) + 270;

so no matter the x or z position, the point is always on the mid of the screen, IF and only if y matches with the camera. So what I need is to calculate the rotationX (which are measured in degrees not radians), and I was wondering how I would do this?

© Game Development or respective owner

Related posts about 3d

Related posts about math