mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 03:03:35 +02:00
Offset camera fix, cleaner frustum transformation.
This commit is contained in:
parent
3330b20232
commit
100d10dc9e
2 changed files with 6 additions and 5 deletions
|
@ -338,6 +338,7 @@ void Application::paintGL() {
|
||||||
_viewFrustumOffsetPitch, _viewFrustumOffsetYaw, _viewFrustumOffsetRoll))));
|
_viewFrustumOffsetPitch, _viewFrustumOffsetYaw, _viewFrustumOffsetRoll))));
|
||||||
_viewFrustumOffsetCamera.setUpShift (_viewFrustumOffsetUp );
|
_viewFrustumOffsetCamera.setUpShift (_viewFrustumOffsetUp );
|
||||||
_viewFrustumOffsetCamera.setDistance (_viewFrustumOffsetDistance);
|
_viewFrustumOffsetCamera.setDistance (_viewFrustumOffsetDistance);
|
||||||
|
_viewFrustumOffsetCamera.initialize(); // force immediate snap to ideal position and orientation
|
||||||
_viewFrustumOffsetCamera.update(1.f/_fps);
|
_viewFrustumOffsetCamera.update(1.f/_fps);
|
||||||
whichCamera = _viewFrustumOffsetCamera;
|
whichCamera = _viewFrustumOffsetCamera;
|
||||||
}
|
}
|
||||||
|
@ -1381,9 +1382,9 @@ void Application::loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum) {
|
||||||
float farClip = camera.getFarClip();
|
float farClip = camera.getFarClip();
|
||||||
|
|
||||||
glm::quat rotation = camera.getRotation();
|
glm::quat rotation = camera.getRotation();
|
||||||
glm::vec3 direction = rotation * IDENTITY_FRONT;
|
glm::vec3 direction = rotation * AVATAR_FRONT;
|
||||||
glm::vec3 up = rotation * IDENTITY_UP;
|
glm::vec3 up = rotation * AVATAR_UP;
|
||||||
glm::vec3 right = rotation * IDENTITY_RIGHT;
|
glm::vec3 right = rotation * AVATAR_RIGHT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
printf("position.x=%f, position.y=%f, position.z=%f\n", position.x, position.y, position.z);
|
printf("position.x=%f, position.y=%f, position.z=%f\n", position.x, position.y, position.z);
|
||||||
|
@ -1398,7 +1399,7 @@ void Application::loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum) {
|
||||||
|
|
||||||
// Set the viewFrustum up with the correct position and orientation of the camera
|
// Set the viewFrustum up with the correct position and orientation of the camera
|
||||||
viewFrustum.setPosition(position);
|
viewFrustum.setPosition(position);
|
||||||
viewFrustum.setOrientation(direction,up,-right);
|
viewFrustum.setOrientation(direction,up,right);
|
||||||
|
|
||||||
// Also make sure it's got the correct lens details from the camera
|
// Also make sure it's got the correct lens details from the camera
|
||||||
viewFrustum.setFieldOfView(fov);
|
viewFrustum.setFieldOfView(fov);
|
||||||
|
|
|
@ -59,7 +59,7 @@ void ViewFrustum::calculate() {
|
||||||
|
|
||||||
// find the intersections of the rays through the corners with the clip planes in view space,
|
// find the intersections of the rays through the corners with the clip planes in view space,
|
||||||
// then transform them to world space
|
// then transform them to world space
|
||||||
glm::mat4 worldMatrix = glm::translate(_position) * glm::mat4(glm::mat3(_right, _up, _direction)) *
|
glm::mat4 worldMatrix = glm::translate(_position) * glm::mat4(glm::mat3(_right, _up, -_direction)) *
|
||||||
glm::translate(_eyeOffsetPosition) * glm::mat4_cast(_eyeOffsetOrientation);
|
glm::translate(_eyeOffsetPosition) * glm::mat4_cast(_eyeOffsetOrientation);
|
||||||
_farTopLeft = glm::vec3(worldMatrix * glm::vec4(topLeft *
|
_farTopLeft = glm::vec3(worldMatrix * glm::vec4(topLeft *
|
||||||
(-farClipPlane.w / glm::dot(topLeft, glm::vec3(farClipPlane))), 1.0f));
|
(-farClipPlane.w / glm::dot(topLeft, glm::vec3(farClipPlane))), 1.0f));
|
||||||
|
|
Loading…
Reference in a new issue