math - Panning camera so object is at edge of screen -
I am trying to write a formula to pan the camera so that the center point of the object is just visible on the edge of the screen Therefore, in other words, if the object is right out of sight, then I will change the position of the camera's X and Y, so that the object is on the right edge of the screen (without changing the angle or Z of the camera). Can anyone point me out how to do this?
But the only way I could do this by modifying the camera height (which I really did not want to do):
// Note: Pose is the center of the object that is displayed on it // // // the map of the camera // m_position is the 3D position of the camera / / m_plane [] array of left, right, etc. Camera Fighter Zero Aircraft Camera :: Panto (Contect Vector 3D & Pauses) {int n; Vector 3D vector diamond; (N = 0; n> NUM_PLANES; n ++) {If (m_plane [n] .GetDistance (pos) <0) {m_plane [n] Normal (); Vector heroine + = M_playen [N]. Get Vector Annure (Pause); }} M_posDesire.m [IX_X] = m_position.m [IX_X] + vectorNearest.m [IX_X]; M_posDesire.m [IX_Y] = M_position.M [IX_Y] + vector diameter. M [IX_Y]; M_posDesire.m [IX_Z] = M_position.M [IX_Z] + vector nyrest.m [IX_Z]; } // This is the definition of aircraft class: class plane {public: zero generalized () {float lenewive = 1.0f / sqrtf (m_a * m_a + m_b * m_b + m_c * m_c); M_a * = lenInv; M_b * = lenInv; M_c * = lenInv; M_d * = lenInv; } Float Guest Diastans (Const Vector 3D & PS) CONST (Returns M_A * POM [IX_X] + M_B * POS. M [IX_Y] + MCM * PSM [IX_Z] + M_D; } Vector 3D gate vectorate (Const Vector 3D and Pause) const (Vector 3D Normal (M_A, M_B, MCG); Float pod dot normal = pos.dotProduct (normal); Vector 3D closest = normal * (m_d + posDotNormal); Closest return; } Float M_A, M_b, MCG, M_D; };
Comments
Post a Comment