Showing the changes to interface/src/Application.cpp (1 of 117 files). Show all
Unified · Split
| @@ -65,17 +65,21 @@ · 64 unmodified lines | ||
| 65 | 65 | #include <FstReader.h> |
| 66 | 66 | |
| 67 | 67 | #include "Application.h" |
| 68 | −#include "ClipboardScriptingInterface.h" | |
| 69 | 68 | #include "InterfaceVersion.h" |
| 70 | 69 | #include "Menu.h" |
| 71 | −#include "MenuScriptingInterface.h" | |
| 72 | 70 | #include "Util.h" |
| 73 | 71 | #include "devices/OculusManager.h" |
| 74 | 72 | #include "devices/TV3DManager.h" |
| 75 | 73 | #include "renderer/ProgramObject.h" |
| 76 | −#include "ui/TextRenderer.h" | |
| 77 | −#include "InfoView.h" | |
| 74 | + | |
| 75 | +#include "scripting/AudioDeviceScriptingInterface.h" | |
| 76 | +#include "scripting/ClipboardScriptingInterface.h" | |
| 77 | +#include "scripting/MenuScriptingInterface.h" | |
| 78 | +#include "scripting/SettingsScriptingInterface.h" | |
| 79 | + | |
| 80 | +#include "ui/InfoView.h" | |
| 78 | 81 | #include "ui/Snapshot.h" |
| 82 | +#include "ui/TextRenderer.h" | |
| 79 | 83 | |
| 80 | 84 | using namespace std; |
| 81 | 85 | |
| @@ -2163,21 +2167,22 @@ void Application::updateShadowMap() { · 2081 unmodified lines | ||
| 2163 | 2167 | glViewport(0, 0, fbo->width(), fbo->height()); |
| 2164 | 2168 | |
| 2165 | 2169 | glm::vec3 lightDirection = -getSunDirection(); |
| 2166 | − glm::quat rotation = glm::inverse(rotationBetween(IDENTITY_FRONT, lightDirection)); | |
| 2167 | − glm::vec3 translation = glm::vec3(); | |
| 2170 | + glm::quat rotation = rotationBetween(IDENTITY_FRONT, lightDirection); | |
| 2171 | + glm::quat inverseRotation = glm::inverse(rotation); | |
| 2168 | 2172 | float nearScale = 0.0f; |
| 2169 | 2173 | const float MAX_SHADOW_DISTANCE = 2.0f; |
| 2170 | − float farScale = (MAX_SHADOW_DISTANCE - _viewFrustum.getNearClip()) / (_viewFrustum.getFarClip() - _viewFrustum.getNearClip()); | |
| 2174 | + float farScale = (MAX_SHADOW_DISTANCE - _viewFrustum.getNearClip()) / | |
| 2175 | + (_viewFrustum.getFarClip() - _viewFrustum.getNearClip()); | |
| 2171 | 2176 | loadViewFrustum(_myCamera, _viewFrustum); |
| 2172 | 2177 | glm::vec3 points[] = { |
| 2173 | − rotation * (glm::mix(_viewFrustum.getNearTopLeft(), _viewFrustum.getFarTopLeft(), nearScale) + translation), | |
| 2174 | − rotation * (glm::mix(_viewFrustum.getNearTopRight(), _viewFrustum.getFarTopRight(), nearScale) + translation), | |
| 2175 | − rotation * (glm::mix(_viewFrustum.getNearBottomLeft(), _viewFrustum.getFarBottomLeft(), nearScale) + translation), | |
| 2176 | − rotation * (glm::mix(_viewFrustum.getNearBottomRight(), _viewFrustum.getFarBottomRight(), nearScale) + translation), | |
| 2177 | − rotation * (glm::mix(_viewFrustum.getNearTopLeft(), _viewFrustum.getFarTopLeft(), farScale) + translation), | |
| 2178 | − rotation * (glm::mix(_viewFrustum.getNearTopRight(), _viewFrustum.getFarTopRight(), farScale) + translation), | |
| 2179 | − rotation * (glm::mix(_viewFrustum.getNearBottomLeft(), _viewFrustum.getFarBottomLeft(), farScale) + translation), | |
| 2180 | − rotation * (glm::mix(_viewFrustum.getNearBottomRight(), _viewFrustum.getFarBottomRight(), farScale) + translation) }; | |
| 2178 | + inverseRotation * (glm::mix(_viewFrustum.getNearTopLeft(), _viewFrustum.getFarTopLeft(), nearScale)), | |
| 2179 | + inverseRotation * (glm::mix(_viewFrustum.getNearTopRight(), _viewFrustum.getFarTopRight(), nearScale)), | |
| 2180 | + inverseRotation * (glm::mix(_viewFrustum.getNearBottomLeft(), _viewFrustum.getFarBottomLeft(), nearScale)), | |
| 2181 | + inverseRotation * (glm::mix(_viewFrustum.getNearBottomRight(), _viewFrustum.getFarBottomRight(), nearScale)), | |
| 2182 | + inverseRotation * (glm::mix(_viewFrustum.getNearTopLeft(), _viewFrustum.getFarTopLeft(), farScale)), | |
| 2183 | + inverseRotation * (glm::mix(_viewFrustum.getNearTopRight(), _viewFrustum.getFarTopRight(), farScale)), | |
| 2184 | + inverseRotation * (glm::mix(_viewFrustum.getNearBottomLeft(), _viewFrustum.getFarBottomLeft(), farScale)), | |
| 2185 | + inverseRotation * (glm::mix(_viewFrustum.getNearBottomRight(), _viewFrustum.getFarBottomRight(), farScale)) }; | |
| 2181 | 2186 | glm::vec3 minima(FLT_MAX, FLT_MAX, FLT_MAX), maxima(-FLT_MAX, -FLT_MAX, -FLT_MAX); |
| 2182 | 2187 | for (size_t i = 0; i < sizeof(points) / sizeof(points[0]); i++) { |
| 2183 | 2188 | minima = glm::min(minima, points[i]); |
| @@ -2190,9 +2195,20 @@ void Application::updateShadowMap() { · 6 unmodified lines | ||
| 2190 | 2195 | |
| 2191 | 2196 | // save the combined matrix for rendering |
| 2192 | 2197 | _shadowMatrix = glm::transpose(glm::translate(glm::vec3(0.5f, 0.5f, 0.5f)) * glm::scale(glm::vec3(0.5f, 0.5f, 0.5f)) * |
| 2193 | − glm::ortho(minima.x, maxima.x, minima.y, maxima.y, -maxima.z, -minima.z) * | |
| 2194 | − glm::mat4_cast(rotation) * glm::translate(translation)); | |
| 2195 | − | |
| 2198 | + glm::ortho(minima.x, maxima.x, minima.y, maxima.y, -maxima.z, -minima.z) * glm::mat4_cast(inverseRotation)); | |
| 2199 | + | |
| 2200 | + // update the shadow view frustum | |
| 2201 | + _shadowViewFrustum.setPosition(rotation * ((minima + maxima) * 0.5f)); | |
| 2202 | + _shadowViewFrustum.setOrientation(rotation); | |
| 2203 | + _shadowViewFrustum.setOrthographic(true); | |
| 2204 | + _shadowViewFrustum.setWidth(maxima.x - minima.x); | |
| 2205 | + _shadowViewFrustum.setHeight(maxima.y - minima.y); | |
| 2206 | + _shadowViewFrustum.setNearClip(minima.z); | |
| 2207 | + _shadowViewFrustum.setFarClip(maxima.z); | |
| 2208 | + _shadowViewFrustum.setEyeOffsetPosition(glm::vec3()); | |
| 2209 | + _shadowViewFrustum.setEyeOffsetOrientation(glm::quat()); | |
| 2210 | + _shadowViewFrustum.calculate(); | |
| 2211 | + | |
| 2196 | 2212 | glMatrixMode(GL_PROJECTION); |
| 2197 | 2213 | glPushMatrix(); |
| 2198 | 2214 | glLoadIdentity(); |
| @@ -2201,16 +2217,14 @@ void Application::updateShadowMap() { · 2 unmodified lines | ||
| 2201 | 2217 | glMatrixMode(GL_MODELVIEW); |
| 2202 | 2218 | glPushMatrix(); |
| 2203 | 2219 | glLoadIdentity(); |
| 2204 | − glm::vec3 axis = glm::axis(rotation); | |
| 2205 | − glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z); | |
| 2220 | + glm::vec3 axis = glm::axis(inverseRotation); | |
| 2221 | + glRotatef(glm::degrees(glm::angle(inverseRotation)), axis.x, axis.y, axis.z); | |
| 2206 | 2222 | |
| 2207 | 2223 | // store view matrix without translation, which we'll use for precision-sensitive objects |
| 2208 | 2224 | glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat*)&_untranslatedViewMatrix); |
| 2209 | − _viewMatrixTranslation = translation; | |
| 2210 | − | |
| 2211 | − glTranslatef(translation.x, translation.y, translation.z); | |
| 2225 | + _viewMatrixTranslation = glm::vec3(); | |
| 2212 | 2226 | |
| 2213 | − _avatarManager.renderAvatars(true); | |
| 2227 | + _avatarManager.renderAvatars(Avatar::SHADOW_RENDER_MODE); | |
| 2214 | 2228 | _particles.render(); |
| 2215 | 2229 | |
| 2216 | 2230 | glPopMatrix(); |
| @@ -2388,7 +2402,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 171 unmodified lines | ||
| 2388 | 2402 | } |
| 2389 | 2403 | |
| 2390 | 2404 | bool mirrorMode = (whichCamera.getInterpolatedMode() == CAMERA_MODE_MIRROR); |
| 2391 | − _avatarManager.renderAvatars(mirrorMode, selfAvatarOnly); | |
| 2405 | + _avatarManager.renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE, selfAvatarOnly); | |
| 2392 | 2406 | |
| 2393 | 2407 | if (!selfAvatarOnly) { |
| 2394 | 2408 | // Render the world box |
| @@ -3548,6 +3562,8 @@ void Application::loadScript(const QString& fileNameString) { · 1153 unmodified lines | ||
| 3548 | 3562 | |
| 3549 | 3563 | scriptEngine->registerGlobalObject("Overlays", &_overlays); |
| 3550 | 3564 | scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance()); |
| 3565 | + scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance()); | |
| 3566 | + scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance()); | |
| 3551 | 3567 | |
| 3552 | 3568 | QThread* workerThread = new QThread(this); |
| 3553 | 3569 | |