mirror of
https://github.com/overte-org/overte.git
synced 2025-07-22 21:06:24 +02:00
Merge 'threedtv' of https://github.com/ZappoMan/hifi for pull 1430
This commit is contained in:
commit
68c09c5b74
6 changed files with 203 additions and 10 deletions
|
@ -57,6 +57,7 @@
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "devices/LeapManager.h"
|
#include "devices/LeapManager.h"
|
||||||
#include "devices/OculusManager.h"
|
#include "devices/OculusManager.h"
|
||||||
|
#include "devices/TV3DManager.h"
|
||||||
#include "renderer/ProgramObject.h"
|
#include "renderer/ProgramObject.h"
|
||||||
#include "ui/TextRenderer.h"
|
#include "ui/TextRenderer.h"
|
||||||
#include "InfoView.h"
|
#include "InfoView.h"
|
||||||
|
@ -439,7 +440,10 @@ void Application::paintGL() {
|
||||||
|
|
||||||
if (OculusManager::isConnected()) {
|
if (OculusManager::isConnected()) {
|
||||||
OculusManager::display(whichCamera);
|
OculusManager::display(whichCamera);
|
||||||
|
} else if (TV3DManager::isConnected()) {
|
||||||
|
_glowEffect.prepare();
|
||||||
|
TV3DManager::display(whichCamera);
|
||||||
|
_glowEffect.render();
|
||||||
} else {
|
} else {
|
||||||
_glowEffect.prepare();
|
_glowEffect.prepare();
|
||||||
|
|
||||||
|
@ -474,8 +478,10 @@ void Application::paintGL() {
|
||||||
_mirrorCamera.update(1.0f/_fps);
|
_mirrorCamera.update(1.0f/_fps);
|
||||||
|
|
||||||
// set the bounds of rear mirror view
|
// set the bounds of rear mirror view
|
||||||
glViewport(_mirrorViewRect.x(), _glWidget->height() - _mirrorViewRect.y() - _mirrorViewRect.height(), _mirrorViewRect.width(), _mirrorViewRect.height());
|
glViewport(_mirrorViewRect.x(), _glWidget->height() - _mirrorViewRect.y() - _mirrorViewRect.height(),
|
||||||
glScissor(_mirrorViewRect.x(), _glWidget->height() - _mirrorViewRect.y() - _mirrorViewRect.height(), _mirrorViewRect.width(), _mirrorViewRect.height());
|
_mirrorViewRect.width(), _mirrorViewRect.height());
|
||||||
|
glScissor(_mirrorViewRect.x(), _glWidget->height() - _mirrorViewRect.y() - _mirrorViewRect.height(),
|
||||||
|
_mirrorViewRect.width(), _mirrorViewRect.height());
|
||||||
bool updateViewFrustum = false;
|
bool updateViewFrustum = false;
|
||||||
updateProjectionMatrix(_mirrorCamera, updateViewFrustum);
|
updateProjectionMatrix(_mirrorCamera, updateViewFrustum);
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
@ -506,7 +512,6 @@ void Application::paintGL() {
|
||||||
// restore absolute translations
|
// restore absolute translations
|
||||||
_myAvatar.getSkeletonModel().setTranslation(absoluteSkeletonTranslation);
|
_myAvatar.getSkeletonModel().setTranslation(absoluteSkeletonTranslation);
|
||||||
_myAvatar.getHead().getFaceModel().setTranslation(absoluteFaceTranslation);
|
_myAvatar.getHead().getFaceModel().setTranslation(absoluteFaceTranslation);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
displaySide(_mirrorCamera, true);
|
displaySide(_mirrorCamera, true);
|
||||||
}
|
}
|
||||||
|
@ -531,7 +536,8 @@ void Application::paintGL() {
|
||||||
void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) {
|
void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) {
|
||||||
if (OculusManager::isConnected()) {
|
if (OculusManager::isConnected()) {
|
||||||
OculusManager::configureCamera(camera, width, height);
|
OculusManager::configureCamera(camera, width, height);
|
||||||
|
} else if (TV3DManager::isConnected()) {
|
||||||
|
TV3DManager::configureCamera(camera, width, height);
|
||||||
} else {
|
} else {
|
||||||
camera.setAspectRatio((float)width / height);
|
camera.setAspectRatio((float)width / height);
|
||||||
camera.setFieldOfView(Menu::getInstance()->getFieldOfView());
|
camera.setFieldOfView(Menu::getInstance()->getFieldOfView());
|
||||||
|
@ -910,7 +916,9 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
case Qt::Key_J:
|
case Qt::Key_J:
|
||||||
if (isShifted) {
|
if (isShifted) {
|
||||||
_viewFrustum.setFocalLength(_viewFrustum.getFocalLength() - 0.1f);
|
_viewFrustum.setFocalLength(_viewFrustum.getFocalLength() - 0.1f);
|
||||||
|
if (TV3DManager::isConnected()) {
|
||||||
|
TV3DManager::configureCamera(_myCamera, _glWidget->width(),_glWidget->height());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
_myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0));
|
_myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0));
|
||||||
}
|
}
|
||||||
|
@ -920,6 +928,9 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
case Qt::Key_M:
|
case Qt::Key_M:
|
||||||
if (isShifted) {
|
if (isShifted) {
|
||||||
_viewFrustum.setFocalLength(_viewFrustum.getFocalLength() + 0.1f);
|
_viewFrustum.setFocalLength(_viewFrustum.getFocalLength() + 0.1f);
|
||||||
|
if (TV3DManager::isConnected()) {
|
||||||
|
TV3DManager::configureCamera(_myCamera, _glWidget->width(),_glWidget->height());
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0.001, 0, 0));
|
_myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0.001, 0, 0));
|
||||||
|
@ -1839,6 +1850,13 @@ void Application::init() {
|
||||||
"trigger",
|
"trigger",
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TV3DManager::connect();
|
||||||
|
if (TV3DManager::isConnected()) {
|
||||||
|
QMetaObject::invokeMethod(Menu::getInstance()->getActionForOption(MenuOption::Fullscreen),
|
||||||
|
"trigger",
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
}
|
||||||
|
|
||||||
LeapManager::initialize();
|
LeapManager::initialize();
|
||||||
|
|
||||||
|
@ -2426,7 +2444,7 @@ void Application::updateCamera(float deltaTime) {
|
||||||
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
||||||
PerformanceWarning warn(showWarnings, "Application::updateCamera()");
|
PerformanceWarning warn(showWarnings, "Application::updateCamera()");
|
||||||
|
|
||||||
if (!OculusManager::isConnected()) {
|
if (!OculusManager::isConnected() && !TV3DManager::isConnected()) {
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
|
||||||
if (_myCamera.getMode() != CAMERA_MODE_MIRROR) {
|
if (_myCamera.getMode() != CAMERA_MODE_MIRROR) {
|
||||||
_myCamera.setMode(CAMERA_MODE_MIRROR);
|
_myCamera.setMode(CAMERA_MODE_MIRROR);
|
||||||
|
@ -3811,7 +3829,7 @@ void Application::renderAvatars(bool forceRenderHead, bool selfAvatarOnly) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||||
"Application::displaySide() ... Avatars...");
|
"Application::renderAvatars()");
|
||||||
|
|
||||||
if (!selfAvatarOnly) {
|
if (!selfAvatarOnly) {
|
||||||
// Render avatars of other nodes
|
// Render avatars of other nodes
|
||||||
|
@ -4100,7 +4118,7 @@ void Application::resetSensors() {
|
||||||
if (OculusManager::isConnected()) {
|
if (OculusManager::isConnected()) {
|
||||||
OculusManager::reset();
|
OculusManager::reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
QCursor::setPos(_headMouseX, _headMouseY);
|
QCursor::setPos(_headMouseX, _headMouseY);
|
||||||
_myAvatar.reset();
|
_myAvatar.reset();
|
||||||
_myTransmitter.resetLevels();
|
_myTransmitter.resetLevels();
|
||||||
|
|
|
@ -254,7 +254,6 @@ private slots:
|
||||||
void shrinkMirrorView();
|
void shrinkMirrorView();
|
||||||
void resetSensors();
|
void resetSensors();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resetCamerasOnResizeGL(Camera& camera, int width, int height);
|
void resetCamerasOnResizeGL(Camera& camera, int width, int height);
|
||||||
void updateProjectionMatrix();
|
void updateProjectionMatrix();
|
||||||
|
|
|
@ -232,6 +232,8 @@ Menu::Menu() :
|
||||||
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::FirstPerson, Qt::Key_P, true);
|
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::FirstPerson, Qt::Key_P, true);
|
||||||
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Mirror, Qt::SHIFT | Qt::Key_H);
|
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Mirror, Qt::SHIFT | Qt::Key_H);
|
||||||
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::FullscreenMirror, Qt::Key_H);
|
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::FullscreenMirror, Qt::Key_H);
|
||||||
|
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Enable3DTVMode, 0, false);
|
||||||
|
|
||||||
|
|
||||||
QMenu* avatarSizeMenu = viewMenu->addMenu("Avatar Size");
|
QMenu* avatarSizeMenu = viewMenu->addMenu("Avatar Size");
|
||||||
|
|
||||||
|
|
|
@ -178,6 +178,7 @@ namespace MenuOption {
|
||||||
const QString FilterSixense = "Smooth Sixense Movement";
|
const QString FilterSixense = "Smooth Sixense Movement";
|
||||||
const QString DontRenderVoxels = "Don't call _voxels.render()";
|
const QString DontRenderVoxels = "Don't call _voxels.render()";
|
||||||
const QString DontCallOpenGLForVoxels = "Don't call glDrawRangeElementsEXT() for Voxels";
|
const QString DontCallOpenGLForVoxels = "Don't call glDrawRangeElementsEXT() for Voxels";
|
||||||
|
const QString Enable3DTVMode = "Enable 3DTV Mode";
|
||||||
const QString EnableOcclusionCulling = "Enable Occlusion Culling";
|
const QString EnableOcclusionCulling = "Enable Occlusion Culling";
|
||||||
const QString EnableVoxelPacketCompression = "Enable Voxel Packet Compression";
|
const QString EnableVoxelPacketCompression = "Enable Voxel Packet Compression";
|
||||||
const QString EchoServerAudio = "Echo Server Audio";
|
const QString EchoServerAudio = "Echo Server Audio";
|
||||||
|
|
132
interface/src/devices/TV3DManager.cpp
Normal file
132
interface/src/devices/TV3DManager.cpp
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
//
|
||||||
|
// TV3DManager.cpp
|
||||||
|
// hifi
|
||||||
|
//
|
||||||
|
// Created by Brad Hefta-Gaub on 12/24/13.
|
||||||
|
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <QOpenGLFramebufferObject>
|
||||||
|
|
||||||
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
|
#include "InterfaceConfig.h"
|
||||||
|
#include "TV3DManager.h"
|
||||||
|
#include "Menu.h"
|
||||||
|
|
||||||
|
int TV3DManager::_screenWidth = 1;
|
||||||
|
int TV3DManager::_screenHeight = 1;
|
||||||
|
double TV3DManager::_aspect = 1.0;
|
||||||
|
eyeFrustum TV3DManager::_leftEye;
|
||||||
|
eyeFrustum TV3DManager::_rightEye;
|
||||||
|
|
||||||
|
|
||||||
|
bool TV3DManager::isConnected() {
|
||||||
|
return Menu::getInstance()->isOptionChecked(MenuOption::Enable3DTVMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TV3DManager::connect() {
|
||||||
|
Application* app = Application::getInstance();
|
||||||
|
int width = app->getGLWidget()->width();
|
||||||
|
int height = app->getGLWidget()->height();
|
||||||
|
Camera& camera = *app->getCamera();
|
||||||
|
|
||||||
|
configureCamera(camera, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// The basic strategy of this stereoscopic rendering is explained here:
|
||||||
|
// http://www.orthostereo.com/geometryopengl.html
|
||||||
|
void TV3DManager::setFrustum(Camera& whichCamera) {
|
||||||
|
const double DTR = 0.0174532925; // degree to radians
|
||||||
|
const double IOD = 0.05; //intraocular distance
|
||||||
|
double fovy = whichCamera.getFieldOfView(); // field of view in y-axis
|
||||||
|
double nearZ = whichCamera.getNearClip(); // near clipping plane
|
||||||
|
double screenZ = Application::getInstance()->getViewFrustum()->getFocalLength(); // screen projection plane
|
||||||
|
|
||||||
|
double top = nearZ * tan(DTR * fovy / 2); //sets top of frustum based on fovy and near clipping plane
|
||||||
|
double right = _aspect * top; // sets right of frustum based on aspect ratio
|
||||||
|
double frustumshift = (IOD / 2) * nearZ / screenZ;
|
||||||
|
|
||||||
|
_leftEye.top = top;
|
||||||
|
_leftEye.bottom = -top;
|
||||||
|
_leftEye.left = -right + frustumshift;
|
||||||
|
_leftEye.right = right + frustumshift;
|
||||||
|
_leftEye.modelTranslation = IOD / 2;
|
||||||
|
|
||||||
|
_rightEye.top = top;
|
||||||
|
_rightEye.bottom = -top;
|
||||||
|
_rightEye.left = -right - frustumshift;
|
||||||
|
_rightEye.right = right - frustumshift;
|
||||||
|
_rightEye.modelTranslation = -IOD / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TV3DManager::configureCamera(Camera& whichCamera, int screenWidth, int screenHeight) {
|
||||||
|
if (screenHeight == 0) {
|
||||||
|
screenHeight = 1; // prevent divide by 0
|
||||||
|
}
|
||||||
|
_screenWidth = screenWidth;
|
||||||
|
_screenHeight = screenHeight;
|
||||||
|
_aspect= (double)_screenWidth / (double)_screenHeight;
|
||||||
|
setFrustum(whichCamera);
|
||||||
|
|
||||||
|
glViewport (0, 0, _screenWidth, _screenHeight); // sets drawing viewport
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TV3DManager::display(Camera& whichCamera) {
|
||||||
|
double nearZ = whichCamera.getNearClip(); // near clipping plane
|
||||||
|
double farZ = whichCamera.getFarClip(); // far clipping plane
|
||||||
|
|
||||||
|
// left eye portal
|
||||||
|
int portalX = 0;
|
||||||
|
int portalY = 0;
|
||||||
|
int portalW = Application::getInstance()->getGLWidget()->width() / 2;
|
||||||
|
int portalH = Application::getInstance()->getGLWidget()->height();
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
// render left side view
|
||||||
|
glViewport(portalX, portalY, portalW, portalH);
|
||||||
|
glScissor(portalX, portalY, portalW, portalH);
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
{
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity(); // reset projection matrix
|
||||||
|
glFrustum(_leftEye.left, _leftEye.right, _leftEye.bottom, _leftEye.top, nearZ, farZ); // set left view frustum
|
||||||
|
glTranslatef(_leftEye.modelTranslation, 0.0, 0.0); // translate to cancel parallax
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
Application::getInstance()->displaySide(whichCamera);
|
||||||
|
}
|
||||||
|
glPopMatrix();
|
||||||
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
|
// render right side view
|
||||||
|
portalX = Application::getInstance()->getGLWidget()->width() / 2;
|
||||||
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
// render left side view
|
||||||
|
glViewport(portalX, portalY, portalW, portalH);
|
||||||
|
glScissor(portalX, portalY, portalW, portalH);
|
||||||
|
glPushMatrix();
|
||||||
|
{
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity(); // reset projection matrix
|
||||||
|
glFrustum(_rightEye.left, _rightEye.right, _rightEye.bottom, _rightEye.top, nearZ, farZ); // set left view frustum
|
||||||
|
glTranslatef(_rightEye.modelTranslation, 0.0, 0.0); // translate to cancel parallax
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
Application::getInstance()->displaySide(whichCamera);
|
||||||
|
}
|
||||||
|
glPopMatrix();
|
||||||
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
|
// reset the viewport to how we started
|
||||||
|
glViewport(0, 0, Application::getInstance()->getGLWidget()->width(), Application::getInstance()->getGLWidget()->height());
|
||||||
|
}
|
41
interface/src/devices/TV3DManager.h
Normal file
41
interface/src/devices/TV3DManager.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
//
|
||||||
|
// TV3DManager.h
|
||||||
|
// hifi
|
||||||
|
//
|
||||||
|
// Created by Brad Hefta-Gaub on 12/24/2013
|
||||||
|
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef __hifi__TV3DManager__
|
||||||
|
#define __hifi__TV3DManager__
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
class Camera;
|
||||||
|
|
||||||
|
struct eyeFrustum {
|
||||||
|
double left;
|
||||||
|
double right;
|
||||||
|
double bottom;
|
||||||
|
double top;
|
||||||
|
float modelTranslation;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/// Handles interaction with 3D TVs
|
||||||
|
class TV3DManager {
|
||||||
|
public:
|
||||||
|
static void connect();
|
||||||
|
static bool isConnected();
|
||||||
|
static void configureCamera(Camera& camera, int screenWidth, int screenHeight);
|
||||||
|
static void display(Camera& whichCamera);
|
||||||
|
private:
|
||||||
|
static void setFrustum(Camera& whichCamera);
|
||||||
|
static int _screenWidth;
|
||||||
|
static int _screenHeight;
|
||||||
|
static double _aspect;
|
||||||
|
static eyeFrustum _leftEye;
|
||||||
|
static eyeFrustum _rightEye;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* defined(__hifi__TV3DManager__) */
|
Loading…
Reference in a new issue