History

latest view frustum work

ZappoMan committed 13 years ago

Commit d01d1161 parent 76d22f110 files · +192 −32Browse files

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

Unified · Split

interface/src/main.cpp+18−5
@@ -75,6 +75,9 @@ · 74 unmodified lines
7575 #include <PerfStat.h>
7676 #include <SharedUtil.h>
7777 #include <PacketHeaders.h>
78+#include <glmUtils.h>
79+
80+#include "ViewFrustum.h"
7881
7982 using namespace std;
8083
@@ -159,6 +162,7 @@ bool viewFrustumFromOffset=false; // Wether or not to offset the view of the · 78 unmodified lines
159162 float viewFrustumOffsetYaw = -90.0;
160163 float viewFrustumOffsetPitch = 7.5;
161164 float viewFrustumOffsetRoll = 0.0;
165+float viewFrustumOffsetDistance = 0.0;
162166
163167 int noiseOn = 0; // Whether to add random noise
164168 float noise = 1.0; // Overall magnitude scaling for random noise levels
@@ -561,11 +565,14 @@ void render_view_frustum() { · 396 unmodified lines
561565 up = headUp;
562566 right = headRight;
563567 }
568+
569+ ViewFrustum vf(viewFrustumPosition,viewFrustumDirection);
570+ vf.dump();
564571
565572 float nearDist = 0.1;
566− float farDist = 1.0;
573+ float farDist = 10.0;
567574
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
569576
570577 float screenWidth = ::WIDTH; // These values come from reshape()
571578 float screenHeight = ::HEIGHT;
@@ -577,7 +584,7 @@ void render_view_frustum() { · 5 unmodified lines
577584 float farWidth = farHeight * ratio;
578585
579586 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);
581588 glm::vec3 farTopRight = farCenter + (up*farHeight*0.5) + (right*farWidth*0.5);
582589 glm::vec3 farBottomLeft = farCenter - (up*farHeight*0.5) - (right*farWidth*0.5);
583590 glm::vec3 farBottomRight = farCenter - (up*farHeight*0.5) + (right*farWidth*0.5);
@@ -587,6 +594,9 @@ void render_view_frustum() { · 3 unmodified lines
587594 glm::vec3 nearTopRight = nearCenter + (up*nearHeight*0.5) + (right*nearWidth*0.5);
588595 glm::vec3 nearBottomLeft = nearCenter - (up*nearHeight*0.5) - (right*nearWidth*0.5);
589596 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);
590600
591601 // At this point we have all the corners for our frustum... we could use these to
592602 // calculate various things...
@@ -770,9 +780,9 @@ void display(void) · 177 unmodified lines
770780 //----------------------------------------------------
771781 viewFrustumOffsetCamera.setYaw ( 180.0 - myAvatar.getBodyYaw() + ::viewFrustumOffsetYaw );
772782 viewFrustumOffsetCamera.setPitch ( 0.0 + ::viewFrustumOffsetPitch );
773− viewFrustumOffsetCamera.setRoll ( 0.0 + ::viewFrustumOffsetRoll );
783+ viewFrustumOffsetCamera.setRoll ( 0.0 + ::viewFrustumOffsetRoll );
774784 viewFrustumOffsetCamera.setUp ( 0.2 + 0.2 );
775− viewFrustumOffsetCamera.setDistance( 0.5 + 0.2 );
785+ viewFrustumOffsetCamera.setDistance ( 0.5 + ::viewFrustumOffsetDistance );
776786 viewFrustumOffsetCamera.update();
777787
778788 whichCamera = viewFrustumOffsetCamera;
@@ -1138,6 +1148,9 @@ void key(unsigned char k, int x, int y) · 359 unmodified lines
11381148 if (k == '(') ::viewFrustumOffsetRoll -= 0.5;
11391149 if (k == ')') ::viewFrustumOffsetRoll += 0.5;
11401150
1151+ if (k == '<') ::viewFrustumOffsetDistance -= 0.5;
1152+ if (k == '>') ::viewFrustumOffsetDistance += 0.5;
1153+
11411154 if (k == '&') {
11421155 ::paintOn = !::paintOn; // toggle paint
11431156 ::setupPaintingVoxel(); // also randomizes colors