mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 09:50:06 +02:00
Merge pull request #83 from ZappoMan/view_frustum_work
Changed render_view_frustum() to handle broken camera yaw
This commit is contained in:
commit
042bb7c332
2 changed files with 35 additions and 22 deletions
|
@ -533,38 +533,47 @@ void render_view_frustum() {
|
||||||
glm::vec3 up;
|
glm::vec3 up;
|
||||||
glm::vec3 right;
|
glm::vec3 right;
|
||||||
float fov, nearClip, farClip;
|
float fov, nearClip, farClip;
|
||||||
|
float yaw, pitch, roll;
|
||||||
|
|
||||||
// Camera or Head?
|
// Camera or Head?
|
||||||
if (::cameraFrustum) {
|
if (::cameraFrustum) {
|
||||||
position = ::myCamera.getPosition();
|
position = ::myCamera.getPosition();
|
||||||
direction = ::myCamera.getOrientation().getFront() * glm::vec3(1,1,-1);
|
|
||||||
up = ::myCamera.getOrientation().getUp() * glm::vec3(1,1,1);
|
|
||||||
right = ::myCamera.getOrientation().getRight() * glm::vec3(1,1,-1);
|
|
||||||
fov = ::myCamera.getFieldOfView();
|
|
||||||
nearClip = ::myCamera.getNearClip();
|
|
||||||
farClip = ::myCamera.getFarClip();
|
|
||||||
} else {
|
} else {
|
||||||
position = ::myAvatar.getHeadPosition();
|
position = ::myAvatar.getHeadPosition();
|
||||||
direction = ::myAvatar.getHeadLookatDirection();
|
|
||||||
up = ::myAvatar.getHeadLookatDirectionUp();
|
|
||||||
right = ::myAvatar.getHeadLookatDirectionRight() * glm::vec3(-1,1,-1);
|
|
||||||
|
|
||||||
// NOTE: we use the same lens details if we draw from the head
|
|
||||||
fov = ::myCamera.getFieldOfView();
|
|
||||||
nearClip = ::myCamera.getNearClip();
|
|
||||||
farClip = ::myCamera.getFarClip();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This bit of hackery is all because our Cameras report the incorrect yaw.
|
||||||
|
// For whatever reason, the camera has a yaw set to 180.0-trueYaw, so we basically
|
||||||
|
// need to get the "yaw" from the camera and adjust it to be the trueYaw
|
||||||
|
yaw = -(::myCamera.getOrientation().getYaw()-180);
|
||||||
|
pitch = ::myCamera.getOrientation().getPitch();
|
||||||
|
roll = ::myCamera.getOrientation().getRoll();
|
||||||
|
fov = ::myCamera.getFieldOfView();
|
||||||
|
nearClip = ::myCamera.getNearClip();
|
||||||
|
farClip = ::myCamera.getFarClip();
|
||||||
|
|
||||||
|
// We can't use the camera's Orientation because of it's broken yaw. so we make a new
|
||||||
|
// correct orientation to get our vectors
|
||||||
|
Orientation o;
|
||||||
|
o.yaw(yaw);
|
||||||
|
o.pitch(pitch);
|
||||||
|
o.roll(roll);
|
||||||
|
|
||||||
|
direction = o.getFront();
|
||||||
|
up = o.getUp();
|
||||||
|
right = o.getRight();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
printLog("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);
|
||||||
printLog("direction.x=%f, direction.y=%f, direction.z=%f\n", direction.x, direction.y, direction.z);
|
printf("yaw=%f, pitch=%f, roll=%f\n", yaw,pitch,roll);
|
||||||
printLog("up.x=%f, up.y=%f, up.z=%f\n", up.x, up.y, up.z);
|
printf("direction.x=%f, direction.y=%f, direction.z=%f\n", direction.x, direction.y, direction.z);
|
||||||
printLog("right.x=%f, right.y=%f, right.z=%f\n", right.x, right.y, right.z);
|
printf("up.x=%f, up.y=%f, up.z=%f\n", up.x, up.y, up.z);
|
||||||
printLog("fov=%f\n", fov);
|
printf("right.x=%f, right.y=%f, right.z=%f\n", right.x, right.y, right.z);
|
||||||
printLog("nearClip=%f\n", nearClip);
|
printf("fov=%f\n", fov);
|
||||||
printLog("farClip=%f\n", farClip);
|
printf("nearClip=%f\n", nearClip);
|
||||||
|
printf("farClip=%f\n", farClip);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 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);
|
||||||
|
|
|
@ -34,6 +34,10 @@ public:
|
||||||
void pitch ( float );
|
void pitch ( float );
|
||||||
void roll ( float );
|
void roll ( float );
|
||||||
|
|
||||||
|
float getYaw() { return _yaw; };
|
||||||
|
float getPitch(){ return _pitch; };
|
||||||
|
float getRoll(){ return _roll; };
|
||||||
|
|
||||||
void set( Orientation );
|
void set( Orientation );
|
||||||
void setToIdentity();
|
void setToIdentity();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue