コード例 #1
0
ファイル: Camera.cpp プロジェクト: Vince-Smith/375
/*****[ getView ]**************************************************************/
Math::Transform
Camera::getView()
{
    //Create the View
    Math::Transform view;

    // Transpose the current position of eye
    Math::Matrix3 temp_mat = m_eye.getOrientation();
    temp_mat.transpose();

    // Set views orientation to be the transpose of eye
    view.setOrientation(temp_mat);

    // Get the eye's position
    Vector3 temp_pos = m_eye.getPosition();

    // Negate it.
    temp_pos.negate();

    temp_pos = temp_mat.transform(temp_pos);

    // Set it.
    view.setPosition(temp_pos);

    return view;

}
コード例 #2
0
ファイル: Camera.cpp プロジェクト: JJWilson21/GraphicsEngine
Math::Transform
Camera::getViewMatrix ()
{		
  Math::Transform view;
  Vector3 at (m_camera.getBack ().x + m_camera.getPosition ().x, m_camera.getBack ().y + m_camera.getPosition ().y, m_camera.getBack ().z + m_camera.getPosition ().z);
  Vector3 eye (m_camera.getPosition ());
  Vector3 up (m_camera.getUp ());
  Vector3 back = eye - at;
  back.normalize ();
  Vector3 right = up.cross(back);
  right.normalize ();
  eye.negate ();
  Math::Matrix3 rotScale (right, up, back);
  rotScale.transpose ();
  view.setOrientation (rotScale);
  Vector3 translation =  rotScale * eye;
  //Vector3 translation = -eye;
  view.setPosition (translation);
  return view;
}