Working on syncing with master

This commit is contained in:
Brad Davis 2015-06-22 13:46:03 -07:00
parent 9f98547390
commit 967fc62da7
6 changed files with 7 additions and 264 deletions

View file

@ -137,7 +137,6 @@ class Application;
typedef bool (Application::* AcceptURLMethod)(const QString &);
class Application : public QApplication, public AbstractViewStateInterface, AbstractScriptingServicesInterface, PluginContainer {
Q_OBJECT
@ -251,8 +250,6 @@ public:
Overlays& getOverlays() { return _overlays; }
float getFps() const { return _fps; }
//const glm::vec3& getViewMatrixTranslation() const { return _viewMatrixTranslation; }
//void setViewMatrixTranslation(const glm::vec3& translation) { _viewMatrixTranslation = translation; }
virtual const Transform& getViewTransform() const { return _viewTransform; }
virtual Transform& getViewTransform() { return _viewTransform; }
@ -281,7 +278,7 @@ public:
QImage renderAvatarBillboard(RenderArgs* renderArgs);
void displaySide(RenderArgs* renderArgs, const Camera& camera, bool selfAvatarOnly = false, bool billboard = false);
void displaySide(RenderArgs* renderArgs, Camera& whichCamera, bool selfAvatarOnly = false, bool billboard = false);
void getModelViewMatrix(glm::dmat4* modelViewMatrix);
void getProjectionMatrix(glm::dmat4* projectionMatrix);
@ -453,12 +450,8 @@ private slots:
void connectedToDomain(const QString& hostname);
#if 0
friend class HMDToolsDialog;
void setFullscreen(bool fullscreen);
#endif
void cameraMenuChanged();
void rotationModeChanged();
void closeMirrorView();
void restoreMirrorView();
@ -571,10 +564,6 @@ private:
Transform _viewTransform;
glm::mat4 _projectionMatrix;
/*
glm::mat4 _untranslatedViewMatrix;
glm::vec3 _viewMatrixTranslation;
*/
float _scaleMirror;
float _rotateMirror;

View file

@ -200,7 +200,6 @@ namespace MenuOption {
const QString CenterPlayerInView = "Center Player In View";
const QString GlowWhenSpeaking = "Glow When Speaking";
const QString NamesAboveHeads = "Names Above Heads";
const QString GoToUser = "Go To User";
const QString IncreaseAvatarSize = "Increase Avatar Size";
const QString KeyboardMotorControl = "Enable Keyboard Motor Control";
const QString LeapMotionOnHMD = "Leap Motion on HMD";

View file

@ -771,7 +771,6 @@ void SkeletonModel::resetShapePositionsToDefaultPose() {
void SkeletonModel::renderBoundingCollisionShapes(float alpha) {
const int BALL_SUBDIVISIONS = 10;
#if 0
if (_shapes.isEmpty()) {
// the bounding shape has not been propery computed
// so no need to render it
@ -802,7 +801,6 @@ void SkeletonModel::renderBoundingCollisionShapes(float alpha) {
Avatar::renderJointConnectingCone( origin, axis, _boundingShape.getRadius(), _boundingShape.getRadius(), glm::vec4(0.6f, 0.8f, 0.6f, alpha));
glPopMatrix();
#endif
}
bool SkeletonModel::hasSkeleton() {

View file

@ -1,209 +0,0 @@
#include "ApplicationOverlayCompositor.h"
#include <TextureCache.h>
#include <PathUtils.h>
#include <ViewFrustum.h>
#include <MatrixStack.h>
#include <gpu/GLBackend.h>
#define DEFAULT_HMD_UI_ANGULAR_SIZE 72.0f
ApplicationOverlayCompositor::ApplicationOverlayCompositor() {
using namespace oglplus;
auto currentContext = QOpenGLContext::currentContext();
Q_ASSERT(currentContext);
_canvas.create(currentContext);
_canvas.makeCurrent();
Q_ASSERT(0 == glGetError());
currentContext = QOpenGLContext::currentContext();
Q_ASSERT(currentContext);
Context::ClearColor(0, 0, 0, 1);
Q_ASSERT(0 == glGetError());
Context::BlendFunc(BlendFunction::SrcAlpha, BlendFunction::OneMinusSrcAlpha);
Q_ASSERT(0 == glGetError());
Context::Disable(Capability::Blend);
Q_ASSERT(0 == glGetError());
Context::Disable(Capability::DepthTest);
Q_ASSERT(0 == glGetError());
Context::Disable(Capability::CullFace);
Q_ASSERT(0 == glGetError());
_program = loadDefaultShader();
_plane = loadPlane(_program);
_program = loadDefaultShader();
_plane = loadPlane(_program);
_hmdUiSurface = loadSphereSection(_program, glm::radians(DEFAULT_HMD_UI_ANGULAR_SIZE));
_crosshairTexture = DependencyManager::get<TextureCache>()->
getImageTexture(PathUtils::resourcesPath() + "images/sixense-reticle.png");
}
GLuint ApplicationOverlayCompositor::composite(DisplayPlugin* plugin,
GLuint sceneTexture, const glm::uvec2& sceneSize,
GLuint overlayTexture, const glm::uvec2& overlaySize) {
using namespace oglplus;
_canvas.makeCurrent();
if (!_fbo || sceneSize != _fbo->size) {
_fbo = BasicFramebufferWrapperPtr(new BasicFramebufferWrapper());
_fbo->Init(sceneSize);
}
_fbo->Bound(Framebuffer::Target::Draw, [&] {
Context::Clear().ColorBuffer();
if (plugin->isHmd()) {
compositeHmd(plugin, sceneTexture, sceneSize, overlayTexture, overlaySize);
} else if (plugin->isStereo()) {
compositeStereo(plugin, sceneTexture, sceneSize, overlayTexture, overlaySize);
} else {
composite2D(plugin, sceneTexture, sceneSize, overlayTexture, overlaySize);
}
});
GLuint result = GetName(_fbo->color);
_canvas.doneCurrent();
return result;
}
void ApplicationOverlayCompositor::composite2D(DisplayPlugin* plugin,
GLuint sceneTexture, const glm::uvec2& sceneSize,
GLuint overlayTexture, const glm::uvec2& overlaySize) {
using namespace oglplus;
const uvec2 size = toGlm(plugin->getDeviceSize());
Q_ASSERT(0 == glGetError());
Context::Viewport(size.x, size.y);
_program->Bind();
Mat4Uniform(*_program, "ModelView").Set(mat4());
Mat4Uniform(*_program, "Projection").Set(mat4());
glBindTexture(GL_TEXTURE_2D, sceneTexture);
_plane->Use();
_plane->Draw();
Context::Enable(Capability::Blend);
glBindTexture(GL_TEXTURE_2D, overlayTexture);
_plane->Draw();
Context::Disable(Capability::Blend);
glBindTexture(GL_TEXTURE_2D, 0);
// FIXME add the cursor
Q_ASSERT(0 == glGetError());
}
template <typename F>
void sbs_for_each_eye(const uvec2& size, F f) {
QRect r(QPoint(0, 0), QSize(size.x / 2, size.y));
for_each_eye([&](Eye eye) {
oglplus::Context::Viewport(r.x(), r.y(), r.width(), r.height());
f(eye);
}, [&] {
r.moveLeft(r.width());
});
}
void ApplicationOverlayCompositor::compositeStereo(DisplayPlugin* plugin,
GLuint sceneTexture, const glm::uvec2& sceneSize,
GLuint overlayTexture, const glm::uvec2& overlaySize) {
using namespace oglplus;
Q_ASSERT(0 == glGetError());
const uvec2 size = sceneSize;
Context::Viewport(size.x, size.y);
_program->Bind();
Mat4Uniform(*_program, "ModelView").Set(mat4());
Mat4Uniform(*_program, "Projection").Set(mat4());
glBindTexture(GL_TEXTURE_2D, sceneTexture);
_plane->Use();
_plane->Draw();
// FIXME the
const float screenAspect = aspect(size);
const GLfloat distance = 1.0f;
const GLfloat halfQuadHeight = distance * tan(DEFAULT_FIELD_OF_VIEW_DEGREES);
const GLfloat halfQuadWidth = halfQuadHeight * screenAspect;
const GLfloat quadWidth = halfQuadWidth * 2.0f;
const GLfloat quadHeight = halfQuadHeight * 2.0f;
vec3 quadSize(quadWidth, quadHeight, 1.0f);
quadSize = vec3(1.0f) / quadSize;
using namespace oglplus;
Context::Enable(Capability::Blend);
glBindTexture(GL_TEXTURE_2D, overlayTexture);
mat4 pr = glm::perspective(glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES), screenAspect, DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP);
Mat4Uniform(*_program, "Projection").Set(pr);
// Position the camera relative to the overlay texture
MatrixStack mv;
mv.translate(vec3(0, 0, -distance)).scale(vec3(0.7f, 0.7f / screenAspect, 1.0f)); // .scale(vec3(quadWidth, quadHeight, 1.0));
sbs_for_each_eye(size, [&](Eye eye) {
mv.withPush([&] {
// translate
mv.top() = plugin->getModelview(eye, mv.top());
Mat4Uniform(*_program, "ModelView").Set(mv.top());
_plane->Draw();
});
});
glBindTexture(GL_TEXTURE_2D, gpu::GLBackend::getTextureID(_crosshairTexture));
glm::vec2 canvasSize = plugin->getCanvasSize();
glm::vec2 mouse = vec2(0); // toGlm(_window->mapFromGlobal(QCursor::pos()));
mouse /= canvasSize;
mouse *= 2.0f;
mouse -= 1.0f;
mouse.y *= -1.0f;
sbs_for_each_eye(size, [&](Eye eye) {
mv.withPush([&] {
// translate
mv.top() = plugin->getModelview(eye, mv.top());
mv.translate(mouse);
//mv.scale(0.05f);
mv.scale(vec3(0.025f, 0.05f, 1.0f));
Mat4Uniform(*_program, "ModelView").Set(mv.top());
_plane->Draw();
});
});
Context::Disable(Capability::Blend);
}
void ApplicationOverlayCompositor::compositeHmd(DisplayPlugin* plugin,
GLuint sceneTexture, const glm::uvec2& sceneSize,
GLuint overlayTexture, const glm::uvec2& overlaySize) {
using namespace oglplus;
auto size = sceneSize;
Context::Viewport(size.x, size.y);
glClearColor(0, 0, 0, 0);
Context::Clear().ColorBuffer();
_program->Bind();
Mat4Uniform(*_program, "Projection").Set(mat4());
Mat4Uniform(*_program, "ModelView").Set(mat4());
glBindTexture(GL_TEXTURE_2D, sceneTexture);
_plane->Use();
_plane->Draw();
Context::Enable(Capability::Blend);
glBindTexture(GL_TEXTURE_2D, overlayTexture);
for_each_eye([&](Eye eye) {
Context::Viewport(eye == Left ? 0 : size.x / 2, 0, size.x / 2, size.y);
glm::mat4 m = plugin->getProjection(eye, glm::mat4());
Mat4Uniform(*_program, "Projection").Set(m);
Mat4Uniform(*_program, "ModelView").Set(glm::scale(glm::inverse(plugin->getModelview(eye, mat4())), vec3(1)));
_hmdUiSurface->Use();
_hmdUiSurface->Draw();
});
Context::Disable(Capability::Blend);
}

View file

@ -1,37 +0,0 @@
#pragma once
#include <gpu/Texture.h>
#include <display-plugins/DisplayPlugin.h>
#include <display-plugins/OglplusHelpers.h>
#include <OffscreenGlCanvas.h>
class ApplicationOverlayCompositor {
public:
ApplicationOverlayCompositor();
GLuint composite(DisplayPlugin* plugin,
GLuint sceneTexture, const glm::uvec2& sceneSize,
GLuint overlayTexture, const glm::uvec2& overlaySize);
private:
OffscreenGlCanvas _canvas;
BasicFramebufferWrapperPtr _fbo;
ProgramPtr _program;
ShapeWrapperPtr _plane;
ShapeWrapperPtr _hmdUiSurface;
gpu::TexturePointer _crosshairTexture;
void composite2D(DisplayPlugin* plugin,
GLuint sceneTexture, const glm::uvec2& sceneSize,
GLuint overlayTexture, const glm::uvec2& overlaySize);
void compositeStereo(DisplayPlugin* plugin,
GLuint sceneTexture, const glm::uvec2& sceneSize,
GLuint overlayTexture, const glm::uvec2& overlaySize);
void compositeHmd(DisplayPlugin* plugin,
GLuint sceneTexture, const glm::uvec2& sceneSize,
GLuint overlayTexture, const glm::uvec2& overlaySize);
};
using CompositorPtr = std::shared_ptr<ApplicationOverlayCompositor>;

View file

@ -38,9 +38,9 @@ void LocalModelsOverlay::render(RenderArgs* args) {
if (_visible) {
float glowLevel = getGlowLevel();
QSharedPointer<Glower> glower;
Glower* glower = NULL;
if (glowLevel > 0.0f) {
glower = QSharedPointer<Glower>(new Glower(glowLevel));
glower = new Glower(glowLevel);
}
glPushMatrix(); {
@ -52,6 +52,9 @@ void LocalModelsOverlay::render(RenderArgs* args) {
Application::getInstance()->setViewMatrixTranslation(oldTranslation);
#endif
} glPopMatrix();
if (glower) {
delete glower;
}
}
}