Esempio n. 1
0
mat4 Camera::getViewMatrixInverse() const {
    updateVM();
    mat4 inv;
    if (viewMatrix_.invert(inv))
        return inv;
    else
        return mat4::identity;
}
Esempio n. 2
0
 // This is called to set up the Camera-View
 void Camera::look(float windowRatio) {
   MatStack.matrixMode(MatrixStack::PROJECTION);
   MatStack.loadIdentity();
   updateFrustum();
   MatStack.loadMatrix(getFrustumMatrix(windowRatio));
   MatStack.matrixMode(MatrixStack::MODELVIEW);
   MatStack.loadIdentity();
   updateVM();
   MatStack.loadMatrix(viewMatrix_);
 }
Esempio n. 3
0
// This is called to set up the Camera-View
void Camera::look() {
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    updateFrustum();
    loadMatrix(getFrustumMatrix());
    //getProjectionMatrix();
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    updateVM();
    loadMatrix(viewMatrix_);
}
Esempio n. 4
0
  void Camera::setViewMatrix(const mat4& mvMat) {
    mat4 inv = glm::inverse(mvMat);
    // preserve the focallength
    float focallength = glm::length(focus_ - position_);

    // calculate world-coordinates
    vec4 pos = (inv * vec4(0.f, 0.f, 0.f, 1.f));
    vec4 look = (inv * vec4(0.f, 0.f, -1.f, 0.f));
    vec4 focus = pos + focallength * look;
    vec4 up = (inv * vec4(0.f, 1.f, 0.f, 0.f));

    positionCamera(pos.xyz(), focus.xyz(), up.xyz());

    updateVM();
  }
Esempio n. 5
0
mat4 Camera::getViewMatrix() const {
    updateVM();
    return viewMatrix_;
}
Esempio n. 6
0
mat4 Camera::getRotateMatrix() const {
    updateVM();
    return viewMatrix_.getRotationalPart();
}
Esempio n. 7
0
 mat4 Camera::getViewMatrixInverse() const {
   updateVM();
   return glm::inverse(viewMatrix_);
 }