Showing the changes to interface/src/Application.cpp (1 of 4 files). Show all
Unified · Split
| @@ -55,6 +55,7 @@ · 54 unmodified lines | ||
| 55 | 55 | #include <PacketHeaders.h> |
| 56 | 56 | #include <PairingHandler.h> |
| 57 | 57 | #include <PerfStat.h> |
| 58 | +#include <math.h> | |
| 58 | 59 | |
| 59 | 60 | #include "Application.h" |
| 60 | 61 | #include "InterfaceConfig.h" |
| @@ -196,6 +197,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 135 unmodified lines | ||
| 196 | 197 | _mousePressed(false), |
| 197 | 198 | _mouseVoxelScale(1.0f / 1024.0f), |
| 198 | 199 | _justEditedVoxel(false), |
| 200 | + _isLookingAtOtherAvatar(false), | |
| 199 | 201 | _paintOn(false), |
| 200 | 202 | _dominantColor(0), |
| 201 | 203 | _perfStatsOn(false), |
| @@ -1881,6 +1883,7 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m · 1679 unmodified lines | ||
| 1881 | 1883 | glm::vec3 headPosition = avatar->getHead().getPosition(); |
| 1882 | 1884 | if (rayIntersectsSphere(mouseRayOrigin, mouseRayDirection, headPosition, HEAD_SPHERE_RADIUS)) { |
| 1883 | 1885 | eyePosition = avatar->getHead().getEyeLevelPosition(); |
| 1886 | + renderLookatIndicator(headPosition); | |
| 1884 | 1887 | return true; |
| 1885 | 1888 | } |
| 1886 | 1889 | } |
| @@ -1888,6 +1891,26 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m · 1 unmodified line | ||
| 1888 | 1891 | return false; |
| 1889 | 1892 | } |
| 1890 | 1893 | |
| 1894 | +void Application::renderLookatIndicator(glm::vec3& pointOfInterest) { | |
| 1895 | + // Render a circle between me and the avatar in question. | |
| 1896 | + | |
| 1897 | + // I need a vector that is perpendicular to the vector from my camera position to the head position. | |
| 1898 | + // Start by locating point on vector that will be the center of the circle. | |
| 1899 | + glm::vec3 direction = glm::normalize(pointOfInterest - _myCamera.getPosition()); | |
| 1900 | + const float DISTANCE_FROM_HEAD_SPHERE = 0.1f; | |
| 1901 | + glm::vec3 indicatorOrigin = pointOfInterest - DISTANCE_FROM_HEAD_SPHERE * direction; | |
| 1902 | + // Then find a perpendicular vector/point | |
| 1903 | + // const float ARB_X = 1.0f; | |
| 1904 | + // const float ARB_Y = 1.0f; | |
| 1905 | + | |
| 1906 | + // float z = - (direction.x * ARB_X + direction.y * ARB_Y) / direction.z; | |
| 1907 | + // glm::vec3 perpendicular(ARB_X, ARB_Y, z); | |
| 1908 | + // perpendicular = glm::normalize(perpendicular); | |
| 1909 | + // glm::vec3 startingVertex = indicatorOrigin + perpendicular; | |
| 1910 | + renderCircle(indicatorOrigin, 0.1, direction, 30); | |
| 1911 | + | |
| 1912 | +} | |
| 1913 | + | |
| 1891 | 1914 | void Application::update(float deltaTime) { |
| 1892 | 1915 | // Use Transmitter Hand to move hand if connected, else use mouse |
| 1893 | 1916 | if (_myTransmitter.isConnected()) { |
| @@ -1915,7 +1938,7 @@ void Application::update(float deltaTime) { · 21 unmodified lines | ||
| 1915 | 1938 | |
| 1916 | 1939 | // Set where I am looking based on my mouse ray (so that other people can see) |
| 1917 | 1940 | glm::vec3 eyePosition; |
| 1918 | − if (isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition)) { | |
| 1941 | + if (_isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition)) { | |
| 1919 | 1942 | // If the mouse is over another avatar's head... |
| 1920 | 1943 | glm::vec3 myLookAtFromMouse(eyePosition); |
| 1921 | 1944 | _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); |
| @@ -1932,7 +1955,7 @@ void Application::update(float deltaTime) { · 10 unmodified lines | ||
| 1932 | 1955 | glm::vec3 front = orientation * IDENTITY_FRONT; |
| 1933 | 1956 | glm::vec3 up = orientation * IDENTITY_UP; |
| 1934 | 1957 | glm::vec3 towardVoxel = getMouseVoxelWorldCoordinates(_mouseVoxelDragging) |
| 1935 | − - _myAvatar.getCameraPosition(); | |
| 1958 | + - _myAvatar.getCameraPosition(); // is this an error? getCameraPosition dne | |
| 1936 | 1959 | towardVoxel = front * glm::length(towardVoxel); |
| 1937 | 1960 | glm::vec3 lateralToVoxel = glm::cross(up, glm::normalize(towardVoxel)) * glm::length(towardVoxel); |
| 1938 | 1961 | _voxelThrust = glm::vec3(0, 0, 0); |
| @@ -2176,7 +2199,7 @@ void Application::updateAvatar(float deltaTime) { · 237 unmodified lines | ||
| 2176 | 2199 | _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection); |
| 2177 | 2200 | |
| 2178 | 2201 | glm::vec3 eyePosition; |
| 2179 | − if (isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition)) { | |
| 2202 | + if (_isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition)) { | |
| 2180 | 2203 | glm::vec3 myLookAtFromMouse(eyePosition); |
| 2181 | 2204 | _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); |
| 2182 | 2205 | } |
| @@ -2204,7 +2227,7 @@ void Application::updateAvatar(float deltaTime) { · 21 unmodified lines | ||
| 2204 | 2227 | // actually need to calculate the view frustum planes to send these details |
| 2205 | 2228 | // to the server. |
| 2206 | 2229 | loadViewFrustum(_myCamera, _viewFrustum); |
| 2207 | − _myAvatar.setCameraPosition(_viewFrustum.getPosition()); | |
| 2230 | + _myAvatar.setCameraPosition(_viewFrustum.getPosition()); // setCameraPosition() dne | |
| 2208 | 2231 | _myAvatar.setCameraOrientation(_viewFrustum.getOrientation()); |
| 2209 | 2232 | _myAvatar.setCameraFov(_viewFrustum.getFieldOfView()); |
| 2210 | 2233 | _myAvatar.setCameraAspectRatio(_viewFrustum.getAspectRatio()); |