mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 20:36:38 +02:00
Switched Oculus magnify method to a manual mode
This commit is contained in:
parent
031fe323ea
commit
84d183b2bc
2 changed files with 69 additions and 30 deletions
|
@ -36,6 +36,9 @@ ApplicationOverlay::ApplicationOverlay() :
|
||||||
_textureFov(DEFAULT_OCULUS_UI_ANGULAR_SIZE * RADIANS_PER_DEGREE),
|
_textureFov(DEFAULT_OCULUS_UI_ANGULAR_SIZE * RADIANS_PER_DEGREE),
|
||||||
_crosshairTexture(0) {
|
_crosshairTexture(0) {
|
||||||
|
|
||||||
|
_magActive[MOUSE] = false;
|
||||||
|
_magActive[LEFT_CONTROLLER] = false;
|
||||||
|
_magActive[RIGHT_CONTROLLER] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationOverlay::~ApplicationOverlay() {
|
ApplicationOverlay::~ApplicationOverlay() {
|
||||||
|
@ -45,7 +48,6 @@ ApplicationOverlay::~ApplicationOverlay() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const float WHITE_TEXT[] = { 0.93f, 0.93f, 0.93f };
|
const float WHITE_TEXT[] = { 0.93f, 0.93f, 0.93f };
|
||||||
|
|
||||||
const float RETICLE_COLOR[] = { 0.0f, 198.0f / 255.0f, 244.0f / 255.0f };
|
const float RETICLE_COLOR[] = { 0.0f, 198.0f / 255.0f, 244.0f / 255.0f };
|
||||||
|
|
||||||
// Renders the overlays either to a texture or to the screen
|
// Renders the overlays either to a texture or to the screen
|
||||||
|
@ -158,7 +160,6 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
|
||||||
MyAvatar* myAvatar = application->getAvatar();
|
MyAvatar* myAvatar = application->getAvatar();
|
||||||
const glm::vec3& viewMatrixTranslation = application->getViewMatrixTranslation();
|
const glm::vec3& viewMatrixTranslation = application->getViewMatrixTranslation();
|
||||||
|
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
@ -194,8 +195,11 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
|
||||||
glAlphaFunc(GL_GREATER, 0.01f);
|
glAlphaFunc(GL_GREATER, 0.01f);
|
||||||
|
|
||||||
//Draw the magnifiers
|
//Draw the magnifiers
|
||||||
for (int i = 0; i < _numMagnifiers; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
renderMagnifier(_mouseX[i], _mouseY[i]);
|
|
||||||
|
if (_magActive[i]) {
|
||||||
|
renderMagnifier(_magX[i], _magY[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
|
@ -220,7 +224,6 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
|
||||||
void ApplicationOverlay::renderPointers() {
|
void ApplicationOverlay::renderPointers() {
|
||||||
Application* application = Application::getInstance();
|
Application* application = Application::getInstance();
|
||||||
// Render a crosshair over the mouse when in Oculus
|
// Render a crosshair over the mouse when in Oculus
|
||||||
_numMagnifiers = 0;
|
|
||||||
int mouseX = application->getMouseX();
|
int mouseX = application->getMouseX();
|
||||||
int mouseY = application->getMouseY();
|
int mouseY = application->getMouseY();
|
||||||
|
|
||||||
|
@ -236,11 +239,19 @@ void ApplicationOverlay::renderPointers() {
|
||||||
|
|
||||||
if (OculusManager::isConnected() && application->getLastMouseMoveType() == QEvent::MouseMove) {
|
if (OculusManager::isConnected() && application->getLastMouseMoveType() == QEvent::MouseMove) {
|
||||||
//If we are in oculus, render reticle later
|
//If we are in oculus, render reticle later
|
||||||
_numMagnifiers = 1;
|
_reticleActive[MOUSE] = true;
|
||||||
_mouseX[0] = application->getMouseX();
|
_magActive[MOUSE] = true;
|
||||||
_mouseY[0] = application->getMouseY();
|
_mouseX[MOUSE] = application->getMouseX();
|
||||||
|
_mouseY[MOUSE] = application->getMouseY();
|
||||||
|
_magX[MOUSE] = _mouseX[MOUSE];
|
||||||
|
_magY[MOUSE] = _mouseY[MOUSE];
|
||||||
|
|
||||||
|
_reticleActive[LEFT_CONTROLLER] = false;
|
||||||
|
_reticleActive[RIGHT_CONTROLLER] = false;
|
||||||
|
|
||||||
} else if (application->getLastMouseMoveType() == CONTROLLER_MOVE_EVENT && Menu::getInstance()->isOptionChecked(MenuOption::SixenseMouseInput)) {
|
} else if (application->getLastMouseMoveType() == CONTROLLER_MOVE_EVENT && Menu::getInstance()->isOptionChecked(MenuOption::SixenseMouseInput)) {
|
||||||
//only render controller pointer if we aren't already rendering a mouse pointer
|
//only render controller pointer if we aren't already rendering a mouse pointer
|
||||||
|
_reticleActive[MOUSE] = false;
|
||||||
renderControllerPointers();
|
renderControllerPointers();
|
||||||
}
|
}
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
@ -256,6 +267,8 @@ void ApplicationOverlay::renderControllerPointers() {
|
||||||
const HandData* handData = Application::getInstance()->getAvatar()->getHandData();
|
const HandData* handData = Application::getInstance()->getAvatar()->getHandData();
|
||||||
|
|
||||||
for (unsigned int palmIndex = 2; palmIndex < 4; palmIndex++) {
|
for (unsigned int palmIndex = 2; palmIndex < 4; palmIndex++) {
|
||||||
|
const int index = palmIndex - 1;
|
||||||
|
|
||||||
const PalmData* palmData = NULL;
|
const PalmData* palmData = NULL;
|
||||||
|
|
||||||
if (palmIndex >= handData->getPalms().size()) {
|
if (palmIndex >= handData->getPalms().size()) {
|
||||||
|
@ -268,6 +281,8 @@ void ApplicationOverlay::renderControllerPointers() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int controllerButtons = palmData->getControllerButtons();
|
||||||
|
|
||||||
// Get directon relative to avatar orientation
|
// Get directon relative to avatar orientation
|
||||||
glm::vec3 direction = glm::inverse(myAvatar->getOrientation()) * palmData->getFingerDirection();
|
glm::vec3 direction = glm::inverse(myAvatar->getOrientation()) * palmData->getFingerDirection();
|
||||||
|
|
||||||
|
@ -281,22 +296,35 @@ void ApplicationOverlay::renderControllerPointers() {
|
||||||
int mouseX = glWidget->width() / 2.0f + cursorRange * xAngle;
|
int mouseX = glWidget->width() / 2.0f + cursorRange * xAngle;
|
||||||
int mouseY = glWidget->height() / 2.0f + cursorRange * yAngle;
|
int mouseY = glWidget->height() / 2.0f + cursorRange * yAngle;
|
||||||
|
|
||||||
|
// If the 2 button is pressed, we disable the magnifier for this controller
|
||||||
|
if (controllerButtons & BUTTON_2) {
|
||||||
|
_magActive[index] = false;
|
||||||
|
_magX[index] = mouseX;
|
||||||
|
_magY[index] = mouseY;
|
||||||
|
}
|
||||||
|
|
||||||
//If the cursor is out of the screen then don't render it
|
//If the cursor is out of the screen then don't render it
|
||||||
if (mouseX < 0 || mouseX >= glWidget->width() || mouseY < 0 || mouseY >= glWidget->height()) {
|
if (mouseX < 0 || mouseX >= glWidget->width() || mouseY < 0 || mouseY >= glWidget->height()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
_reticleActive[index] = true;
|
||||||
float pointerWidth = 40;
|
float pointerWidth = 40;
|
||||||
float pointerHeight = 40;
|
float pointerHeight = 40;
|
||||||
|
|
||||||
//if we have the oculus, we should make the cursor smaller since it will be
|
//if we have the oculus, we should make the cursor smaller since it will be
|
||||||
//magnified
|
//magnified
|
||||||
if (OculusManager::isConnected()) {
|
if (OculusManager::isConnected()) {
|
||||||
|
|
||||||
|
_mouseX[index] = mouseX;
|
||||||
|
_mouseY[index] = mouseY;
|
||||||
|
|
||||||
_mouseX[_numMagnifiers] = mouseX;
|
if (controllerButtons & BUTTON_3) {
|
||||||
_mouseY[_numMagnifiers] = mouseY;
|
_magActive[index] = true;
|
||||||
_numMagnifiers++;
|
_magX[index] = mouseX;
|
||||||
//If oculus is enabled, we draw the crosshairs later
|
_magY[index] = mouseY;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If oculus is enabled, we draw the crosshairs later
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +356,12 @@ void ApplicationOverlay::renderControllerPointersOculus() {
|
||||||
glBindTexture(GL_TEXTURE_2D, _crosshairTexture);
|
glBindTexture(GL_TEXTURE_2D, _crosshairTexture);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
for (int i = 0; i < _numMagnifiers; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
|
|
||||||
|
//Dont render the reticle if its inactive
|
||||||
|
if (!_reticleActive[i]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
float mouseX = (float)_mouseX[i];
|
float mouseX = (float)_mouseX[i];
|
||||||
float mouseY = (float)_mouseY[i];
|
float mouseY = (float)_mouseY[i];
|
||||||
|
@ -385,26 +418,22 @@ void ApplicationOverlay::renderMagnifier(int mouseX, int mouseY)
|
||||||
|
|
||||||
const int widgetWidth = glWidget->width();
|
const int widgetWidth = glWidget->width();
|
||||||
const int widgetHeight = glWidget->height();
|
const int widgetHeight = glWidget->height();
|
||||||
const float magnification = 4.0f;
|
|
||||||
|
|
||||||
float magnifyWidth = 80.0f;
|
mouseX -= MAGNIFY_WIDTH / 2;
|
||||||
float magnifyHeight = 60.0f;
|
mouseY -= MAGNIFY_HEIGHT / 2;
|
||||||
|
|
||||||
mouseX -= magnifyWidth / 2;
|
float newWidth = MAGNIFY_WIDTH * MAGNIFY_MULT;
|
||||||
mouseY -= magnifyHeight / 2;
|
float newHeight = MAGNIFY_HEIGHT * MAGNIFY_MULT;
|
||||||
|
|
||||||
float newWidth = magnifyWidth * magnification;
|
|
||||||
float newHeight = magnifyHeight * magnification;
|
|
||||||
|
|
||||||
// Magnification Texture Coordinates
|
// Magnification Texture Coordinates
|
||||||
float magnifyULeft = mouseX / (float)widgetWidth;
|
float magnifyULeft = mouseX / (float)widgetWidth;
|
||||||
float magnifyURight = (mouseX + magnifyWidth) / (float)widgetWidth;
|
float magnifyURight = (mouseX + MAGNIFY_WIDTH) / (float)widgetWidth;
|
||||||
float magnifyVBottom = 1.0f - mouseY / (float)widgetHeight;
|
float magnifyVBottom = 1.0f - mouseY / (float)widgetHeight;
|
||||||
float magnifyVTop = 1.0f - (mouseY + magnifyHeight) / (float)widgetHeight;
|
float magnifyVTop = 1.0f - (mouseY + MAGNIFY_HEIGHT) / (float)widgetHeight;
|
||||||
|
|
||||||
// Coordinates of magnification overlay
|
// Coordinates of magnification overlay
|
||||||
float newMouseX = (mouseX + magnifyWidth / 2) - newWidth / 2.0f;
|
float newMouseX = (mouseX + MAGNIFY_WIDTH / 2) - newWidth / 2.0f;
|
||||||
float newMouseY = (mouseY + magnifyHeight / 2) + newHeight / 2.0f;
|
float newMouseY = (mouseY + MAGNIFY_HEIGHT / 2) + newHeight / 2.0f;
|
||||||
|
|
||||||
// Get position on hemisphere using angle
|
// Get position on hemisphere using angle
|
||||||
|
|
||||||
|
|
|
@ -15,18 +15,22 @@
|
||||||
class Overlays;
|
class Overlays;
|
||||||
class QOpenGLFramebufferObject;
|
class QOpenGLFramebufferObject;
|
||||||
|
|
||||||
|
const float MAGNIFY_WIDTH = 160.0f;
|
||||||
|
const float MAGNIFY_HEIGHT = 80.0f;
|
||||||
|
const float MAGNIFY_MULT = 4.0f;
|
||||||
|
|
||||||
// Handles the drawing of the overlays to the screen
|
// Handles the drawing of the overlays to the screen
|
||||||
class ApplicationOverlay {
|
class ApplicationOverlay {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ApplicationOverlay();
|
ApplicationOverlay();
|
||||||
|
|
||||||
~ApplicationOverlay();
|
~ApplicationOverlay();
|
||||||
|
|
||||||
void renderOverlay(bool renderToTexture = false);
|
void renderOverlay(bool renderToTexture = false);
|
||||||
void displayOverlayTexture(Camera& whichCamera);
|
void displayOverlayTexture(Camera& whichCamera);
|
||||||
void displayOverlayTextureOculus(Camera& whichCamera);
|
void displayOverlayTextureOculus(Camera& whichCamera);
|
||||||
void computeOculusPickRay(float x, float y, glm::vec3& direction) const;
|
void computeOculusPickRay(float x, float y, glm::vec3& direction) const;
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
QOpenGLFramebufferObject* getFramebufferObject();
|
QOpenGLFramebufferObject* getFramebufferObject();
|
||||||
|
|
||||||
|
@ -37,6 +41,8 @@ private:
|
||||||
glm::vec2 uv;
|
glm::vec2 uv;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum MousePointerDevice { MOUSE, LEFT_CONTROLLER, RIGHT_CONTROLLER };
|
||||||
|
|
||||||
typedef QPair<GLuint, GLuint> VerticesIndices;
|
typedef QPair<GLuint, GLuint> VerticesIndices;
|
||||||
|
|
||||||
void renderPointers();
|
void renderPointers();
|
||||||
|
@ -52,9 +58,13 @@ private:
|
||||||
float _oculusAngle;
|
float _oculusAngle;
|
||||||
float _distance;
|
float _distance;
|
||||||
float _textureFov;
|
float _textureFov;
|
||||||
int _mouseX[2];
|
// 0 = Mouse, 1 = Left Controller, 2 = Right Controller
|
||||||
int _mouseY[2];
|
bool _reticleActive[3];
|
||||||
int _numMagnifiers;
|
int _mouseX[3];
|
||||||
|
int _mouseY[3];
|
||||||
|
bool _magActive[3];
|
||||||
|
int _magX[3];
|
||||||
|
int _magY[3];
|
||||||
|
|
||||||
GLuint _crosshairTexture;
|
GLuint _crosshairTexture;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue