This commit is contained in:
Philip Rosedale 2014-11-19 07:05:36 -08:00
commit 0a143d9177
4 changed files with 28 additions and 7 deletions

View file

@ -2929,6 +2929,13 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
if (whichCamera.getMode() == CAMERA_MODE_MIRROR) {
viewTransform.setScale(Transform::Vec3(-1.0f, 1.0f, 1.0f));
}
if (renderSide != RenderArgs::MONO) {
glm::mat4 invView = glm::inverse(_untranslatedViewMatrix);
viewTransform.evalFromRawMatrix(invView);
viewTransform.preTranslate(_viewMatrixTranslation);
}
setViewTransform(viewTransform);
glTranslatef(_viewMatrixTranslation.x, _viewMatrixTranslation.y, _viewMatrixTranslation.z);

View file

@ -18,6 +18,7 @@
#include <glm/gtx/quaternion.hpp>
#include <glm/gtx/vector_angle.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtx/vector_query.hpp>
#include <GeometryUtil.h>
#include <NodeList.h>
@ -664,8 +665,18 @@ void Avatar::renderDisplayName() {
// we need "always facing camera": we must remove the camera rotation from the stack
glm::quat rotation = Application::getInstance()->getCamera()->getRotation();
glm::vec3 axis = glm::axis(rotation);
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
glm::vec3 frontAxis(1.f, 0.f, 0.f);
frontAxis = glm::rotate(rotation, frontAxis);
frontAxis = glm::normalize(glm::vec3(frontAxis.x, 0.f, frontAxis.z));
// TODO : test this secodn solution which should be better wfor occulus
//glm::vec3 camPosition = Application::getInstance()->getCamera()->getPosition();
//glm::vec3 frontAxis = camPosition - textPosition;
//frontAxis = glm::normalize(glm::vec3(frontAxis.z, 0.f, -frontAxis.x));
float angle = acos(frontAxis.x) * ((frontAxis.z < 0) ? 1.f : -1.f);
glRotatef(glm::degrees(angle), 0.0f, 1.0f, 0.0f);
// We need to compute the scale factor such as the text remains with fixed size respect to window coordinates
// We project a unit vector and check the difference in screen coordinates, to check which is the
@ -695,7 +706,8 @@ void Avatar::renderDisplayName() {
if (success) {
double textWindowHeight = abs(result1[1] - result0[1]);
float scaleFactor = Application::getInstance()->getRenderResolutionScale() *
float scaleFactor = Application::getInstance()->getRenderResolutionScale() * // Scale compensate for the resolution
QApplication::desktop()->windowHandle()->devicePixelRatio() * // And the device pixel ratio
((textWindowHeight > EPSILON) ? 1.0f / textWindowHeight : 1.0f);
glScalef(scaleFactor, scaleFactor, 1.0);

View file

@ -524,13 +524,15 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p
glViewport(_eyeRenderViewport[eye].Pos.x, _eyeRenderViewport[eye].Pos.y,
_eyeRenderViewport[eye].Size.w, _eyeRenderViewport[eye].Size.h);
// Apply the offset for the left or right eye on the projection matrix
glTranslatef(_eyeRenderDesc[eye].ViewAdjust.x, _eyeRenderDesc[eye].ViewAdjust.y, _eyeRenderDesc[eye].ViewAdjust.z);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// HACK: instead of passing the stereo eye offset directly in the matrix, pass it in the camera offset
//glTranslatef(_eyeRenderDesc[eye].ViewAdjust.x, _eyeRenderDesc[eye].ViewAdjust.y, _eyeRenderDesc[eye].ViewAdjust.z);
Application::getInstance()->displaySide(*_camera, false, renderSide);
_camera->setEyeOffsetPosition(glm::vec3(-_eyeRenderDesc[eye].ViewAdjust.x, -_eyeRenderDesc[eye].ViewAdjust.y, -_eyeRenderDesc[eye].ViewAdjust.z));
Application::getInstance()->displaySide(*_camera, false, RenderArgs::MONO);
applicationOverlay.displayOverlayTextureOculus(*_camera);
_activeEyeIndex = -1;

View file

@ -95,7 +95,7 @@ int TextRenderer::draw(int x, int y, const char* str, float alpha) {
maxHeight = glyph.bounds().height();
}
//glBindTexture(GL_TEXTURE_2D, glyph.textureID());
int left = x + glyph.bounds().x();
int right = x + glyph.bounds().x() + glyph.bounds().width();
int bottom = y + glyph.bounds().y();