void Camera::InverseLookAtMatrix( void ) { Vector rotVec = at-eye; rotVec = ( ball ? ball->ApplyTrackballMatrix( rotVec ) : rotVec ); Point finalPos = ( eyeMove ? eyeMove->ApplyCurrentFrameMovementMatrix( at-rotVec ) : at-rotVec ); Matrix4x4 m = Matrix4x4::LookAt( finalPos, at, up ).Invert(); glMultMatrixf( m.GetDataPtr() ); }
// This multiplies onto the current matrix stack an inverse look-at matrix // (equivalent to Invert( gluLookAt() ) -- if such an operation were possible) void Scene::LightLookAtInverseMatrix( int i ) { Point lightPos( light[i]->GetCurrentPos() ); Vector view = camera->GetAt()-lightPos; view.Normalize(); Vector perp = abs( view.Dot( Vector::YAxis() ) ) < 0.95 ? view.Cross( Vector::YAxis() ) : view.Cross( Vector::XAxis() ); perp.Normalize(); Vector up = perp.Cross( view ); Matrix4x4 mat = Matrix4x4::LookAt( lightPos, camera->GetAt(), up ).Invert(); glMultMatrixf( mat.GetDataPtr() ); }
void Camera::InverseLookAtMatrix( void ) { Matrix4x4 m; if (ball) { Vector rotVec = ball->ApplyTrackballMatrix( at-eye ); m = Matrix4x4::LookAt( at-rotVec, at, up ).Invert(); } else m = Matrix4x4::LookAt( eye, at, up ).Invert(); glMultMatrixf( m.GetDataPtr() ); }
void Scene::LightPerspectiveInverseMatrix( int i, float aspect ) { Matrix4x4 mat = Matrix4x4::Perspective( light[i]->GetLightFovy(), aspect, light[i]->GetLightNearPlane(), light[i]->GetLightFarPlane() ).Invert(); glMultMatrixf( mat.GetDataPtr() ); }