Showing the changes to interface/src/main.cpp (1 of 13 files). Show all
Unified · Split
| @@ -102,6 +102,13 @@ int screenHeight = 800; · 101 unmodified lines | |||
| 102 | int fullscreen = 0; | 102 | int fullscreen = 0; |
| 103 | float aspectRatio = 1.0f; | 103 | float aspectRatio = 1.0f; |
| 104 | 104 | ||
| 105 | bool USING_MOUSE_VIEW_SHIFT = false; | ||
| 106 | float MOUSE_VIEW_SHIFT_RATE = 40.0f; | ||
| 107 | float MOUSE_VIEW_SHIFT_YAW_MARGIN = (float)(WIDTH * 0.2f); | ||
| 108 | float MOUSE_VIEW_SHIFT_PITCH_MARGIN = (float)(HEIGHT * 0.2f); | ||
| 109 | float MOUSE_VIEW_SHIFT_YAW_LIMIT = 45.0; | ||
| 110 | float MOUSE_VIEW_SHIFT_PITCH_LIMIT = 30.0; | ||
| 111 | |||
| 105 | //CameraMode defaultCameraMode = CAMERA_MODE_FIRST_PERSON; | 112 | //CameraMode defaultCameraMode = CAMERA_MODE_FIRST_PERSON; |
| 106 | CameraMode defaultCameraMode = CAMERA_MODE_THIRD_PERSON; | 113 | CameraMode defaultCameraMode = CAMERA_MODE_THIRD_PERSON; |
| 107 | 114 | ||
| @@ -206,7 +213,6 @@ double elapsedTime; · 98 unmodified lines | |||
| 206 | timeval applicationStartupTime; | 213 | timeval applicationStartupTime; |
| 207 | bool justStarted = true; | 214 | bool justStarted = true; |
| 208 | 215 | ||
| 209 | |||
| 210 | // Every second, check the frame rates and other stuff | 216 | // Every second, check the frame rates and other stuff |
| 211 | void Timer(int extra) { | 217 | void Timer(int extra) { |
| 212 | gettimeofday(&timerEnd, NULL); | 218 | gettimeofday(&timerEnd, NULL); |
| @@ -370,9 +376,7 @@ void sendVoxelEditMessage(PACKET_HEADER header, VoxelDetail& detail) { · 157 unmodified lines | |||
| 370 | } | 376 | } |
| 371 | } | 377 | } |
| 372 | 378 | ||
| 373 | // | ||
| 374 | // Using gyro data, update both view frustum and avatar head position | 379 | // Using gyro data, update both view frustum and avatar head position |
| 375 | // | ||
| 376 | void updateAvatar(float deltaTime) { | 380 | void updateAvatar(float deltaTime) { |
| 377 | 381 | ||
| 378 | // Update my avatar's head position from gyros | 382 | // Update my avatar's head position from gyros |
| @@ -409,7 +413,34 @@ void updateAvatar(float deltaTime) { · 30 unmodified lines | |||
| 409 | const float RENDER_PITCH_MULTIPLY = 4.f; | 413 | const float RENDER_PITCH_MULTIPLY = 4.f; |
| 410 | myAvatar.setRenderPitch((1.f - renderPitchSpring * deltaTime) * myAvatar.getRenderPitch() + | 414 | myAvatar.setRenderPitch((1.f - renderPitchSpring * deltaTime) * myAvatar.getRenderPitch() + |
| 411 | renderPitchSpring * deltaTime * -myAvatar.getHeadPitch() * RENDER_PITCH_MULTIPLY); | 415 | renderPitchSpring * deltaTime * -myAvatar.getHeadPitch() * RENDER_PITCH_MULTIPLY); |
| 412 | 416 | } | |
| 417 | |||
| 418 | |||
| 419 | if (USING_MOUSE_VIEW_SHIFT) | ||
| 420 | { | ||
| 421 | //make it so that when your mouse hits the edge of the screen, the camera shifts | ||
| 422 | float rightBoundary = (float)WIDTH - MOUSE_VIEW_SHIFT_YAW_MARGIN; | ||
| 423 | float bottomBoundary = (float)HEIGHT - MOUSE_VIEW_SHIFT_PITCH_MARGIN; | ||
| 424 | |||
| 425 | if (mouseX > rightBoundary) { | ||
| 426 | float f = (mouseX - rightBoundary) / ( (float)WIDTH - rightBoundary); | ||
| 427 | mouseViewShiftYaw += MOUSE_VIEW_SHIFT_RATE * f * deltaTime; | ||
| 428 | if (mouseViewShiftYaw > MOUSE_VIEW_SHIFT_YAW_LIMIT) { mouseViewShiftYaw = MOUSE_VIEW_SHIFT_YAW_LIMIT; } | ||
| 429 | } else if (mouseX < MOUSE_VIEW_SHIFT_YAW_MARGIN) { | ||
| 430 | float f = 1.0 - (mouseX / MOUSE_VIEW_SHIFT_YAW_MARGIN); | ||
| 431 | mouseViewShiftYaw -= MOUSE_VIEW_SHIFT_RATE * f * deltaTime; | ||
| 432 | if (mouseViewShiftYaw < -MOUSE_VIEW_SHIFT_YAW_LIMIT) { mouseViewShiftYaw = -MOUSE_VIEW_SHIFT_YAW_LIMIT; } | ||
| 433 | } | ||
| 434 | if (mouseY < MOUSE_VIEW_SHIFT_PITCH_MARGIN) { | ||
| 435 | float f = 1.0 - (mouseY / MOUSE_VIEW_SHIFT_PITCH_MARGIN); | ||
| 436 | mouseViewShiftPitch += MOUSE_VIEW_SHIFT_RATE * f * deltaTime; | ||
| 437 | if ( mouseViewShiftPitch > MOUSE_VIEW_SHIFT_PITCH_LIMIT ) { mouseViewShiftPitch = MOUSE_VIEW_SHIFT_PITCH_LIMIT; } | ||
| 438 | } | ||
| 439 | else if (mouseY > bottomBoundary) { | ||
| 440 | float f = (mouseY - bottomBoundary) / ((float)HEIGHT - bottomBoundary); | ||
| 441 | mouseViewShiftPitch -= MOUSE_VIEW_SHIFT_RATE * f * deltaTime; | ||
| 442 | if (mouseViewShiftPitch < -MOUSE_VIEW_SHIFT_PITCH_LIMIT) { mouseViewShiftPitch = -MOUSE_VIEW_SHIFT_PITCH_LIMIT; } | ||
| 443 | } | ||
| 413 | } | 444 | } |
| 414 | 445 | ||
| 415 | if (OculusManager::isConnected()) { | 446 | if (OculusManager::isConnected()) { |
| @@ -1032,7 +1063,7 @@ void display(void) · 616 unmodified lines | |||
| 1032 | myCamera.setDistance (1.5f); | 1063 | myCamera.setDistance (1.5f); |
| 1033 | myCamera.setTightness (8.0f); | 1064 | myCamera.setTightness (8.0f); |
| 1034 | myCamera.setTargetPosition(myAvatar.getHeadPosition()); | 1065 | myCamera.setTargetPosition(myAvatar.getHeadPosition()); |
| 1035 | myCamera.setTargetRotation(myAvatar.getBodyYaw(), 0.0f, 0.0f); | 1066 | myCamera.setTargetRotation(myAvatar.getBodyYaw() - mouseViewShiftYaw, mouseViewShiftPitch, 0.0f); |
| 1036 | } | 1067 | } |
| 1037 | 1068 | ||
| 1038 | // important... | 1069 | // important... |
| @@ -1540,9 +1571,6 @@ void specialkey(int k, int x, int y) { · 501 unmodified lines | |||
| 1540 | if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myAvatar.setDriveKeys(RIGHT, 1); | 1571 | if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myAvatar.setDriveKeys(RIGHT, 1); |
| 1541 | else myAvatar.setDriveKeys(ROT_RIGHT, 1); | 1572 | else myAvatar.setDriveKeys(ROT_RIGHT, 1); |
| 1542 | } | 1573 | } |
| 1543 | #ifndef _WIN32 | ||
| 1544 | audio.setWalkingState(true); | ||
| 1545 | #endif | ||
| 1546 | } | 1574 | } |
| 1547 | } | 1575 | } |
| 1548 | 1576 | ||
| @@ -1800,6 +1828,8 @@ void idle(void) { · 251 unmodified lines | |||
| 1800 | // walking triggers the handControl to stop | 1828 | // walking triggers the handControl to stop |
| 1801 | if (myAvatar.getMode() == AVATAR_MODE_WALKING) { | 1829 | if (myAvatar.getMode() == AVATAR_MODE_WALKING) { |
| 1802 | handControl.stop(); | 1830 | handControl.stop(); |
| 1831 | mouseViewShiftYaw *= 0.9; | ||
| 1832 | mouseViewShiftPitch *= 0.9; | ||
| 1803 | } | 1833 | } |
| 1804 | 1834 | ||
| 1805 | // Read serial port interface devices | 1835 | // Read serial port interface devices |
| @@ -1836,7 +1866,6 @@ void idle(void) { · 30 unmodified lines | |||
| 1836 | glutPostRedisplay(); | 1866 | glutPostRedisplay(); |
| 1837 | lastTimeIdle = check; | 1867 | lastTimeIdle = check; |
| 1838 | } | 1868 | } |
| 1839 | |||
| 1840 | } | 1869 | } |
| 1841 | 1870 | ||
| 1842 | void reshape(int width, int height) { | 1871 | void reshape(int width, int height) { |