Showing the changes to interface/src/Application.cpp (1 of 12 files). Show all
Unified · Split
| @@ -203,6 +203,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 202 unmodified lines | ||
| 203 | 203 | _mouseVoxelScale(1.0f / 1024.0f), |
| 204 | 204 | _justEditedVoxel(false), |
| 205 | 205 | _isLookingAtOtherAvatar(false), |
| 206 | + _lookatIndicatorScale(1.0f), | |
| 206 | 207 | _paintOn(false), |
| 207 | 208 | _dominantColor(0), |
| 208 | 209 | _perfStatsOn(false), |
| @@ -1854,6 +1855,11 @@ void Application::initMenu() { · 1645 unmodified lines | ||
| 1854 | 1855 | (_simulateLeapHand = debugMenu->addAction("Simulate Leap Hand"))->setCheckable(true); |
| 1855 | 1856 | (_testRaveGlove = debugMenu->addAction("Test RaveGlove"))->setCheckable(true); |
| 1856 | 1857 | |
| 1858 | + QMenu* audioDebugMenu = debugMenu->addMenu("Audio Debugging Tools"); | |
| 1859 | + audioDebugMenu->addAction("Listen Mode Normal", this, SLOT(setListenModeNormal()), Qt::CTRL | Qt::Key_1); | |
| 1860 | + audioDebugMenu->addAction("Listen Mode Point/Radius", this, SLOT(setListenModePoint()), Qt::CTRL | Qt::Key_2); | |
| 1861 | + audioDebugMenu->addAction("Listen Mode Single Source", this, SLOT(setListenModeSingleSource()), Qt::CTRL | Qt::Key_3); | |
| 1862 | + | |
| 1857 | 1863 | QMenu* settingsMenu = menuBar->addMenu("Settings"); |
| 1858 | 1864 | (_settingsAutosave = settingsMenu->addAction("Autosave"))->setCheckable(true); |
| 1859 | 1865 | _settingsAutosave->setChecked(true); |
| @@ -1865,6 +1871,30 @@ void Application::initMenu() { · 5 unmodified lines | ||
| 1865 | 1871 | _networkAccessManager = new QNetworkAccessManager(this); |
| 1866 | 1872 | } |
| 1867 | 1873 | |
| 1874 | +void Application::setListenModeNormal() { | |
| 1875 | + _audio.setListenMode(AudioRingBuffer::NORMAL); | |
| 1876 | +} | |
| 1877 | + | |
| 1878 | +void Application::setListenModePoint() { | |
| 1879 | + _audio.setListenMode(AudioRingBuffer::OMNI_DIRECTIONAL_POINT); | |
| 1880 | + _audio.setListenRadius(1.0); | |
| 1881 | +} | |
| 1882 | + | |
| 1883 | +void Application::setListenModeSingleSource() { | |
| 1884 | + _audio.setListenMode(AudioRingBuffer::SELECTED_SOURCES); | |
| 1885 | + _audio.clearListenSources(); | |
| 1886 | + | |
| 1887 | + glm::vec3 mouseRayOrigin = _myAvatar.getMouseRayOrigin(); | |
| 1888 | + glm::vec3 mouseRayDirection = _myAvatar.getMouseRayDirection(); | |
| 1889 | + glm::vec3 eyePositionIgnored; | |
| 1890 | + uint16_t nodeID; | |
| 1891 | + | |
| 1892 | + if (isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeID)) { | |
| 1893 | + _audio.addListenSource(nodeID); | |
| 1894 | + } | |
| 1895 | +} | |
| 1896 | + | |
| 1897 | + | |
| 1868 | 1898 | void Application::updateFrustumRenderModeAction() { |
| 1869 | 1899 | switch (_frustumDrawingMode) { |
| 1870 | 1900 | default: |
| @@ -1953,7 +1983,13 @@ const float MAX_AVATAR_EDIT_VELOCITY = 1.0f; · 82 unmodified lines | ||
| 1953 | 1983 | const float MAX_VOXEL_EDIT_DISTANCE = 20.0f; |
| 1954 | 1984 | const float HEAD_SPHERE_RADIUS = 0.07; |
| 1955 | 1985 | |
| 1956 | −bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection, glm::vec3& eyePosition) { | |
| 1986 | + | |
| 1987 | +static uint16_t DEFAULT_NODE_ID_REF = 1; | |
| 1988 | + | |
| 1989 | + | |
| 1990 | +bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection, | |
| 1991 | + glm::vec3& eyePosition, uint16_t& nodeID = DEFAULT_NODE_ID_REF) { | |
| 1992 | + | |
| 1957 | 1993 | NodeList* nodeList = NodeList::getInstance(); |
| 1958 | 1994 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { |
| 1959 | 1995 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { |
| @@ -1961,7 +1997,9 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m · 1 unmodified line | ||
| 1961 | 1997 | glm::vec3 headPosition = avatar->getHead().getPosition(); |
| 1962 | 1998 | if (rayIntersectsSphere(mouseRayOrigin, mouseRayDirection, headPosition, HEAD_SPHERE_RADIUS)) { |
| 1963 | 1999 | eyePosition = avatar->getHead().getEyeLevelPosition(); |
| 2000 | + _lookatIndicatorScale = avatar->getScale(); | |
| 1964 | 2001 | _lookatOtherPosition = headPosition; |
| 2002 | + nodeID = avatar->getOwningNode()->getNodeID(); | |
| 1965 | 2003 | return true; |
| 1966 | 2004 | } |
| 1967 | 2005 | } |
| @@ -1971,11 +2009,13 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m · 3 unmodified lines | ||
| 1971 | 2009 | |
| 1972 | 2010 | void Application::renderLookatIndicator(glm::vec3 pointOfInterest, Camera& whichCamera) { |
| 1973 | 2011 | |
| 1974 | − const float DISTANCE_FROM_HEAD_SPHERE = 0.1f; | |
| 2012 | + const float DISTANCE_FROM_HEAD_SPHERE = 0.1f * _lookatIndicatorScale; | |
| 2013 | + const float INDICATOR_RADIUS = 0.1f * _lookatIndicatorScale; | |
| 1975 | 2014 | const float YELLOW[] = { 1.0f, 1.0f, 0.0f }; |
| 2015 | + const int NUM_SEGMENTS = 30; | |
| 1976 | 2016 | glm::vec3 haloOrigin(pointOfInterest.x, pointOfInterest.y + DISTANCE_FROM_HEAD_SPHERE, pointOfInterest.z); |
| 1977 | 2017 | glColor3f(YELLOW[0], YELLOW[1], YELLOW[2]); |
| 1978 | − renderCircle(haloOrigin, 0.1f, glm::vec3(0.0f, 1.0f, 0.0f), 30); | |
| 2018 | + renderCircle(haloOrigin, INDICATOR_RADIUS, IDENTITY_UP, NUM_SEGMENTS); | |
| 1979 | 2019 | } |
| 1980 | 2020 | |
| 1981 | 2021 | void Application::update(float deltaTime) { |
| @@ -2005,7 +2045,9 @@ void Application::update(float deltaTime) { · 23 unmodified lines | ||
| 2005 | 2045 | |
| 2006 | 2046 | // Set where I am looking based on my mouse ray (so that other people can see) |
| 2007 | 2047 | glm::vec3 eyePosition; |
| 2008 | − if ((_isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition))) { | |
| 2048 | + | |
| 2049 | + _isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition); | |
| 2050 | + if (_isLookingAtOtherAvatar) { | |
| 2009 | 2051 | // If the mouse is over another avatar's head... |
| 2010 | 2052 | glm::vec3 myLookAtFromMouse(eyePosition); |
| 2011 | 2053 | _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); |
| @@ -2022,7 +2064,7 @@ void Application::update(float deltaTime) { · 10 unmodified lines | ||
| 2022 | 2064 | glm::vec3 front = orientation * IDENTITY_FRONT; |
| 2023 | 2065 | glm::vec3 up = orientation * IDENTITY_UP; |
| 2024 | 2066 | glm::vec3 towardVoxel = getMouseVoxelWorldCoordinates(_mouseVoxelDragging) |
| 2025 | − - _myAvatar.getCameraPosition(); // is this an error? getCameraPosition dne | |
| 2067 | + - _myAvatar.getCameraPosition(); | |
| 2026 | 2068 | towardVoxel = front * glm::length(towardVoxel); |
| 2027 | 2069 | glm::vec3 lateralToVoxel = glm::cross(up, glm::normalize(towardVoxel)) * glm::length(towardVoxel); |
| 2028 | 2070 | _voxelThrust = glm::vec3(0, 0, 0); |
| @@ -2270,7 +2312,9 @@ void Application::updateAvatar(float deltaTime) { · 241 unmodified lines | ||
| 2270 | 2312 | _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection); |
| 2271 | 2313 | |
| 2272 | 2314 | glm::vec3 eyePosition; |
| 2273 | − if ((_isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition))) { | |
| 2315 | + | |
| 2316 | + _isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition); | |
| 2317 | + if (_isLookingAtOtherAvatar) { | |
| 2274 | 2318 | glm::vec3 myLookAtFromMouse(eyePosition); |
| 2275 | 2319 | _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); |
| 2276 | 2320 | } |
| @@ -2298,7 +2342,7 @@ void Application::updateAvatar(float deltaTime) { · 21 unmodified lines | ||
| 2298 | 2342 | // actually need to calculate the view frustum planes to send these details |
| 2299 | 2343 | // to the server. |
| 2300 | 2344 | loadViewFrustum(_myCamera, _viewFrustum); |
| 2301 | − _myAvatar.setCameraPosition(_viewFrustum.getPosition()); // setCameraPosition() dne | |
| 2345 | + _myAvatar.setCameraPosition(_viewFrustum.getPosition()); | |
| 2302 | 2346 | _myAvatar.setCameraOrientation(_viewFrustum.getOrientation()); |
| 2303 | 2347 | _myAvatar.setCameraFov(_viewFrustum.getFieldOfView()); |
| 2304 | 2348 | _myAvatar.setCameraAspectRatio(_viewFrustum.getAspectRatio()); |