History

Fix camera positioning so that it is in between avatar's eyes. Plus some code clean up.

Mark Peng committed 13 years ago

Commit d7cd88a1 parent f24cf195 files · +14 −22Browse files

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

Unified · Split

interface/src/Application.cpp+10−11
@@ -394,7 +394,7 @@ void Application::paintGL() { · 393 unmodified lines
394 394
395 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {395 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
396 _myCamera.setTightness (100.0f); 396 _myCamera.setTightness (100.0f);
397 _myCamera.setTargetPosition(_myAvatar.getUprightHeadPosition());397 _myCamera.setTargetPosition(_myAvatar.getHead().getEyePosition());
398 _myCamera.setTargetRotation(_myAvatar.getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PIf, 0.0f)));398 _myCamera.setTargetRotation(_myAvatar.getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PIf, 0.0f)));
399 399
400 } else if (OculusManager::isConnected()) {400 } else if (OculusManager::isConnected()) {
@@ -406,7 +406,7 @@ void Application::paintGL() { · 5 unmodified lines
406 406
407 } else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {407 } else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
408 _myCamera.setTightness(0.0f); // In first person, camera follows head exactly without delay408 _myCamera.setTightness(0.0f); // In first person, camera follows head exactly without delay
409 _myCamera.setTargetPosition(_myAvatar.getUprightEyeLevelPosition());409 _myCamera.setTargetPosition(_myAvatar.getHead().getEyePosition());
410 _myCamera.setTargetRotation(_myAvatar.getHead().getCameraOrientation());410 _myCamera.setTargetRotation(_myAvatar.getHead().getCameraOrientation());
411 411
412 } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {412 } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
@@ -2100,7 +2100,7 @@ Avatar* Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3 · 1687 unmodified lines
2100 Avatar* avatar = (Avatar *) node->getLinkedData();2100 Avatar* avatar = (Avatar *) node->getLinkedData();
2101 glm::vec3 headPosition = avatar->getHead().getPosition();2101 glm::vec3 headPosition = avatar->getHead().getPosition();
2102 if (rayIntersectsSphere(mouseRayOrigin, mouseRayDirection, headPosition, HEAD_SPHERE_RADIUS)) {2102 if (rayIntersectsSphere(mouseRayOrigin, mouseRayDirection, headPosition, HEAD_SPHERE_RADIUS)) {
2103 eyePosition = avatar->getHead().getEyeLevelPosition();2103 eyePosition = avatar->getHead().getEyePosition();
2104 _lookatIndicatorScale = avatar->getScale();2104 _lookatIndicatorScale = avatar->getScale();
2105 _lookatOtherPosition = headPosition;2105 _lookatOtherPosition = headPosition;
2106 nodeID = avatar->getOwningNode()->getNodeID();2106 nodeID = avatar->getOwningNode()->getNodeID();
@@ -2149,21 +2149,20 @@ void Application::update(float deltaTime) { · 42 unmodified lines
2149 _myAvatar.setMouseRay(mouseRayOrigin, mouseRayDirection);2149 _myAvatar.setMouseRay(mouseRayOrigin, mouseRayDirection);
2150 2150
2151 // Set where I am looking based on my mouse ray (so that other people can see)2151 // Set where I am looking based on my mouse ray (so that other people can see)
2152 glm::vec3 eyePosition;2152 glm::vec3 lookAtSpot;
2153 2153
2154 _isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition);2154 _isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, lookAtSpot);
2155 if (_isLookingAtOtherAvatar) {2155 if (_isLookingAtOtherAvatar) {
2156 // If the mouse is over another avatar's head...2156 // If the mouse is over another avatar's head...
2157 glm::vec3 myLookAtFromMouse(eyePosition);2157 _myAvatar.getHead().setLookAtPosition(lookAtSpot);
2158 _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
2159 } else if (_isHoverVoxel) {2158 } else if (_isHoverVoxel) {
2160 // Look at the hovered voxel2159 // Look at the hovered voxel
2161 glm::vec3 lookAtSpot = getMouseVoxelWorldCoordinates(_hoverVoxel);2160 lookAtSpot = getMouseVoxelWorldCoordinates(_hoverVoxel);
2162 _myAvatar.getHead().setLookAtPosition(lookAtSpot);2161 _myAvatar.getHead().setLookAtPosition(lookAtSpot);
2163 } else {2162 } else {
2164 // Just look in direction of the mouse ray2163 // Just look in direction of the mouse ray
2165 glm::vec3 myLookAtFromMouse(mouseRayOrigin + mouseRayDirection);2164 lookAtSpot = mouseRayOrigin + mouseRayDirection;
2166 _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);2165 _myAvatar.getHead().setLookAtPosition(lookAtSpot);
2167 }2166 }
2168 2167
2169 // Find the voxel we are hovering over, and respond if clicked2168 // Find the voxel we are hovering over, and respond if clicked
@@ -2732,7 +2731,7 @@ void Application::displaySide(Camera& whichCamera) { · 562 unmodified lines
2732 glRotatef(-glm::angle(rotation), axis.x, axis.y, axis.z);2731 glRotatef(-glm::angle(rotation), axis.x, axis.y, axis.z);
2733 2732
2734 glTranslatef(-whichCamera.getPosition().x, -whichCamera.getPosition().y, -whichCamera.getPosition().z);2733 glTranslatef(-whichCamera.getPosition().x, -whichCamera.getPosition().y, -whichCamera.getPosition().z);
2735 2734
2736 // Setup 3D lights (after the camera transform, so that they are positioned in world space)2735 // Setup 3D lights (after the camera transform, so that they are positioned in world space)
2737 glEnable(GL_COLOR_MATERIAL);2736 glEnable(GL_COLOR_MATERIAL);
2738 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);2737 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);

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