mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 16:41:02 +02:00
Curved Oculus overlay around camera as a semicircle
This commit is contained in:
parent
6f5d2ba233
commit
90754e320d
5 changed files with 48 additions and 16 deletions
|
@ -51,7 +51,7 @@ var flockGravity = { x: 0, y: -1, z: 0};
|
||||||
var enableRandomXZThrust = false; // leading birds randomly decide to thrust in some random direction.
|
var enableRandomXZThrust = false; // leading birds randomly decide to thrust in some random direction.
|
||||||
var enableSomeBirdsLead = false; // birds randomly decide not fly toward flock, causing other birds to follow
|
var enableSomeBirdsLead = false; // birds randomly decide not fly toward flock, causing other birds to follow
|
||||||
var leaders = 0; // number of birds leading
|
var leaders = 0; // number of birds leading
|
||||||
var PROBABILITY_TO_LEAD = 0.1; // probabolity a bird will choose to lead
|
var PROBABILITY_TO_LEAD = 0.1; // probability a bird will choose to lead
|
||||||
|
|
||||||
var birds = new Array(); // array of bird state data
|
var birds = new Array(); // array of bird state data
|
||||||
|
|
||||||
|
|
|
@ -1007,6 +1007,12 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
case Qt::Key_At:
|
case Qt::Key_At:
|
||||||
Menu::getInstance()->goTo();
|
Menu::getInstance()->goTo();
|
||||||
break;
|
break;
|
||||||
|
case Qt::Key_B:
|
||||||
|
_applicationOverlay.setOculusAngle(_applicationOverlay.getOculusAngle() - 1.0f*RADIANS_PER_DEGREE);
|
||||||
|
break;
|
||||||
|
case Qt::Key_N:
|
||||||
|
_applicationOverlay.setOculusAngle(_applicationOverlay.getOculusAngle() + 1.0f*RADIANS_PER_DEGREE);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
event->ignore();
|
event->ignore();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -86,7 +86,7 @@ void OculusManager::display(Camera& whichCamera) {
|
||||||
// We only need to render the overlays to a texture once, then we just render the texture as a quad
|
// We only need to render the overlays to a texture once, then we just render the texture as a quad
|
||||||
// PrioVR will only work if renderOverlay is called, calibration is connected to Application::renderingOverlay()
|
// PrioVR will only work if renderOverlay is called, calibration is connected to Application::renderingOverlay()
|
||||||
applicationOverlay.renderOverlay(true);
|
applicationOverlay.renderOverlay(true);
|
||||||
const bool displayOverlays = false;
|
const bool displayOverlays = true;
|
||||||
|
|
||||||
Application::getInstance()->getGlowEffect()->prepare();
|
Application::getInstance()->getGlowEffect()->prepare();
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
|
|
||||||
#include "ui/Stats.h"
|
#include "ui/Stats.h"
|
||||||
|
|
||||||
ApplicationOverlay::ApplicationOverlay() : _framebufferObject(NULL) {
|
ApplicationOverlay::ApplicationOverlay() : _framebufferObject(NULL),
|
||||||
|
_oculusAngle(65.0f * RADIANS_PER_DEGREE) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,14 +272,21 @@ 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();
|
||||||
|
|
||||||
// Calculates the world space width and height of the texture based on a desired FOV
|
// Get vertical FoV of the displayed overlay texture
|
||||||
const float overlayFov = whichCamera.getFieldOfView() * PI / 180.0f;
|
const float halfVerticalAngle = _oculusAngle / 2.0f;
|
||||||
const float overlayDistance = 1;
|
const float overlayDistance = 1.0;
|
||||||
const float overlayAspectRatio = glWidget->width() / (float)glWidget->height();
|
const float overlayAspectRatio = glWidget->width() / (float)glWidget->height();
|
||||||
const float overlayHeight = overlayDistance * tan(overlayFov);
|
const float halfOverlayHeight = overlayDistance * tan(halfVerticalAngle);
|
||||||
const float overlayWidth = overlayHeight * overlayAspectRatio;
|
|
||||||
const float halfOverlayWidth = overlayWidth / 2;
|
// The more vertices, the better the curve
|
||||||
const float halfOverlayHeight = overlayHeight / 2;
|
const int numHorizontalVertices = 20;
|
||||||
|
// U texture coordinate width at each quad
|
||||||
|
const float quadTexWidth = 1.0f / (numHorizontalVertices - 1);
|
||||||
|
|
||||||
|
// Get horizontal angle and angle increment from vertical angle and aspect ratio
|
||||||
|
const float horizontalAngle = halfVerticalAngle * 2.0f * overlayAspectRatio;
|
||||||
|
const float angleIncrement = horizontalAngle / (numHorizontalVertices - 1);
|
||||||
|
const float halfHorizontalAngle = horizontalAngle / 2;
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
|
@ -305,16 +313,29 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
|
||||||
glm::vec3 pos = whichCamera.getPosition();
|
glm::vec3 pos = whichCamera.getPosition();
|
||||||
glm::quat rot = myAvatar->getOrientation();
|
glm::quat rot = myAvatar->getOrientation();
|
||||||
glm::vec3 axis = glm::axis(rot);
|
glm::vec3 axis = glm::axis(rot);
|
||||||
pos += rot * glm::vec3(0.0, 0.0, -overlayDistance);
|
|
||||||
|
|
||||||
glTranslatef(pos.x, pos.y, pos.z);
|
glTranslatef(pos.x, pos.y, pos.z);
|
||||||
glRotatef(glm::degrees(glm::angle(rot)), axis.x, axis.y, axis.z);
|
glRotatef(glm::degrees(glm::angle(rot)), axis.x, axis.y, axis.z);
|
||||||
|
|
||||||
|
float leftX, rightX, leftZ, rightZ;
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2f(1, 0); glVertex3f(-halfOverlayWidth, halfOverlayHeight, 0);
|
|
||||||
glTexCoord2f(0, 0); glVertex3f(halfOverlayWidth, halfOverlayHeight, 0);
|
// Place the vertices in a semicircle curve around the camera
|
||||||
glTexCoord2f(0, 1); glVertex3f(halfOverlayWidth, -halfOverlayHeight, 0);
|
for (int i = 0; i < numHorizontalVertices-1; i++) {
|
||||||
glTexCoord2f(1, 1); glVertex3f(-halfOverlayWidth, -halfOverlayHeight, 0);
|
|
||||||
|
// Calculate the X and Z coordinates from the angles and radius from camera
|
||||||
|
leftX = sin(angleIncrement * i - halfHorizontalAngle) * overlayDistance;
|
||||||
|
rightX = sin(angleIncrement * (i + 1) - halfHorizontalAngle) * overlayDistance;
|
||||||
|
leftZ = -cos(angleIncrement * i - halfHorizontalAngle) * overlayDistance;
|
||||||
|
rightZ = -cos(angleIncrement * (i + 1) - halfHorizontalAngle) * overlayDistance;
|
||||||
|
|
||||||
|
glTexCoord2f(quadTexWidth * i, 1); glVertex3f(leftX, halfOverlayHeight, leftZ);
|
||||||
|
glTexCoord2f(quadTexWidth * (i + 1), 1); glVertex3f(rightX, halfOverlayHeight, rightZ);
|
||||||
|
glTexCoord2f(quadTexWidth * (i + 1), 0); glVertex3f(rightX, -halfOverlayHeight, rightZ);
|
||||||
|
glTexCoord2f(quadTexWidth * i, 0); glVertex3f(leftX, -halfOverlayHeight, leftZ);
|
||||||
|
}
|
||||||
|
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
|
@ -28,11 +28,16 @@ public:
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
QOpenGLFramebufferObject* getFramebufferObject();
|
QOpenGLFramebufferObject* getFramebufferObject();
|
||||||
|
float getOculusAngle() const { return _oculusAngle; }
|
||||||
|
|
||||||
|
// Setters
|
||||||
|
void setOculusAngle(float oculusAngle) { _oculusAngle = oculusAngle; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QOpenGLFramebufferObject* _framebufferObject;
|
QOpenGLFramebufferObject* _framebufferObject;
|
||||||
float _trailingAudioLoudness;
|
float _trailingAudioLoudness;
|
||||||
|
float _oculusAngle;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_ApplicationOverlay_h
|
#endif // hifi_ApplicationOverlay_h
|
Loading…
Reference in a new issue