void lookAt( float x1, float y1, float z1 )
{
VectorR3 v( x1, y1, z1 );
v.x = m_position.x - v.x;
v.y = m_position.y - v.y;
v.z = m_position.z - v.z;
float r = v.length();
float yaw = acos( v.z / r );
float pitch = atan2( v.y, v.x );
setRotation( yaw, pitch, 0.0f, true ); // This just wraps the values to ensure they stay within range
}
LookAt() functionality for FPS (Euler Angle) Camera
I have a FPS style camera that accumulates Euler angles, and works well. But now I want to implement a lookAt( Vector ) method which will take in a vector, and then calculate an absolute rotation in Euler Angles to aim the camera at that point in space.
This is what I have so far:
Bbuutt... things aren't working. This is Cartesian Coordinate to Spherical coordinate conversion, or at least it's suppose to be. Does anything jump out as majorly wrong here?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement