public void SetRotationAboutEye(double x, double y, double z) { msgMatrix matx = new msgMatrix(); msgVectorStruct LookAtPos = new msgVectorStruct(); matx.Rotate(zero_p, x_axe, x / 180.0 * Math.PI); matx.Rotate(zero_p, z_axe, -z / 180.0 * Math.PI); LookAtPos.x = 0.0; LookAtPos.y = m_fFocalLength; LookAtPos.z = 0.0; matx.ApplyMatrixToVector(zero_p, LookAtPos); m_fLookAtPos.x = m_fEyePos.x + LookAtPos.x; m_fLookAtPos.y = m_fEyePos.y + LookAtPos.y; m_fLookAtPos.z = m_fEyePos.z + LookAtPos.z; // Calculate our camera's UpVector using ONLY the 'X' (Pitch) and 'Z' (Yaw) // parameters m_fUpVector = z_axe; matx.ApplyMatrixToVector(zero_p, m_fUpVector); // Just save the 'y' value for later use when calculating the camera's 'Up' vector // prior to calling gluLookAt() m_fRoll = y; }
private void PrepareMatrix(double Ox, double Oy, double Oz, double Rx, double Ry, double Rz, double Tx, double Ty, double Tz, ref msgMatrix XForm) { XForm.Identity(); msgVectorStruct TransV = new msgVectorStruct(); TransV.x = Tx; TransV.y = Ty; TransV.z = Tz; XForm.Translate(TransV); XForm.Rotate(zero_p, x_axe, Rx); XForm.Rotate(zero_p, y_axe, Ry); XForm.Rotate(zero_p, z_axe, Rz); msgVectorStruct oV = new msgVectorStruct(); oV.x = Ox; oV.y = Oy; oV.z = Oz; XForm.Translate(oV); }
public void CalculateUpVector() { msgMatrix matx = new msgMatrix(); matx.Rotate(zero_p, x_axe, m_fPitch / 180.0 * Math.PI); matx.Rotate(zero_p, z_axe, -m_fYaw / 180.0 * Math.PI); m_fUpVector = z_axe; matx.ApplyMatrixToVector(zero_p, m_fUpVector); }
public void PositionCamera() { if (m_bResetClippingPlanes) { // Reset our cameras clipping plane ResetView(0, 0); m_bResetClippingPlanes = false; } if (m_fRoll != 0) { msgMatrix matx = new msgMatrix(); msgVectorStruct UpVector; matx.Rotate(zero_p, x_axe, m_fPitch / 180.0 * Math.PI); matx.Rotate(zero_p, y_axe, m_fRoll / 180.0 * Math.PI); matx.Rotate(zero_p, z_axe, -m_fYaw / 180.0 * Math.PI); UpVector = z_axe; matx.ApplyMatrixToVector(zero_p, UpVector); // Position the camera using the newly calculated 'Up' vector OpenGLControl.gluLookAt(m_fEyePos.x, m_fEyePos.y, m_fEyePos.z, m_fLookAtPos.x, m_fLookAtPos.y, m_fLookAtPos.z, UpVector.x, UpVector.y, UpVector.z); } else { // Since our 'Up' vector has already been calculated, all we need to do is // position the camera.. OpenGLControl.gluLookAt(m_fEyePos.x, m_fEyePos.y, m_fEyePos.z, m_fLookAtPos.x, m_fLookAtPos.y, m_fLookAtPos.z, m_fUpVector.x, m_fUpVector.y, m_fUpVector.z); } // Save the Model view matrix. This is used later for // conversion of mouse coordinates to world coordinates. OpenGLControl.glGetDoublev(OpenGLControl.GL_MODELVIEW_MATRIX, m_dModelViewMatrix); }
public void SetRotationAboutLookAt(double x, double y, double z) { msgMatrix matx = new msgMatrix(); msgVectorStruct EyePos = new msgVectorStruct(); matx.Rotate(zero_p, x_axe, x / 180.0 * Math.PI); matx.Rotate(zero_p, z_axe, -z / 180.0 * Math.PI); EyePos.x = 0.0; EyePos.y = -m_fFocalLength; EyePos.z = 0.0; matx.ApplyMatrixToVector(zero_p, EyePos); m_fEyePos.x = EyePos.x + m_fLookAtPos.x; m_fEyePos.y = EyePos.y + m_fLookAtPos.y; m_fEyePos.z = EyePos.z + m_fLookAtPos.z; // Calculate our camera's UpVector using ONLY the 'X' (Pitch) and 'Z' (Yaw) // parameters m_fUpVector = z_axe; matx.ApplyMatrixToVector(zero_p, m_fUpVector); // Just save the 'y' value for later use when calculating the camera's 'Up' vector // prior to calling gluLookAt() m_fRoll = y; }