History

Rendering of indicator circle in 3D space. Spacing edits in util.

Mark Peng committed 13 years ago

Commit 5ffe3fa1 parent f6619c64 files · +29 −7Browse files

Showing the changes to interface/src/Application.cpp (1 of 4 files). Show all

Unified · Split

interface/src/Application.cpp+27−4
@@ -55,6 +55,7 @@ · 54 unmodified lines
5555 #include <PacketHeaders.h>
5656 #include <PairingHandler.h>
5757 #include <PerfStat.h>
58+#include <math.h>
5859
5960 #include "Application.h"
6061 #include "InterfaceConfig.h"
@@ -196,6 +197,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 135 unmodified lines
196197 _mousePressed(false),
197198 _mouseVoxelScale(1.0f / 1024.0f),
198199 _justEditedVoxel(false),
200+ _isLookingAtOtherAvatar(false),
199201 _paintOn(false),
200202 _dominantColor(0),
201203 _perfStatsOn(false),
@@ -1881,6 +1883,7 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m · 1679 unmodified lines
18811883 glm::vec3 headPosition = avatar->getHead().getPosition();
18821884 if (rayIntersectsSphere(mouseRayOrigin, mouseRayDirection, headPosition, HEAD_SPHERE_RADIUS)) {
18831885 eyePosition = avatar->getHead().getEyeLevelPosition();
1886+ renderLookatIndicator(headPosition);
18841887 return true;
18851888 }
18861889 }
@@ -1888,6 +1891,26 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m · 1 unmodified line
18881891 return false;
18891892 }
18901893
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+
18911914 void Application::update(float deltaTime) {
18921915 // Use Transmitter Hand to move hand if connected, else use mouse
18931916 if (_myTransmitter.isConnected()) {
@@ -1915,7 +1938,7 @@ void Application::update(float deltaTime) { · 21 unmodified lines
19151938
19161939 // Set where I am looking based on my mouse ray (so that other people can see)
19171940 glm::vec3 eyePosition;
1918− if (isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition)) {
1941+ if (_isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition)) {
19191942 // If the mouse is over another avatar's head...
19201943 glm::vec3 myLookAtFromMouse(eyePosition);
19211944 _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
@@ -1932,7 +1955,7 @@ void Application::update(float deltaTime) { · 10 unmodified lines
19321955 glm::vec3 front = orientation * IDENTITY_FRONT;
19331956 glm::vec3 up = orientation * IDENTITY_UP;
19341957 glm::vec3 towardVoxel = getMouseVoxelWorldCoordinates(_mouseVoxelDragging)
1935− - _myAvatar.getCameraPosition();
1958+ - _myAvatar.getCameraPosition(); // is this an error? getCameraPosition dne
19361959 towardVoxel = front * glm::length(towardVoxel);
19371960 glm::vec3 lateralToVoxel = glm::cross(up, glm::normalize(towardVoxel)) * glm::length(towardVoxel);
19381961 _voxelThrust = glm::vec3(0, 0, 0);
@@ -2176,7 +2199,7 @@ void Application::updateAvatar(float deltaTime) { · 237 unmodified lines
21762199 _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection);
21772200
21782201 glm::vec3 eyePosition;
2179− if (isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition)) {
2202+ if (_isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition)) {
21802203 glm::vec3 myLookAtFromMouse(eyePosition);
21812204 _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
21822205 }
@@ -2204,7 +2227,7 @@ void Application::updateAvatar(float deltaTime) { · 21 unmodified lines
22042227 // actually need to calculate the view frustum planes to send these details
22052228 // to the server.
22062229 loadViewFrustum(_myCamera, _viewFrustum);
2207− _myAvatar.setCameraPosition(_viewFrustum.getPosition());
2230+ _myAvatar.setCameraPosition(_viewFrustum.getPosition()); // setCameraPosition() dne
22082231 _myAvatar.setCameraOrientation(_viewFrustum.getOrientation());
22092232 _myAvatar.setCameraFov(_viewFrustum.getFieldOfView());
22102233 _myAvatar.setCameraAspectRatio(_viewFrustum.getAspectRatio());

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t