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
394394
395395 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
396396 _myCamera.setTightness (100.0f);
397− _myCamera.setTargetPosition(_myAvatar.getUprightHeadPosition());
397+ _myCamera.setTargetPosition(_myAvatar.getHead().getEyePosition());
398398 _myCamera.setTargetRotation(_myAvatar.getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PIf, 0.0f)));
399399
400400 } else if (OculusManager::isConnected()) {
@@ -406,7 +406,7 @@ void Application::paintGL() { · 5 unmodified lines
406406
407407 } else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
408408 _myCamera.setTightness(0.0f); // In first person, camera follows head exactly without delay
409− _myCamera.setTargetPosition(_myAvatar.getUprightEyeLevelPosition());
409+ _myCamera.setTargetPosition(_myAvatar.getHead().getEyePosition());
410410 _myCamera.setTargetRotation(_myAvatar.getHead().getCameraOrientation());
411411
412412 } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
@@ -2100,7 +2100,7 @@ Avatar* Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3 · 1687 unmodified lines
21002100 Avatar* avatar = (Avatar *) node->getLinkedData();
21012101 glm::vec3 headPosition = avatar->getHead().getPosition();
21022102 if (rayIntersectsSphere(mouseRayOrigin, mouseRayDirection, headPosition, HEAD_SPHERE_RADIUS)) {
2103− eyePosition = avatar->getHead().getEyeLevelPosition();
2103+ eyePosition = avatar->getHead().getEyePosition();
21042104 _lookatIndicatorScale = avatar->getScale();
21052105 _lookatOtherPosition = headPosition;
21062106 nodeID = avatar->getOwningNode()->getNodeID();
@@ -2149,21 +2149,20 @@ void Application::update(float deltaTime) { · 42 unmodified lines
21492149 _myAvatar.setMouseRay(mouseRayOrigin, mouseRayDirection);
21502150
21512151 // Set where I am looking based on my mouse ray (so that other people can see)
2152− glm::vec3 eyePosition;
2152+ glm::vec3 lookAtSpot;
21532153
2154− _isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition);
2154+ _isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, lookAtSpot);
21552155 if (_isLookingAtOtherAvatar) {
21562156 // If the mouse is over another avatar's head...
2157− glm::vec3 myLookAtFromMouse(eyePosition);
2158− _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
2157+ _myAvatar.getHead().setLookAtPosition(lookAtSpot);
21592158 } else if (_isHoverVoxel) {
21602159 // Look at the hovered voxel
2161− glm::vec3 lookAtSpot = getMouseVoxelWorldCoordinates(_hoverVoxel);
2160+ lookAtSpot = getMouseVoxelWorldCoordinates(_hoverVoxel);
21622161 _myAvatar.getHead().setLookAtPosition(lookAtSpot);
21632162 } else {
21642163 // Just look in direction of the mouse ray
2165− glm::vec3 myLookAtFromMouse(mouseRayOrigin + mouseRayDirection);
2166− _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
2164+ lookAtSpot = mouseRayOrigin + mouseRayDirection;
2165+ _myAvatar.getHead().setLookAtPosition(lookAtSpot);
21672166 }
21682167
21692168 // Find the voxel we are hovering over, and respond if clicked
@@ -2732,7 +2731,7 @@ void Application::displaySide(Camera& whichCamera) { · 562 unmodified lines
27322731 glRotatef(-glm::angle(rotation), axis.x, axis.y, axis.z);
27332732
27342733 glTranslatef(-whichCamera.getPosition().x, -whichCamera.getPosition().y, -whichCamera.getPosition().z);
2735−
2734+
27362735 // Setup 3D lights (after the camera transform, so that they are positioned in world space)
27372736 glEnable(GL_COLOR_MATERIAL);
27382737 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