mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
merge + few efficiency ameliorations to importDialog
This commit is contained in:
commit
3eb5ace715
27 changed files with 604 additions and 98 deletions
|
@ -4,6 +4,9 @@ project(hifi)
|
|||
|
||||
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} $ENV{QT_CMAKE_PREFIX_PATH})
|
||||
|
||||
# set our Base SDK to 10.7
|
||||
set(CMAKE_OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk)
|
||||
|
||||
# Find includes in corresponding build directories
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
|
|
4
interface/external/fervor/CMakeLists.txt
vendored
4
interface/external/fervor/CMakeLists.txt
vendored
|
@ -3,8 +3,8 @@ project(Fervor)
|
|||
|
||||
find_package(Qt5Core REQUIRED)
|
||||
find_package(Qt5Network REQUIRED)
|
||||
find_package(Qt5WebKit REQUIRED)
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
find_package(Qt5WebKitWidgets REQUIRED)
|
||||
|
||||
add_definitions(-DFV_GUI)
|
||||
|
||||
|
@ -32,4 +32,4 @@ include_directories(
|
|||
add_library(fervor ${FERVOR_SOURCES} ${FERVOR_HEADERS} ${FERVOR_MOC_SOURCES} ${FERVOR_WRAPPED_UI})
|
||||
target_link_libraries(fervor ${QUAZIP_LIBRARIES})
|
||||
|
||||
qt5_use_modules(fervor Core Network Widgets WebKit)
|
||||
qt5_use_modules(fervor Core Network Widgets WebKitWidgets)
|
BIN
interface/external/quazip/lib/MacOS/libquazip.a
vendored
BIN
interface/external/quazip/lib/MacOS/libquazip.a
vendored
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
[INFO]
|
||||
name=interface
|
||||
name=Interface
|
||||
version=0.0.1
|
||||
organizationName=High Fidelity
|
||||
organizationDomain=highfidelity.io
|
66
interface/resources/shaders/ambient_occlusion.frag
Normal file
66
interface/resources/shaders/ambient_occlusion.frag
Normal file
|
@ -0,0 +1,66 @@
|
|||
#version 120
|
||||
|
||||
//
|
||||
// ambient_occlusion.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 7/5/13.
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
// the depth texture
|
||||
uniform sampler2D depthTexture;
|
||||
|
||||
// the random rotation texture
|
||||
uniform sampler2D rotationTexture;
|
||||
|
||||
// the sample kernel containing the unit offset vectors
|
||||
const int SAMPLE_KERNEL_SIZE = 16;
|
||||
uniform vec3 sampleKernel[SAMPLE_KERNEL_SIZE];
|
||||
|
||||
// the distance to the near clip plane
|
||||
uniform float near;
|
||||
|
||||
// the distance to the far clip plane
|
||||
uniform float far;
|
||||
|
||||
// the left and bottom edges of the view window
|
||||
uniform vec2 leftBottom;
|
||||
|
||||
// the right and top edges of the view window
|
||||
uniform vec2 rightTop;
|
||||
|
||||
// the radius of the effect
|
||||
uniform float radius;
|
||||
|
||||
// the scale for the noise texture
|
||||
uniform vec2 noiseScale;
|
||||
|
||||
// given a texture coordinate, returns the 3D view space z coordinate
|
||||
float texCoordToViewSpaceZ(vec2 texCoord) {
|
||||
return (far * near) / (texture2D(depthTexture, texCoord).r * (far - near) - far);
|
||||
}
|
||||
|
||||
// given a texture coordinate, returns the 3D view space coordinate
|
||||
vec3 texCoordToViewSpace(vec2 texCoord) {
|
||||
float z = texCoordToViewSpaceZ(texCoord);
|
||||
return vec3(((texCoord * 2.0 - vec2(1.0, 1.0)) * (rightTop - leftBottom) + rightTop + leftBottom) * z / (-2.0 * near), z);
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
vec3 rotationX = texture2D(rotationTexture, gl_TexCoord[0].st * noiseScale).rgb;
|
||||
vec3 rotationY = normalize(cross(rotationX, vec3(0.0, 0.0, 1.0)));
|
||||
mat3 rotation = mat3(rotationX, rotationY, cross(rotationX, rotationY));
|
||||
|
||||
vec3 center = texCoordToViewSpace(gl_TexCoord[0].st);
|
||||
|
||||
float occlusion = 4.0;
|
||||
for (int i = 0; i < SAMPLE_KERNEL_SIZE; i++) {
|
||||
vec3 offset = center + rotation * (radius * sampleKernel[i]);
|
||||
vec4 projected = gl_ProjectionMatrix * vec4(offset, 1.0);
|
||||
float depth = texCoordToViewSpaceZ(projected.xy * 0.5 / projected.w + vec2(0.5, 0.5));
|
||||
occlusion += 1.0 - step(offset.z, depth);
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(occlusion, occlusion, occlusion, 0.0) / 16.0;
|
||||
}
|
14
interface/resources/shaders/ambient_occlusion.vert
Normal file
14
interface/resources/shaders/ambient_occlusion.vert
Normal file
|
@ -0,0 +1,14 @@
|
|||
#version 120
|
||||
|
||||
//
|
||||
// ambient_occlusion.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 8/16/13.
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
void main(void) {
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_Position = gl_Vertex;
|
||||
}
|
24
interface/resources/shaders/occlusion_blur.frag
Normal file
24
interface/resources/shaders/occlusion_blur.frag
Normal file
|
@ -0,0 +1,24 @@
|
|||
#version 120
|
||||
|
||||
//
|
||||
// occlusion_blur.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Andrzej Kapolka on 8/16/13.
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
// the original texture
|
||||
uniform sampler2D originalTexture;
|
||||
|
||||
// the scale for the blur kernel
|
||||
uniform vec2 blurScale;
|
||||
|
||||
void main(void) {
|
||||
vec2 minExtents = gl_TexCoord[0].st + blurScale * vec2(-0.5, -0.5);
|
||||
vec2 maxExtents = gl_TexCoord[0].st + blurScale * vec2(1.5, 1.5);
|
||||
gl_FragColor = (texture2D(originalTexture, minExtents) +
|
||||
texture2D(originalTexture, vec2(maxExtents.s, minExtents.t)) +
|
||||
texture2D(originalTexture, vec2(minExtents.s, maxExtents.t)) +
|
||||
texture2D(originalTexture, maxExtents)) * 0.25;
|
||||
}
|
|
@ -64,7 +64,6 @@
|
|||
#include "renderer/ProgramObject.h"
|
||||
#include "ui/TextRenderer.h"
|
||||
#include "Swatch.h"
|
||||
#include "fvupdater.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -95,6 +94,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
_frameCount(0),
|
||||
_fps(120.0f),
|
||||
_justStarted(true),
|
||||
_clipboard(1),
|
||||
_voxelImporter(_window),
|
||||
_wantToKillLocalVoxels(false),
|
||||
_audioScope(256, 200, true),
|
||||
|
@ -127,7 +127,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
_packetsPerSecond(0),
|
||||
_bytesPerSecond(0),
|
||||
_bytesCount(0),
|
||||
_swatch(NULL)
|
||||
_swatch(NULL),
|
||||
_pasteMode(false)
|
||||
{
|
||||
_applicationStartupTime = startup_time;
|
||||
_window->setWindowTitle("Interface");
|
||||
|
@ -210,12 +211,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
NodeList::getInstance()->startSilentNodeRemovalThread();
|
||||
|
||||
_window->setCentralWidget(_glWidget);
|
||||
|
||||
#if defined(Q_OS_MAC) && defined(QT_NO_DEBUG)
|
||||
// if this is a release OS X build use fervor to check for an update
|
||||
FvUpdater::sharedUpdater()->SetFeedURL("https://s3-us-west-1.amazonaws.com/highfidelity/appcast.xml");
|
||||
FvUpdater::sharedUpdater()->CheckForUpdatesSilent();
|
||||
#endif
|
||||
|
||||
// call Menu getInstance static method to set up the menu
|
||||
_window->setMenuBar(Menu::getInstance());
|
||||
|
@ -313,6 +308,11 @@ void Application::initializeGL() {
|
|||
|
||||
// update before the first render
|
||||
update(0.0f);
|
||||
|
||||
// now that things are drawn - if this is an OS X release build we can check for an update
|
||||
#if defined(Q_OS_MAC) && defined(QT_NO_DEBUG)
|
||||
Menu::getInstance()->checkForUpdates();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Application::paintGL() {
|
||||
|
@ -813,6 +813,10 @@ void Application::mousePressEvent(QMouseEvent* event) {
|
|||
_pieMenu.mousePressEvent(_mouseX, _mouseY);
|
||||
}
|
||||
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode) && _pasteMode) {
|
||||
pasteVoxels();
|
||||
}
|
||||
|
||||
if (MAKE_SOUND_ON_VOXEL_CLICK && _isHoverVoxel && !_isHoverVoxelSounding) {
|
||||
_hoverVoxelOriginalColor[0] = _hoverVoxel.red;
|
||||
_hoverVoxelOriginalColor[1] = _hoverVoxel.green;
|
||||
|
@ -1213,10 +1217,11 @@ void Application::importVoxelsToClipboard() {
|
|||
}
|
||||
|
||||
void Application::importVoxels() {
|
||||
_pasteMode = false;
|
||||
|
||||
if (_voxelImporter.exec()) {
|
||||
qDebug("[DEBUG] Import succedded.\n");
|
||||
|
||||
|
||||
_pasteMode = true;
|
||||
} else {
|
||||
qDebug("[DEBUG] Import failed.\n");
|
||||
}
|
||||
|
@ -1382,8 +1387,14 @@ void Application::copyVoxels() {
|
|||
_clipboard.killLocalVoxels();
|
||||
|
||||
// then copy onto it
|
||||
//_voxels.copySubTreeIntoNewTree(selectedNode, _clipboard, true);
|
||||
_voxels.copySubTreeIntoNewTree(selectedNode, &_clipboard, true);
|
||||
}
|
||||
|
||||
_pasteMode = false;
|
||||
}
|
||||
|
||||
void Application::togglePasteMode() {
|
||||
_pasteMode = !_pasteMode;
|
||||
}
|
||||
|
||||
void Application::pasteVoxels() {
|
||||
|
@ -1403,7 +1414,12 @@ void Application::pasteVoxels() {
|
|||
args.newBaseOctCode = calculatedOctCode = pointToVoxel(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s);
|
||||
}
|
||||
|
||||
//_clipboard.recurseTreeWithOperation(sendVoxelsOperation, &args);
|
||||
if (_voxelImporter.getImportWaiting()) {
|
||||
_voxelImporter.getVoxelSystem()->recurseTreeWithOperation(sendVoxelsOperation, &args);
|
||||
_voxelImporter.reset();
|
||||
} else {
|
||||
_clipboard.recurseTreeWithOperation(sendVoxelsOperation, &args);
|
||||
}
|
||||
_voxelEditSender.flushQueue();
|
||||
|
||||
if (calculatedOctCode) {
|
||||
|
@ -1445,10 +1461,15 @@ void Application::initDisplay() {
|
|||
|
||||
void Application::init() {
|
||||
_voxels.init();
|
||||
_clipboard.init();
|
||||
_clipboardViewFrustum.setKeyholeRadius(1000.0f);
|
||||
_clipboardViewFrustum.calculate();
|
||||
_clipboard.setViewFrustum(&_clipboardViewFrustum);
|
||||
|
||||
_environment.init();
|
||||
|
||||
_glowEffect.init();
|
||||
_ambientOcclusionEffect.init();
|
||||
|
||||
_handControl.setScreenDimensions(_glWidget->width(), _glWidget->height());
|
||||
|
||||
|
@ -2330,6 +2351,23 @@ void Application::displaySide(Camera& whichCamera) {
|
|||
glEnable(GL_LIGHTING);
|
||||
}
|
||||
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode) && _pasteMode) {
|
||||
glPushMatrix();
|
||||
glTranslatef(_mouseVoxel.x * TREE_SCALE,
|
||||
_mouseVoxel.y * TREE_SCALE,
|
||||
_mouseVoxel.z * TREE_SCALE);
|
||||
glScalef(_mouseVoxel.s * TREE_SCALE,
|
||||
_mouseVoxel.s * TREE_SCALE,
|
||||
_mouseVoxel.s * TREE_SCALE);
|
||||
|
||||
if (_voxelImporter.getImportWaiting()) {
|
||||
_voxelImporter.getVoxelSystem()->render(true);
|
||||
} else {
|
||||
_clipboard.render(true);
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
_myAvatar.renderScreenTint(SCREEN_TINT_BEFORE_AVATARS, whichCamera);
|
||||
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Avatars)) {
|
||||
|
@ -2375,6 +2413,11 @@ void Application::displaySide(Camera& whichCamera) {
|
|||
renderWorldBox();
|
||||
}
|
||||
|
||||
// render the ambient occlusion effect if enabled
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) {
|
||||
_ambientOcclusionEffect.render();
|
||||
}
|
||||
|
||||
// brad's frustum for debugging
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) {
|
||||
renderViewFrustum(_viewFrustum);
|
||||
|
@ -2393,7 +2436,7 @@ void Application::displaySide(Camera& whichCamera) {
|
|||
}
|
||||
|
||||
renderFollowIndicator();
|
||||
|
||||
|
||||
// render the glow effect
|
||||
_glowEffect.render();
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "Environment.h"
|
||||
#include "GLCanvas.h"
|
||||
#include "PacketHeaders.h"
|
||||
#include "PieMenu.h"
|
||||
#include "SerialInterface.h"
|
||||
#include "Stars.h"
|
||||
#include "Swatch.h"
|
||||
|
@ -43,9 +44,9 @@
|
|||
#include "VoxelSystem.h"
|
||||
#include "VoxelImporter.h"
|
||||
#include "Webcam.h"
|
||||
#include "PieMenu.h"
|
||||
#include "avatar/Avatar.h"
|
||||
#include "avatar/HandControl.h"
|
||||
#include "renderer/AmbientOcclusionEffect.h"
|
||||
#include "renderer/GeometryCache.h"
|
||||
#include "renderer/GlowEffect.h"
|
||||
#include "renderer/TextureCache.h"
|
||||
|
@ -141,6 +142,7 @@ public slots:
|
|||
void importVoxelsToClipboard();
|
||||
void cutVoxels();
|
||||
void copyVoxels();
|
||||
void togglePasteMode();
|
||||
void pasteVoxels();
|
||||
|
||||
void setRenderVoxels(bool renderVoxels);
|
||||
|
@ -240,6 +242,7 @@ private:
|
|||
|
||||
VoxelSystem _voxels;
|
||||
VoxelSystem _clipboard; // if I copy/paste
|
||||
ViewFrustum _clipboardViewFrustum;
|
||||
VoxelImporter _voxelImporter;
|
||||
|
||||
QByteArray _voxelsFilename;
|
||||
|
@ -316,6 +319,7 @@ private:
|
|||
TextureCache _textureCache;
|
||||
|
||||
GlowEffect _glowEffect;
|
||||
AmbientOcclusionEffect _ambientOcclusionEffect;
|
||||
|
||||
#ifndef _WIN32
|
||||
Audio _audio;
|
||||
|
@ -341,6 +345,8 @@ private:
|
|||
ToolsPalette _palette;
|
||||
Swatch _swatch;
|
||||
|
||||
bool _pasteMode;
|
||||
|
||||
PieMenu _pieMenu;
|
||||
|
||||
VoxelSceneStats _voxelSceneStats;
|
||||
|
|
|
@ -407,7 +407,7 @@ Audio::Audio(Oscilloscope* scope, int16_t initialJitterBufferSamples) :
|
|||
return;
|
||||
}
|
||||
|
||||
inputParameters.channelCount = 2; // Stereo input
|
||||
inputParameters.channelCount = 1; // Stereo input
|
||||
inputParameters.sampleFormat = (paInt16 | paNonInterleaved);
|
||||
inputParameters.suggestedLatency = Pa_GetDeviceInfo(inputParameters.device)->defaultLowInputLatency;
|
||||
inputParameters.hostApiSpecificStreamInfo = NULL;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
#include "ImportDialog.h"
|
||||
#include "Application.h"
|
||||
|
||||
#include <QStandardPaths>
|
||||
#include <QGridLayout>
|
||||
|
@ -23,7 +24,7 @@ const QString IMPORT_FILE_TYPES = QObject::tr("Sparse Voxel Oc
|
|||
const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
|
||||
|
||||
|
||||
const glm::vec3 UP = glm::vec3(0, 1, 0);
|
||||
const glm::vec3 UP_VECT = glm::vec3(0, 1, 0);
|
||||
const float ANGULAR_RATE = 0.02f;
|
||||
const float VERTICAL_ANGLE = M_PI_4 / 2.0f;
|
||||
const float RETURN_RATE = 0.02f;
|
||||
|
@ -61,7 +62,7 @@ private:
|
|||
};
|
||||
|
||||
GLWidget::GLWidget(QWidget *parent, VoxelSystem *voxelSystem)
|
||||
: QGLWidget(parent),
|
||||
: QGLWidget(parent, Application::getInstance()->getGLWidget()),
|
||||
_voxelSystem(voxelSystem),
|
||||
_draw(false),
|
||||
_a(0.0f),
|
||||
|
@ -77,11 +78,6 @@ void GLWidget::initializeGL() {
|
|||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glShadeModel (GL_SMOOTH);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
if(_voxelSystem) {
|
||||
_voxelSystem->init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GLWidget::resizeGL(int width, int height) {
|
||||
|
@ -111,7 +107,7 @@ void GLWidget::paintGL() {
|
|||
_targetCenter.y + (glm::length(_targetCenter) + NEAR_CLIP) * sin(_h),
|
||||
_targetCenter.z + (glm::length(_targetCenter) + NEAR_CLIP) * sin(_a),
|
||||
_targetCenter.x, _targetCenter.y, _targetCenter.z,
|
||||
UP.x, UP.y, UP.z);
|
||||
UP_VECT.x, UP_VECT.y, UP_VECT.z);
|
||||
|
||||
|
||||
if (_draw && _voxelSystem) {
|
||||
|
@ -138,7 +134,7 @@ void GLWidget::paintGL() {
|
|||
glVertex3d(2 * _targetCenter.x, 2 * _targetCenter.y, 0 );
|
||||
glEnd();
|
||||
|
||||
_voxelSystem->render(false);
|
||||
_voxelSystem->render(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,11 +217,7 @@ void ImportDialog::reject() {
|
|||
}
|
||||
|
||||
int ImportDialog::exec() {
|
||||
reset();
|
||||
int ret = QFileDialog::exec();
|
||||
preview(false);
|
||||
|
||||
return ret;
|
||||
return QFileDialog::exec();
|
||||
}
|
||||
|
||||
void ImportDialog::setGLCamera(float x, float y, float z) {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <QStandardPaths>
|
||||
|
||||
#include "Application.h"
|
||||
#include "fvupdater.h"
|
||||
#include "PairingHandler.h"
|
||||
#include "Menu.h"
|
||||
#include "Util.h"
|
||||
|
@ -63,6 +64,11 @@ Menu::Menu() :
|
|||
this,
|
||||
SLOT(editPreferences())))->setMenuRole(QAction::PreferencesRole);
|
||||
|
||||
#if defined(Q_OS_MAC) && defined(QT_NO_DEBUG)
|
||||
// show "Check for Updates" in the menu
|
||||
(addActionToQMenuAndActionHash(fileMenu, MenuOption::CheckForUpdates, 0, this, SLOT(checkForUpdates())))->setMenuRole(QAction::ApplicationSpecificRole);
|
||||
#endif
|
||||
|
||||
QMenu* pairMenu = addMenu("Pair");
|
||||
addActionToQMenuAndActionHash(pairMenu, MenuOption::Pair, 0, PairingHandler::getInstance(), SLOT(sendPairRequest()));
|
||||
|
||||
|
@ -151,6 +157,13 @@ Menu::Menu() :
|
|||
&appInstance->getAvatar()->getHead().getFace(),
|
||||
SLOT(cycleRenderMode()));
|
||||
|
||||
addActionToQMenuAndActionHash(renderMenu,
|
||||
MenuOption::GlowMode,
|
||||
0,
|
||||
appInstance->getGlowEffect(),
|
||||
SLOT(cycleRenderMode()));
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::AmbientOcclusion);
|
||||
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::FrameTimer);
|
||||
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::LookAtVectors);
|
||||
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::LookAtIndicator, 0, true);
|
||||
|
@ -235,7 +248,7 @@ Menu::Menu() :
|
|||
addActionToQMenuAndActionHash(voxelMenu, MenuOption::ImportVoxels, Qt::CTRL | Qt::Key_I, appInstance, SLOT(importVoxels()));
|
||||
addActionToQMenuAndActionHash(voxelMenu, MenuOption::CutVoxels, Qt::CTRL | Qt::Key_X, appInstance, SLOT(cutVoxels()));
|
||||
addActionToQMenuAndActionHash(voxelMenu, MenuOption::CopyVoxels, Qt::CTRL | Qt::Key_C, appInstance, SLOT(copyVoxels()));
|
||||
addActionToQMenuAndActionHash(voxelMenu, MenuOption::PasteVoxels, Qt::CTRL | Qt::Key_V, appInstance, SLOT(pasteVoxels()));
|
||||
addActionToQMenuAndActionHash(voxelMenu, MenuOption::PasteVoxels, Qt::CTRL | Qt::Key_V, appInstance, SLOT(togglePasteMode()));
|
||||
|
||||
QMenu* debugMenu = addMenu("Debug");
|
||||
|
||||
|
@ -448,6 +461,14 @@ void Menu::exportSettings() {
|
|||
}
|
||||
}
|
||||
|
||||
void Menu::checkForUpdates() {
|
||||
#if defined(Q_OS_MAC) && defined(QT_NO_DEBUG)
|
||||
qDebug() << "Checking if there are available updates.\n";
|
||||
// if this is a release OS X build use fervor to check for an update
|
||||
FvUpdater::sharedUpdater()->SetFeedURL("http://s3.highfidelity.io/appcast.xml");
|
||||
FvUpdater::sharedUpdater()->CheckForUpdatesSilent();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Menu::loadAction(QSettings* set, QAction* action) {
|
||||
if (action->isChecked() != set->value(action->text(), action->isChecked()).toBool()) {
|
||||
|
|
|
@ -58,6 +58,7 @@ public slots:
|
|||
void saveSettings(QSettings* settings = NULL);
|
||||
void importSettings();
|
||||
void exportSettings();
|
||||
void checkForUpdates();
|
||||
|
||||
private slots:
|
||||
void editPreferences();
|
||||
|
@ -107,11 +108,13 @@ private:
|
|||
|
||||
namespace MenuOption {
|
||||
|
||||
const QString AmbientOcclusion = "Ambient Occlusion";
|
||||
const QString Avatars = "Avatars";
|
||||
const QString AvatarAsBalls = "Avatar as Balls";
|
||||
const QString Atmosphere = "Atmosphere";
|
||||
const QString Bandwidth = "Bandwidth Display";
|
||||
const QString BandwidthDetails = "Bandwidth Details";
|
||||
const QString CheckForUpdates = "Check for Updates...";
|
||||
const QString Collisions = "Collisions";
|
||||
const QString CopyVoxels = "Copy Voxels";
|
||||
const QString CoverageMap = "Render Coverage Map";
|
||||
|
@ -137,6 +140,7 @@ namespace MenuOption {
|
|||
const QString FrameTimer = "Show Timer";
|
||||
const QString FrustumRenderMode = "Render Mode";
|
||||
const QString Fullscreen = "Fullscreen";
|
||||
const QString GlowMode = "Cycle Glow Mode";
|
||||
const QString ImportVoxels = "Import Voxels";
|
||||
const QString ImportVoxelsClipboard = "Import Voxels to Clipboard";
|
||||
const QString IncreaseAvatarSize = "Increase Avatar Size";
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include <QFileInfo>
|
||||
#include <QThreadPool>
|
||||
|
||||
static const int MAX_VOXELS_PER_IMPORT = 2000000;
|
||||
|
||||
class ImportTask : public QObject, public QRunnable {
|
||||
public:
|
||||
ImportTask(VoxelSystem* voxelSystem, const QString &filename);
|
||||
|
@ -21,16 +23,11 @@ private:
|
|||
QString _filename;
|
||||
};
|
||||
|
||||
class LocalVoxelSystem : public VoxelSystem {
|
||||
public:
|
||||
LocalVoxelSystem() : VoxelSystem(1, 2000000) {}
|
||||
|
||||
virtual void removeOutOfView() {}
|
||||
};
|
||||
|
||||
VoxelImporter::VoxelImporter(QWidget* parent)
|
||||
: QObject(parent),
|
||||
_voxelSystem(new LocalVoxelSystem()),
|
||||
_voxelSystem(new VoxelSystem(1, MAX_VOXELS_PER_IMPORT)),
|
||||
_initialized(false),
|
||||
_importWaiting(false),
|
||||
_importDialog(parent, _voxelSystem),
|
||||
_currentTask(NULL),
|
||||
_nextTask(NULL) {
|
||||
|
@ -60,24 +57,35 @@ void VoxelImporter::reset() {
|
|||
_voxelSystem->killLocalVoxels();
|
||||
_importDialog.reset();
|
||||
_filename = "";
|
||||
_currentTask = NULL;
|
||||
_nextTask = NULL;
|
||||
_importWaiting = false;
|
||||
|
||||
if (_nextTask) {
|
||||
delete _nextTask;
|
||||
_nextTask = NULL;
|
||||
}
|
||||
|
||||
if (_currentTask) {
|
||||
_voxelSystem->cancelImport();
|
||||
}
|
||||
}
|
||||
|
||||
int VoxelImporter::exec() {
|
||||
reset();
|
||||
if (!_initialized) {
|
||||
_voxelSystem->init();
|
||||
_importViewFrustum.setKeyholeRadius(100000.0f);
|
||||
_importViewFrustum.calculate();
|
||||
_voxelSystem->setViewFrustum(&_importViewFrustum);
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
reset();
|
||||
int ret = _importDialog.exec();
|
||||
|
||||
if (!ret) {
|
||||
if (_nextTask) {
|
||||
delete _nextTask;
|
||||
_nextTask = NULL;
|
||||
}
|
||||
|
||||
if (_currentTask) {
|
||||
_voxelSystem->cancelImport();
|
||||
}
|
||||
reset();
|
||||
} else {
|
||||
_importDialog.reset();
|
||||
_importWaiting = true;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -93,6 +101,10 @@ int VoxelImporter::preImport() {
|
|||
if (_importDialog.getWantPreview()) {
|
||||
_filename = filename;
|
||||
|
||||
if (_nextTask) {
|
||||
delete _nextTask;
|
||||
}
|
||||
|
||||
_nextTask = new ImportTask(_voxelSystem, _filename);
|
||||
connect(_nextTask, SIGNAL(destroyed()), SLOT(launchTask()));
|
||||
|
||||
|
@ -125,6 +137,10 @@ int VoxelImporter::import() {
|
|||
|
||||
_filename = filename;
|
||||
|
||||
if (_nextTask) {
|
||||
delete _nextTask;
|
||||
}
|
||||
|
||||
_nextTask = new ImportTask(_voxelSystem, _filename);
|
||||
connect(_nextTask, SIGNAL(destroyed()), SLOT(launchTask()));
|
||||
connect(_nextTask, SIGNAL(destroyed()), &_importDialog, SLOT(accept()));
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include <QRunnable>
|
||||
|
||||
class ImportTask;
|
||||
class LocalVoxelSystem;
|
||||
|
||||
class VoxelImporter : public QObject {
|
||||
Q_OBJECT
|
||||
|
@ -25,6 +24,7 @@ public:
|
|||
~VoxelImporter();
|
||||
void reset();
|
||||
|
||||
bool getImportWaiting() const { return _importWaiting; }
|
||||
VoxelSystem* getVoxelSystem() const { return _voxelSystem; }
|
||||
bool getimportIntoClipboard() const { return _importDialog.getImportIntoClipboard(); }
|
||||
|
||||
|
@ -38,6 +38,9 @@ private slots:
|
|||
|
||||
private:
|
||||
VoxelSystem* _voxelSystem;
|
||||
ViewFrustum _importViewFrustum;
|
||||
bool _initialized;
|
||||
bool _importWaiting;
|
||||
|
||||
ImportDialog _importDialog;
|
||||
|
||||
|
|
|
@ -66,6 +66,8 @@ VoxelSystem::VoxelSystem(float treeScale, int maxVoxels) :
|
|||
_dataSourceID = UNKNOWN_NODE_ID;
|
||||
_voxelServerCount = 0;
|
||||
|
||||
_viewFrustum = Application::getInstance()->getViewFrustum();
|
||||
|
||||
connect(_tree, SIGNAL(importSize(float,float,float)), SIGNAL(importSize(float,float,float)));
|
||||
connect(_tree, SIGNAL(importProgress(int)), SIGNAL(importProgress(int)));
|
||||
}
|
||||
|
@ -413,7 +415,7 @@ int VoxelSystem::newTreeToArrays(VoxelNode* node) {
|
|||
int voxelsUpdated = 0;
|
||||
bool shouldRender = false; // assume we don't need to render it
|
||||
// if it's colored, we might need to render it!
|
||||
shouldRender = node->calculateShouldRender(Application::getInstance()->getViewFrustum());
|
||||
shouldRender = node->calculateShouldRender(_viewFrustum);
|
||||
|
||||
node->setShouldRender(shouldRender);
|
||||
// let children figure out their renderness
|
||||
|
@ -655,7 +657,7 @@ void VoxelSystem::updatePartialVBOs() {
|
|||
}
|
||||
|
||||
// if we got to the end of the array, and we're in an active dirty segment...
|
||||
if (inSegment) {
|
||||
if (inSegment) {
|
||||
updateVBOSegment(segmentStart, _voxelsInReadArrays - 1);
|
||||
inSegment = false;
|
||||
}
|
||||
|
@ -832,10 +834,8 @@ bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, void* extraData)
|
|||
}
|
||||
|
||||
void VoxelSystem::falseColorizeInView() {
|
||||
ViewFrustum* viewFrustum = Application::getInstance()->getViewFrustum();
|
||||
|
||||
_nodeCount = 0;
|
||||
_tree->recurseTreeWithOperation(falseColorizeInViewOperation,(void*)viewFrustum);
|
||||
_tree->recurseTreeWithOperation(falseColorizeInViewOperation,(void*)_viewFrustum);
|
||||
qDebug("setting in view false color for %d nodes\n", _nodeCount);
|
||||
_tree->setDirtyBit();
|
||||
setupNewVoxelsForDrawing();
|
||||
|
@ -961,15 +961,13 @@ bool VoxelSystem::getDistanceFromViewRangeOperation(VoxelNode* node, void* extra
|
|||
}
|
||||
|
||||
void VoxelSystem::falseColorizeDistanceFromView() {
|
||||
ViewFrustum* viewFrustum = Application::getInstance()->getViewFrustum();
|
||||
|
||||
_nodeCount = 0;
|
||||
_maxDistance = 0.0;
|
||||
_minDistance = FLT_MAX;
|
||||
_tree->recurseTreeWithOperation(getDistanceFromViewRangeOperation, (void*) viewFrustum);
|
||||
_tree->recurseTreeWithOperation(getDistanceFromViewRangeOperation, (void*) _viewFrustum);
|
||||
qDebug("determining distance range for %d nodes\n", _nodeCount);
|
||||
_nodeCount = 0;
|
||||
_tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation, (void*) viewFrustum);
|
||||
_tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation, (void*) _viewFrustum);
|
||||
qDebug("setting in distance false color for %d nodes\n", _nodeCount);
|
||||
_tree->setDirtyBit();
|
||||
setupNewVoxelsForDrawing();
|
||||
|
@ -979,6 +977,7 @@ void VoxelSystem::falseColorizeDistanceFromView() {
|
|||
class removeOutOfViewArgs {
|
||||
public:
|
||||
VoxelSystem* thisVoxelSystem;
|
||||
ViewFrustum* thisViewFrustum;
|
||||
VoxelNodeBag dontRecurseBag;
|
||||
unsigned long nodesScanned;
|
||||
unsigned long nodesRemoved;
|
||||
|
@ -988,6 +987,7 @@ public:
|
|||
|
||||
removeOutOfViewArgs(VoxelSystem* voxelSystem) :
|
||||
thisVoxelSystem(voxelSystem),
|
||||
thisViewFrustum(voxelSystem->getViewFrustum()),
|
||||
dontRecurseBag(),
|
||||
nodesScanned(0),
|
||||
nodesRemoved(0),
|
||||
|
@ -1020,7 +1020,7 @@ bool VoxelSystem::removeOutOfViewOperation(VoxelNode* node, void* extraData) {
|
|||
for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {
|
||||
VoxelNode* childNode = node->getChildAtIndex(i);
|
||||
if (childNode) {
|
||||
ViewFrustum::location inFrustum = childNode->inFrustum(*Application::getInstance()->getViewFrustum());
|
||||
ViewFrustum::location inFrustum = childNode->inFrustum(*args->thisViewFrustum);
|
||||
switch (inFrustum) {
|
||||
case ViewFrustum::OUTSIDE: {
|
||||
args->nodesOutside++;
|
||||
|
@ -1054,9 +1054,9 @@ bool VoxelSystem::isViewChanging() {
|
|||
bool result = false; // assume the best
|
||||
|
||||
// If our viewFrustum has changed since our _lastKnowViewFrustum
|
||||
if (!_lastKnowViewFrustum.matches(Application::getInstance()->getViewFrustum())) {
|
||||
if (!_lastKnowViewFrustum.matches(_viewFrustum)) {
|
||||
result = true;
|
||||
_lastKnowViewFrustum = *Application::getInstance()->getViewFrustum(); // save last known
|
||||
_lastKnowViewFrustum = *_viewFrustum; // save last known
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1070,9 +1070,9 @@ bool VoxelSystem::hasViewChanged() {
|
|||
}
|
||||
|
||||
// If our viewFrustum has changed since our _lastKnowViewFrustum
|
||||
if (!_lastStableViewFrustum.matches(Application::getInstance()->getViewFrustum())) {
|
||||
if (!_lastStableViewFrustum.matches(_viewFrustum)) {
|
||||
result = true;
|
||||
_lastStableViewFrustum = *Application::getInstance()->getViewFrustum(); // save last stable
|
||||
_lastStableViewFrustum = *_viewFrustum; // save last stable
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1312,6 +1312,10 @@ void VoxelSystem::createSphere(float r,float xc, float yc, float zc, float s, bo
|
|||
setupNewVoxelsForDrawing();
|
||||
};
|
||||
|
||||
void VoxelSystem::copySubTreeIntoNewTree(VoxelNode* startNode, VoxelSystem* destinationTree, bool rebaseToRoot) {
|
||||
_tree->copySubTreeIntoNewTree(startNode, destinationTree->_tree, rebaseToRoot);
|
||||
}
|
||||
|
||||
void VoxelSystem::copySubTreeIntoNewTree(VoxelNode* startNode, VoxelTree* destinationTree, bool rebaseToRoot) {
|
||||
_tree->copySubTreeIntoNewTree(startNode, destinationTree, rebaseToRoot);
|
||||
}
|
||||
|
@ -1320,6 +1324,10 @@ void VoxelSystem::copyFromTreeIntoSubTree(VoxelTree* sourceTree, VoxelNode* dest
|
|||
_tree->copyFromTreeIntoSubTree(sourceTree, destinationNode);
|
||||
}
|
||||
|
||||
void VoxelSystem::recurseTreeWithOperation(RecurseVoxelTreeOperation operation, void* extraData) {
|
||||
_tree->recurseTreeWithOperation(operation, extraData);
|
||||
}
|
||||
|
||||
struct FalseColorizeOccludedArgs {
|
||||
ViewFrustum* viewFrustum;
|
||||
CoverageMap* map;
|
||||
|
@ -1426,7 +1434,7 @@ void VoxelSystem::falseColorizeOccluded() {
|
|||
myCoverageMap.erase();
|
||||
|
||||
FalseColorizeOccludedArgs args;
|
||||
args.viewFrustum = Application::getInstance()->getViewFrustum();
|
||||
args.viewFrustum = _viewFrustum;
|
||||
args.map = &myCoverageMap;
|
||||
args.totalVoxels = 0;
|
||||
args.coloredVoxels = 0;
|
||||
|
@ -1548,7 +1556,7 @@ void VoxelSystem::falseColorizeOccludedV2() {
|
|||
VoxelProjectedPolygon::intersects_calls = 0;
|
||||
|
||||
FalseColorizeOccludedArgs args;
|
||||
args.viewFrustum = Application::getInstance()->getViewFrustum();
|
||||
args.viewFrustum = _viewFrustum;
|
||||
args.mapV2 = &myCoverageMapV2;
|
||||
args.totalVoxels = 0;
|
||||
args.coloredVoxels = 0;
|
||||
|
|
|
@ -43,7 +43,9 @@ public:
|
|||
void simulate(float deltaTime) { };
|
||||
void render(bool texture);
|
||||
|
||||
unsigned long getVoxelsUpdated () const {return _voxelsUpdated;};
|
||||
ViewFrustum* getViewFrustum() const {return _viewFrustum;}
|
||||
void setViewFrustum(ViewFrustum* viewFrustum) {_viewFrustum = viewFrustum;}
|
||||
unsigned long getVoxelsUpdated() const {return _voxelsUpdated;};
|
||||
unsigned long getVoxelsRendered() const {return _voxelsInReadArrays;};
|
||||
|
||||
void loadVoxelsFile(const char* fileName,bool wantColorRandomizer);
|
||||
|
@ -79,9 +81,12 @@ public:
|
|||
void createSphere(float r,float xc, float yc, float zc, float s, bool solid,
|
||||
creationMode mode, bool destructive = false, bool debug = false);
|
||||
|
||||
void copySubTreeIntoNewTree(VoxelNode* startNode, VoxelSystem* destinationTree, bool rebaseToRoot);
|
||||
void copySubTreeIntoNewTree(VoxelNode* startNode, VoxelTree* destinationTree, bool rebaseToRoot);
|
||||
void copyFromTreeIntoSubTree(VoxelTree* sourceTree, VoxelNode* destinationNode);
|
||||
|
||||
void recurseTreeWithOperation(RecurseVoxelTreeOperation operation, void* extraData=NULL);
|
||||
|
||||
CoverageMapV2 myCoverageMapV2;
|
||||
CoverageMap myCoverageMap;
|
||||
|
||||
|
@ -190,6 +195,7 @@ private:
|
|||
|
||||
ViewFrustum _lastKnowViewFrustum;
|
||||
ViewFrustum _lastStableViewFrustum;
|
||||
ViewFrustum* _viewFrustum;
|
||||
|
||||
int newTreeToArrays(VoxelNode *currentNode);
|
||||
void cleanupRemovedVoxels();
|
||||
|
|
|
@ -323,6 +323,7 @@ void Avatar::updateFromGyrosAndOrWebcam(bool gyroLook,
|
|||
Webcam* webcam = Application::getInstance()->getWebcam();
|
||||
glm::vec3 estimatedPosition, estimatedRotation;
|
||||
if (gyros->isActive()) {
|
||||
estimatedPosition = gyros->getEstimatedPosition();
|
||||
estimatedRotation = gyros->getEstimatedRotation();
|
||||
|
||||
} else if (webcam->isActive()) {
|
||||
|
@ -1573,7 +1574,7 @@ void Avatar::loadData(QSettings* settings) {
|
|||
|
||||
_voxels.setVoxelURL(settings->value("voxelURL").toUrl());
|
||||
|
||||
_leanScale = loadSetting(settings, "leanScale", 0.5f);
|
||||
_leanScale = loadSetting(settings, "leanScale", 0.05f);
|
||||
|
||||
_newScale = loadSetting(settings, "scale", 1.0f);
|
||||
setScale(_scale);
|
||||
|
|
147
interface/src/renderer/AmbientOcclusionEffect.cpp
Normal file
147
interface/src/renderer/AmbientOcclusionEffect.cpp
Normal file
|
@ -0,0 +1,147 @@
|
|||
//
|
||||
// AmbientOcclusionEffect.cpp
|
||||
// interface
|
||||
//
|
||||
// Created by Andrzej Kapolka on 7/14/13.
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
// include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL
|
||||
#include "InterfaceConfig.h"
|
||||
|
||||
#include <QOpenGLFramebufferObject>
|
||||
|
||||
#include <glm/gtc/random.hpp>
|
||||
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "AmbientOcclusionEffect.h"
|
||||
#include "Application.h"
|
||||
#include "InterfaceConfig.h"
|
||||
#include "ProgramObject.h"
|
||||
#include "RenderUtil.h"
|
||||
|
||||
const int ROTATION_WIDTH = 4;
|
||||
const int ROTATION_HEIGHT = 4;
|
||||
|
||||
void AmbientOcclusionEffect::init() {
|
||||
switchToResourcesParentIfRequired();
|
||||
|
||||
_occlusionProgram = new ProgramObject();
|
||||
_occlusionProgram->addShaderFromSourceFile(QGLShader::Vertex, "resources/shaders/ambient_occlusion.vert");
|
||||
_occlusionProgram->addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/ambient_occlusion.frag");
|
||||
_occlusionProgram->link();
|
||||
|
||||
// create the sample kernel: an array of spherically distributed offset vectors
|
||||
const int SAMPLE_KERNEL_SIZE = 16;
|
||||
QVector3D sampleKernel[SAMPLE_KERNEL_SIZE];
|
||||
for (int i = 0; i < SAMPLE_KERNEL_SIZE; i++) {
|
||||
// square the length in order to increase density towards the center
|
||||
glm::vec3 vector = glm::sphericalRand(1.0f);
|
||||
float scale = randFloat();
|
||||
const float MIN_VECTOR_LENGTH = 0.01f;
|
||||
const float MAX_VECTOR_LENGTH = 1.0f;
|
||||
vector *= glm::mix(MIN_VECTOR_LENGTH, MAX_VECTOR_LENGTH, scale * scale);
|
||||
sampleKernel[i] = QVector3D(vector.x, vector.y, vector.z);
|
||||
}
|
||||
|
||||
_occlusionProgram->bind();
|
||||
_occlusionProgram->setUniformValue("depthTexture", 0);
|
||||
_occlusionProgram->setUniformValue("rotationTexture", 1);
|
||||
_occlusionProgram->setUniformValueArray("sampleKernel", sampleKernel, SAMPLE_KERNEL_SIZE);
|
||||
_occlusionProgram->setUniformValue("radius", 0.1f);
|
||||
_occlusionProgram->release();
|
||||
|
||||
_nearLocation = _occlusionProgram->uniformLocation("near");
|
||||
_farLocation = _occlusionProgram->uniformLocation("far");
|
||||
_leftBottomLocation = _occlusionProgram->uniformLocation("leftBottom");
|
||||
_rightTopLocation = _occlusionProgram->uniformLocation("rightTop");
|
||||
_noiseScaleLocation = _occlusionProgram->uniformLocation("noiseScale");
|
||||
|
||||
// generate the random rotation texture
|
||||
glGenTextures(1, &_rotationTextureID);
|
||||
glBindTexture(GL_TEXTURE_2D, _rotationTextureID);
|
||||
const int ELEMENTS_PER_PIXEL = 3;
|
||||
unsigned char rotationData[ROTATION_WIDTH * ROTATION_HEIGHT * ELEMENTS_PER_PIXEL];
|
||||
unsigned char* rotation = rotationData;
|
||||
for (int i = 0; i < ROTATION_WIDTH * ROTATION_HEIGHT; i++) {
|
||||
glm::vec3 randvec = glm::sphericalRand(1.0f);
|
||||
*rotation++ = ((randvec.x + 1.0f) / 2.0f) * 255.0f;
|
||||
*rotation++ = ((randvec.y + 1.0f) / 2.0f) * 255.0f;
|
||||
*rotation++ = ((randvec.z + 1.0f) / 2.0f) * 255.0f;
|
||||
}
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, ROTATION_WIDTH, ROTATION_HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, rotationData);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
_blurProgram = new ProgramObject();
|
||||
_blurProgram->addShaderFromSourceFile(QGLShader::Vertex, "resources/shaders/ambient_occlusion.vert");
|
||||
_blurProgram->addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/occlusion_blur.frag");
|
||||
_blurProgram->link();
|
||||
|
||||
_blurProgram->bind();
|
||||
_blurProgram->setUniformValue("originalTexture", 0);
|
||||
_blurProgram->release();
|
||||
|
||||
_blurScaleLocation = _blurProgram->uniformLocation("blurScale");
|
||||
}
|
||||
|
||||
void AmbientOcclusionEffect::render() {
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryDepthTextureID());
|
||||
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, _rotationTextureID);
|
||||
|
||||
// render with the occlusion shader to the secondary buffer
|
||||
QOpenGLFramebufferObject* secondaryFBO = Application::getInstance()->getTextureCache()->getSecondaryFramebufferObject();
|
||||
secondaryFBO->bind();
|
||||
|
||||
float left, right, bottom, top, nearVal, farVal;
|
||||
glm::vec4 nearClipPlane, farClipPlane;
|
||||
Application::getInstance()->getViewFrustum()->computeOffAxisFrustum(
|
||||
left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
|
||||
|
||||
_occlusionProgram->bind();
|
||||
_occlusionProgram->setUniformValue(_nearLocation, nearVal);
|
||||
_occlusionProgram->setUniformValue(_farLocation, farVal);
|
||||
_occlusionProgram->setUniformValue(_leftBottomLocation, left, bottom);
|
||||
_occlusionProgram->setUniformValue(_rightTopLocation, right, top);
|
||||
QSize size = Application::getInstance()->getGLWidget()->size();
|
||||
_occlusionProgram->setUniformValue(_noiseScaleLocation, size.width() / (float)ROTATION_WIDTH,
|
||||
size.height() / (float)ROTATION_HEIGHT);
|
||||
|
||||
renderFullscreenQuad();
|
||||
|
||||
_occlusionProgram->release();
|
||||
|
||||
secondaryFBO->release();
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
// now render secondary to primary with 4x4 blur
|
||||
Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->bind();
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFuncSeparate(GL_ZERO, GL_SRC_COLOR, GL_ZERO, GL_ONE);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, secondaryFBO->texture());
|
||||
|
||||
_blurProgram->bind();
|
||||
_blurProgram->setUniformValue(_blurScaleLocation, 1.0f / size.width(), 1.0f / size.height());
|
||||
|
||||
renderFullscreenQuad();
|
||||
|
||||
_blurProgram->release();
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
40
interface/src/renderer/AmbientOcclusionEffect.h
Normal file
40
interface/src/renderer/AmbientOcclusionEffect.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
//
|
||||
// AmbientOcclusionEffect.h
|
||||
// interface
|
||||
//
|
||||
// Created by Andrzej Kapolka on 7/14/13.
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef __interface__AmbientOcclusionEffect__
|
||||
#define __interface__AmbientOcclusionEffect__
|
||||
|
||||
#include "InterfaceConfig.h"
|
||||
|
||||
class ProgramObject;
|
||||
|
||||
/// A screen space ambient occlusion effect. See John Chapman's tutorial at
|
||||
/// http://john-chapman-graphics.blogspot.co.uk/2013/01/ssao-tutorial.html for reference.
|
||||
class AmbientOcclusionEffect {
|
||||
public:
|
||||
|
||||
void init();
|
||||
|
||||
void render();
|
||||
|
||||
private:
|
||||
|
||||
ProgramObject* _occlusionProgram;
|
||||
int _nearLocation;
|
||||
int _farLocation;
|
||||
int _leftBottomLocation;
|
||||
int _rightTopLocation;
|
||||
int _noiseScaleLocation;
|
||||
|
||||
ProgramObject* _blurProgram;
|
||||
int _blurScaleLocation;
|
||||
|
||||
GLuint _rotationTextureID;
|
||||
};
|
||||
|
||||
#endif /* defined(__interface__AmbientOcclusionEffect__) */
|
|
@ -5,7 +5,7 @@
|
|||
// Created by Andrzej Kapolka on 8/7/13.
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
|
||||
// include this before QGLWidget, which includes an earlier version of OpenGL
|
||||
// include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL
|
||||
#include "InterfaceConfig.h"
|
||||
|
||||
#include <QOpenGLFramebufferObject>
|
||||
|
@ -13,6 +13,7 @@
|
|||
#include "Application.h"
|
||||
#include "GlowEffect.h"
|
||||
#include "ProgramObject.h"
|
||||
#include "RenderUtil.h"
|
||||
|
||||
GlowEffect::GlowEffect() : _renderMode(BLUR_ADD_MODE) {
|
||||
}
|
||||
|
@ -68,19 +69,6 @@ void GlowEffect::end() {
|
|||
glBlendColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
static void renderFullscreenQuad() {
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0f, 0.0f);
|
||||
glVertex2f(-1.0f, -1.0f);
|
||||
glTexCoord2f(1.0f, 0.0f);
|
||||
glVertex2f(1.0f, -1.0f);
|
||||
glTexCoord2f(1.0f, 1.0f);
|
||||
glVertex2f(1.0f, 1.0f);
|
||||
glTexCoord2f(0.0f, 1.0f);
|
||||
glVertex2f(-1.0f, 1.0f);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void GlowEffect::render() {
|
||||
QOpenGLFramebufferObject* primaryFBO = Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject();
|
||||
primaryFBO->release();
|
||||
|
@ -95,6 +83,7 @@ void GlowEffect::render() {
|
|||
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
if (_isEmpty) {
|
||||
// copy the primary to the screen
|
||||
|
@ -210,6 +199,7 @@ void GlowEffect::render() {
|
|||
|
||||
glEnable(GL_BLEND);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
|
|
22
interface/src/renderer/RenderUtil.cpp
Normal file
22
interface/src/renderer/RenderUtil.cpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
// RenderUtil.cpp
|
||||
// interface
|
||||
//
|
||||
// Created by Andrzej Kapolka on 8/15/13.
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
|
||||
#include "InterfaceConfig.h"
|
||||
#include "RenderUtil.h"
|
||||
|
||||
void renderFullscreenQuad() {
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0f, 0.0f);
|
||||
glVertex2f(-1.0f, -1.0f);
|
||||
glTexCoord2f(1.0f, 0.0f);
|
||||
glVertex2f(1.0f, -1.0f);
|
||||
glTexCoord2f(1.0f, 1.0f);
|
||||
glVertex2f(1.0f, 1.0f);
|
||||
glTexCoord2f(0.0f, 1.0f);
|
||||
glVertex2f(-1.0f, 1.0f);
|
||||
glEnd();
|
||||
}
|
15
interface/src/renderer/RenderUtil.h
Normal file
15
interface/src/renderer/RenderUtil.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
//
|
||||
// RenderUtil.h
|
||||
// interface
|
||||
//
|
||||
// Created by Andrzej Kapolka on 8/15/13.
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef __interface__RenderUtil__
|
||||
#define __interface__RenderUtil__
|
||||
|
||||
/// Renders a quad from (-1, -1, 0) to (1, 1, 0) with texture coordinates from (0, 0) to (1, 1).
|
||||
void renderFullscreenQuad();
|
||||
|
||||
#endif /* defined(__interface__RenderUtil__) */
|
|
@ -5,6 +5,9 @@
|
|||
// Created by Andrzej Kapolka on 8/6/13.
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
|
||||
// include this before QGLWidget, which includes an earlier version of OpenGL
|
||||
#include "InterfaceConfig.h"
|
||||
|
||||
#include <QGLWidget>
|
||||
#include <QOpenGLFramebufferObject>
|
||||
|
||||
|
@ -23,6 +26,7 @@ TextureCache::~TextureCache() {
|
|||
}
|
||||
if (_primaryFramebufferObject != NULL) {
|
||||
delete _primaryFramebufferObject;
|
||||
glDeleteTextures(1, &_primaryDepthTextureID);
|
||||
}
|
||||
if (_secondaryFramebufferObject != NULL) {
|
||||
delete _secondaryFramebufferObject;
|
||||
|
@ -60,25 +64,40 @@ GLuint TextureCache::getPermutationNormalTextureID() {
|
|||
|
||||
QOpenGLFramebufferObject* TextureCache::getPrimaryFramebufferObject() {
|
||||
if (_primaryFramebufferObject == NULL) {
|
||||
_primaryFramebufferObject = new QOpenGLFramebufferObject(Application::getInstance()->getGLWidget()->size(),
|
||||
QOpenGLFramebufferObject::Depth);
|
||||
Application::getInstance()->getGLWidget()->installEventFilter(this);
|
||||
_primaryFramebufferObject = createFramebufferObject();
|
||||
|
||||
glGenTextures(1, &_primaryDepthTextureID);
|
||||
glBindTexture(GL_TEXTURE_2D, _primaryDepthTextureID);
|
||||
QSize size = Application::getInstance()->getGLWidget()->size();
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, size.width(), size.height(),
|
||||
0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
_primaryFramebufferObject->bind();
|
||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, _primaryDepthTextureID, 0);
|
||||
_primaryFramebufferObject->release();
|
||||
}
|
||||
return _primaryFramebufferObject;
|
||||
}
|
||||
|
||||
GLuint TextureCache::getPrimaryDepthTextureID() {
|
||||
// ensure that the primary framebuffer object is initialized before returning the depth texture id
|
||||
getPrimaryFramebufferObject();
|
||||
return _primaryDepthTextureID;
|
||||
}
|
||||
|
||||
QOpenGLFramebufferObject* TextureCache::getSecondaryFramebufferObject() {
|
||||
if (_secondaryFramebufferObject == NULL) {
|
||||
_secondaryFramebufferObject = new QOpenGLFramebufferObject(Application::getInstance()->getGLWidget()->size());
|
||||
Application::getInstance()->getGLWidget()->installEventFilter(this);
|
||||
_secondaryFramebufferObject = createFramebufferObject();
|
||||
}
|
||||
return _secondaryFramebufferObject;
|
||||
}
|
||||
|
||||
QOpenGLFramebufferObject* TextureCache::getTertiaryFramebufferObject() {
|
||||
if (_tertiaryFramebufferObject == NULL) {
|
||||
_tertiaryFramebufferObject = new QOpenGLFramebufferObject(Application::getInstance()->getGLWidget()->size());
|
||||
Application::getInstance()->getGLWidget()->installEventFilter(this);
|
||||
_tertiaryFramebufferObject = createFramebufferObject();
|
||||
}
|
||||
return _tertiaryFramebufferObject;
|
||||
}
|
||||
|
@ -89,6 +108,7 @@ bool TextureCache::eventFilter(QObject* watched, QEvent* event) {
|
|||
if (_primaryFramebufferObject != NULL && _primaryFramebufferObject->size() != size) {
|
||||
delete _primaryFramebufferObject;
|
||||
_primaryFramebufferObject = NULL;
|
||||
glDeleteTextures(1, &_primaryDepthTextureID);
|
||||
}
|
||||
if (_secondaryFramebufferObject != NULL && _secondaryFramebufferObject->size() != size) {
|
||||
delete _secondaryFramebufferObject;
|
||||
|
@ -101,3 +121,15 @@ bool TextureCache::eventFilter(QObject* watched, QEvent* event) {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QOpenGLFramebufferObject* TextureCache::createFramebufferObject() {
|
||||
QOpenGLFramebufferObject* fbo = new QOpenGLFramebufferObject(Application::getInstance()->getGLWidget()->size());
|
||||
Application::getInstance()->getGLWidget()->installEventFilter(this);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, fbo->texture());
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
return fbo;
|
||||
}
|
||||
|
|
|
@ -15,25 +15,43 @@
|
|||
|
||||
class QOpenGLFramebufferObject;
|
||||
|
||||
/// Stored cached textures, including render-to-texture targets.
|
||||
class TextureCache : public QObject {
|
||||
public:
|
||||
|
||||
TextureCache();
|
||||
~TextureCache();
|
||||
|
||||
/// Returns the ID of the permutation/normal texture used for Perlin noise shader programs. This texture
|
||||
/// has two lines: the first, a set of random numbers in [0, 255] to be used as permutation offsets, and
|
||||
/// the second, a set of random unit vectors to be used as noise gradients.
|
||||
GLuint getPermutationNormalTextureID();
|
||||
|
||||
/// Returns a pointer to the primary framebuffer object. This render target includes a depth component, and is
|
||||
/// used for scene rendering.
|
||||
QOpenGLFramebufferObject* getPrimaryFramebufferObject();
|
||||
|
||||
/// Returns the ID of the primary framebuffer object's depth texture. This contains the Z buffer used in rendering.
|
||||
GLuint getPrimaryDepthTextureID();
|
||||
|
||||
/// Returns a pointer to the secondary framebuffer object, used as an additional render target when performing full
|
||||
/// screen effects.
|
||||
QOpenGLFramebufferObject* getSecondaryFramebufferObject();
|
||||
|
||||
/// Returns a pointer to the tertiary framebuffer object, used as an additional render target when performing full
|
||||
/// screen effects.
|
||||
QOpenGLFramebufferObject* getTertiaryFramebufferObject();
|
||||
|
||||
virtual bool eventFilter(QObject* watched, QEvent* event);
|
||||
|
||||
private:
|
||||
|
||||
QOpenGLFramebufferObject* createFramebufferObject();
|
||||
|
||||
GLuint _permutationNormalTextureID;
|
||||
|
||||
QOpenGLFramebufferObject* _primaryFramebufferObject;
|
||||
GLuint _primaryDepthTextureID;
|
||||
QOpenGLFramebufferObject* _secondaryFramebufferObject;
|
||||
QOpenGLFramebufferObject* _tertiaryFramebufferObject;
|
||||
};
|
||||
|
|
|
@ -10,9 +10,10 @@ def hifiJob(String targetName, Boolean deploy) {
|
|||
|
||||
scm {
|
||||
git(GIT_REPO_URL, 'master') { node ->
|
||||
node / includedRegions << "${targetName}/.*\nlibraries/.*"
|
||||
node / 'userRemoteConfigs' / 'hudson.plugins.git.UserRemoteConfig' / 'name' << ''
|
||||
node / 'userRemoteConfigs' / 'hudson.plugins.git.UserRemoteConfig' / 'refspec' << ''
|
||||
node << {
|
||||
includedRegions "${targetName}/.*\nlibraries/.*"
|
||||
useShallowClone true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +109,6 @@ def targets = [
|
|||
'pairing-server':true,
|
||||
'space-server':true,
|
||||
'voxel-server':true,
|
||||
'interface':false,
|
||||
]
|
||||
|
||||
/* setup all of the target jobs to use the above template */
|
||||
|
@ -116,6 +116,30 @@ for (target in targets) {
|
|||
queue hifiJob(target.key, target.value)
|
||||
}
|
||||
|
||||
/* setup the OS X interface builds */
|
||||
interfaceOSXJob = hifiJob('interface', false)
|
||||
interfaceOSXJob.with {
|
||||
name 'hifi-interface-osx'
|
||||
|
||||
scm {
|
||||
git(GIT_REPO_URL, 'stable') { node ->
|
||||
node << {
|
||||
includedRegions "interface/.*\nlibraries/.*"
|
||||
useShallowClone true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configure { project ->
|
||||
project << {
|
||||
assignedNode 'interface-mini'
|
||||
canRoam false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
queue interfaceOSXJob
|
||||
|
||||
/* setup the parametrized build job for builds from jenkins */
|
||||
parameterizedJob = hifiJob('$TARGET', true)
|
||||
parameterizedJob.with {
|
||||
|
@ -128,7 +152,11 @@ parameterizedJob.with {
|
|||
}
|
||||
scm {
|
||||
git('git@github.com:/$GITHUB_USER/hifi.git', '$GIT_BRANCH') { node ->
|
||||
node / 'wipeOutWorkspace' << true
|
||||
node << {
|
||||
wipeOutWorkspace true
|
||||
useShallowClone true
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
configure { project ->
|
||||
|
@ -144,7 +172,11 @@ parameterizedJob.with {
|
|||
doxygenJob = hifiJob('docs', false)
|
||||
doxygenJob.with {
|
||||
scm {
|
||||
git(GIT_REPO_URL, 'master') {}
|
||||
git(GIT_REPO_URL, 'master') { node ->
|
||||
node << {
|
||||
useShallowClone true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configure { project ->
|
||||
|
|
|
@ -1612,6 +1612,9 @@ bool VoxelTree::readFromSquareARGB32Pixels(const char* filename) {
|
|||
}
|
||||
|
||||
bool VoxelTree::readFromSchematicFile(const char *fileName) {
|
||||
_stopImport = false;
|
||||
emit importProgress(0);
|
||||
|
||||
std::stringstream ss;
|
||||
int err = retrieveData(std::string(fileName), ss);
|
||||
if (err && ss.get() != TAG_Compound) {
|
||||
|
|
Loading…
Reference in a new issue