Showing the changes to interface/src/main.cpp (1 of 10 files). Show all
Unified · Split
| @@ -75,6 +75,9 @@ · 74 unmodified lines | |||
| 75 | #include <PerfStat.h> | 75 | #include <PerfStat.h> |
| 76 | #include <SharedUtil.h> | 76 | #include <SharedUtil.h> |
| 77 | #include <PacketHeaders.h> | 77 | #include <PacketHeaders.h> |
| 78 | #include <glmUtils.h> | ||
| 79 | |||
| 80 | #include "ViewFrustum.h" | ||
| 78 | 81 | ||
| 79 | using namespace std; | 82 | using namespace std; |
| 80 | 83 | ||
| @@ -159,6 +162,7 @@ bool viewFrustumFromOffset=false; // Wether or not to offset the view of the · 78 unmodified lines | |||
| 159 | float viewFrustumOffsetYaw = -90.0; | 162 | float viewFrustumOffsetYaw = -90.0; |
| 160 | float viewFrustumOffsetPitch = 7.5; | 163 | float viewFrustumOffsetPitch = 7.5; |
| 161 | float viewFrustumOffsetRoll = 0.0; | 164 | float viewFrustumOffsetRoll = 0.0; |
| 165 | float viewFrustumOffsetDistance = 0.0; | ||
| 162 | 166 | ||
| 163 | int noiseOn = 0; // Whether to add random noise | 167 | int noiseOn = 0; // Whether to add random noise |
| 164 | float noise = 1.0; // Overall magnitude scaling for random noise levels | 168 | float noise = 1.0; // Overall magnitude scaling for random noise levels |
| @@ -561,11 +565,14 @@ void render_view_frustum() { · 396 unmodified lines | |||
| 561 | up = headUp; | 565 | up = headUp; |
| 562 | right = headRight; | 566 | right = headRight; |
| 563 | } | 567 | } |
| 568 | |||
| 569 | ViewFrustum vf(viewFrustumPosition,viewFrustumDirection); | ||
| 570 | vf.dump(); | ||
| 564 | 571 | ||
| 565 | float nearDist = 0.1; | 572 | float nearDist = 0.1; |
| 566 | float farDist = 1.0; | 573 | float farDist = 10.0; |
| 567 | 574 | ||
| 568 | float fovHalfAngle = 0.7854f*1.7; // 45 deg for half, so fov = 90 deg | 575 | float fovHalfAngle = 0.7854f*1.5; // 45 deg for half, so fov = 90 deg |
| 569 | 576 | ||
| 570 | float screenWidth = ::WIDTH; // These values come from reshape() | 577 | float screenWidth = ::WIDTH; // These values come from reshape() |
| 571 | float screenHeight = ::HEIGHT; | 578 | float screenHeight = ::HEIGHT; |
| @@ -577,7 +584,7 @@ void render_view_frustum() { · 5 unmodified lines | |||
| 577 | float farWidth = farHeight * ratio; | 584 | float farWidth = farHeight * ratio; |
| 578 | 585 | ||
| 579 | glm::vec3 farCenter = viewFrustumPosition+viewFrustumDirection*farDist; | 586 | glm::vec3 farCenter = viewFrustumPosition+viewFrustumDirection*farDist; |
| 580 | glm::vec3 farTopLeft = farCenter + (up*farHeight*0.5) - (right*farWidth*0.5); | 587 | glm::vec3 farTopLeft = farCenter + (up*farHeight*0.5) - (right*farWidth*0.5); |
| 581 | glm::vec3 farTopRight = farCenter + (up*farHeight*0.5) + (right*farWidth*0.5); | 588 | glm::vec3 farTopRight = farCenter + (up*farHeight*0.5) + (right*farWidth*0.5); |
| 582 | glm::vec3 farBottomLeft = farCenter - (up*farHeight*0.5) - (right*farWidth*0.5); | 589 | glm::vec3 farBottomLeft = farCenter - (up*farHeight*0.5) - (right*farWidth*0.5); |
| 583 | glm::vec3 farBottomRight = farCenter - (up*farHeight*0.5) + (right*farWidth*0.5); | 590 | glm::vec3 farBottomRight = farCenter - (up*farHeight*0.5) + (right*farWidth*0.5); |
| @@ -587,6 +594,9 @@ void render_view_frustum() { · 3 unmodified lines | |||
| 587 | glm::vec3 nearTopRight = nearCenter + (up*nearHeight*0.5) + (right*nearWidth*0.5); | 594 | glm::vec3 nearTopRight = nearCenter + (up*nearHeight*0.5) + (right*nearWidth*0.5); |
| 588 | glm::vec3 nearBottomLeft = nearCenter - (up*nearHeight*0.5) - (right*nearWidth*0.5); | 595 | glm::vec3 nearBottomLeft = nearCenter - (up*nearHeight*0.5) - (right*nearWidth*0.5); |
| 589 | glm::vec3 nearBottomRight = nearCenter - (up*nearHeight*0.5) + (right*nearWidth*0.5); | 596 | glm::vec3 nearBottomRight = nearCenter - (up*nearHeight*0.5) + (right*nearWidth*0.5); |
| 597 | |||
| 598 | //printf("farCenter.x=%f, farCenter.y=%f, farCenter.z=%f\n",farCenter.x,farCenter.y,farCenter.z); | ||
| 599 | //printf("farTopLeft.x=%f, farTopLeft.y=%f, farTopLeft.z=%f\n",farTopLeft.x,farTopLeft.y,farTopLeft.z); | ||
| 590 | 600 | ||
| 591 | // At this point we have all the corners for our frustum... we could use these to | 601 | // At this point we have all the corners for our frustum... we could use these to |
| 592 | // calculate various things... | 602 | // calculate various things... |
| @@ -770,9 +780,9 @@ void display(void) · 177 unmodified lines | |||
| 770 | //---------------------------------------------------- | 780 | //---------------------------------------------------- |
| 771 | viewFrustumOffsetCamera.setYaw ( 180.0 - myAvatar.getBodyYaw() + ::viewFrustumOffsetYaw ); | 781 | viewFrustumOffsetCamera.setYaw ( 180.0 - myAvatar.getBodyYaw() + ::viewFrustumOffsetYaw ); |
| 772 | viewFrustumOffsetCamera.setPitch ( 0.0 + ::viewFrustumOffsetPitch ); | 782 | viewFrustumOffsetCamera.setPitch ( 0.0 + ::viewFrustumOffsetPitch ); |
| 773 | viewFrustumOffsetCamera.setRoll ( 0.0 + ::viewFrustumOffsetRoll ); | 783 | viewFrustumOffsetCamera.setRoll ( 0.0 + ::viewFrustumOffsetRoll ); |
| 774 | viewFrustumOffsetCamera.setUp ( 0.2 + 0.2 ); | 784 | viewFrustumOffsetCamera.setUp ( 0.2 + 0.2 ); |
| 775 | viewFrustumOffsetCamera.setDistance( 0.5 + 0.2 ); | 785 | viewFrustumOffsetCamera.setDistance ( 0.5 + ::viewFrustumOffsetDistance ); |
| 776 | viewFrustumOffsetCamera.update(); | 786 | viewFrustumOffsetCamera.update(); |
| 777 | 787 | ||
| 778 | whichCamera = viewFrustumOffsetCamera; | 788 | whichCamera = viewFrustumOffsetCamera; |
| @@ -1138,6 +1148,9 @@ void key(unsigned char k, int x, int y) · 359 unmodified lines | |||
| 1138 | if (k == '(') ::viewFrustumOffsetRoll -= 0.5; | 1148 | if (k == '(') ::viewFrustumOffsetRoll -= 0.5; |
| 1139 | if (k == ')') ::viewFrustumOffsetRoll += 0.5; | 1149 | if (k == ')') ::viewFrustumOffsetRoll += 0.5; |
| 1140 | 1150 | ||
| 1151 | if (k == '<') ::viewFrustumOffsetDistance -= 0.5; | ||
| 1152 | if (k == '>') ::viewFrustumOffsetDistance += 0.5; | ||
| 1153 | |||
| 1141 | if (k == '&') { | 1154 | if (k == '&') { |
| 1142 | ::paintOn = !::paintOn; // toggle paint | 1155 | ::paintOn = !::paintOn; // toggle paint |
| 1143 | ::setupPaintingVoxel(); // also randomizes colors | 1156 | ::setupPaintingVoxel(); // also randomizes colors |