Пример #1
0
/*****[ 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
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;
}
Пример #3
0
Math::Transform Camera::PerspectiveTransform(double aFov, double n, double f, uint32_t xDim, uint32_t yDim){
    double x = xDim;
    double y = yDim;
    // Normalized screen dimensions
    double aspectRatio = y / x;

    Math::Transform s = Math::Transform::Scaling(2./x, -2./y, 1.);
    s *= Math::Transform::Scaling(1., aspectRatio, 1.);
    s *= Math::Transform::Translation(-x/2., -y/2., 0);

    // Perspective transform
    double scale = 1. / tan(M_PI*aFov/180./2.);
    Math::Transform pers = Math::Transform::Scaling(scale, scale, 1.);

    double m = f / (f - n);
    Eigen::Matrix4d t;
    t << 1,   0,   0,   0,
         0,   1,   0,   0,
         0,   0,   m,-n*m,
         0,   0,   1,   0;
    pers *= Math::Transform(t);

    return pers.Inverse() * s;
}
Пример #4
0
void MatrixStack::push(const math::Transform& transform){
	glm::mat4x4 m;
	transform.getMatrix(m);
	push(m);
}
Пример #5
0
void MatrixStack::pushAndConcat(const math::Transform& transform){
	glm::mat4x4 t;
	transform.getMatrix(t);

	pushAndConcat(t);
}
Пример #6
0
 Shape::Shape(const math::Transform &transform) :
   mImpl(new Impl) {
     mImpl->o2w = transform;
     mImpl->w2o = transform.inverse();
 }