History

cleaning up of whacky currentCamera experiment

ZappoMan committed 13 years ago

Commit e7fa5401 parent faf57d91 file · +18 −55Browse files

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

Unified · Split

interface/src/main.cpp+18−55
@@ -105,7 +105,6 @@ ViewFrustum viewFrustum; // current state of view frustum, perspective, orient · 104 unmodified lines
105105 Head myAvatar; // The rendered avatar of oneself
106106 Camera myCamera; // My view onto the world (sometimes on myself :)
107107 Camera viewFrustumOffsetCamera; // The camera we use to sometimes show the view frustum from an offset mode
108−Camera currentCamera = myCamera; // could be either myCamera or viewFrustumOffsetCamera, this is the camera for OpenGL
109108
110109 // Starfield information
111110 char starFile[] = "https://s3-us-west-1.amazonaws.com/highfidelity/stars.txt";
@@ -738,47 +737,6 @@ void display(void) · 626 unmodified lines
738737 myCamera.update ( 1.f/FPS );
739738 }
740739
741−/******
742− // Note: currentCamera is used to pick between the normal camera myCamera for our
743− // main camera, vs, an alternate camera. The alternate camera we support right now
744− // is the viewFrustumOffsetCamera. But theoretically, we could use this same mechanism
745− // to add other cameras.
746− //
747− // Why have two cameras? Well, one reason is that because in the case of the render_view_frustum()
748− // code, we want to keep the state of "myCamera" intact, so we can render what the view frustum of
749− // myCamera is. But we also want to do meaningful camera transforms on OpenGL for the offset camera
750− currentCamera = myCamera;
751−
752− if (::viewFrustumFromOffset && ::frustumOn) {
753−
754− viewFrustumOffsetCamera = myCamera; //.setTargetPosition( myAvatar.getPos() );
755−
756− //----------------------------------------------------
757− // set the camera to third-person view but offset so we can see the frustum
758− //----------------------------------------------------
759− viewFrustumOffsetCamera.setYaw ( 180.0 - myAvatar.getBodyYaw() + ::viewFrustumOffsetYaw );
760− viewFrustumOffsetCamera.setPitch ( 0.0 + ::viewFrustumOffsetPitch );
761− viewFrustumOffsetCamera.setRoll ( 0.0 + ::viewFrustumOffsetRoll );
762− viewFrustumOffsetCamera.setUp ( 0.2 + ::viewFrustumOffsetUp );
763− viewFrustumOffsetCamera.setDistance ( 0.5 + ::viewFrustumOffsetDistance );
764− viewFrustumOffsetCamera.update();
765−
766− // We'll be using this one!
767− currentCamera = viewFrustumOffsetCamera;
768− }
769−
770− //---------------------------------------------
771− // transform view according to whichCamera
772− // could be myCamera (if in normal mode)
773− // or could be viewFrustumOffsetCamera if in offset mode
774− //---------------------------------------------
775− glRotatef ( currentCamera.getPitch(), 1, 0, 0 );
776− glRotatef ( currentCamera.getYaw(), 0, 1, 0 );
777− glRotatef ( currentCamera.getRoll(), 0, 0, 1 );
778− glTranslatef( -currentCamera.getPosition().x, -currentCamera.getPosition().y, -currentCamera.getPosition().z );
779−*****/
780−
781−
782740 // Note: whichCamera is used to pick between the normal camera myCamera for our
783741 // main camera, vs, an alternate camera. The alternate camera we support right now
784742 // is the viewFrustumOffsetCamera. But theoretically, we could use this same mechanism
@@ -1032,13 +990,8 @@ int setDisplayFrustum(int state) { · 247 unmodified lines
1032990
1033991 int setFrustumOffset(int state) {
1034992 int value = setValue(state, &::viewFrustumFromOffset);
1035−
1036− // make sure we reset the camera for OpenGL appropriate
1037− if (::viewFrustumFromOffset) {
1038− currentCamera = ::viewFrustumOffsetCamera;
1039− } else {
1040− currentCamera = myCamera;
1041− }
993+
994+ // reshape so that OpenGL will get the right lens details for the camera of choice
1042995 reshape(::WIDTH,::HEIGHT);
1043996
1044997 return value;
@@ -1443,12 +1396,20 @@ void reshape(int width, int height) · 398 unmodified lines
14431396 HEIGHT = height;
14441397 float aspectRatio = ((float)width/(float)height); // based on screen resize
14451398
1446−
1447− // get the lens details from the current camera
1448− float fov = ::currentCamera.getFieldOfView();
1449− float nearClip = ::currentCamera.getNearClip();
1450− float farClip = ::currentCamera.getFarClip();
1399+ float fov;
1400+ float nearClip;
1401+ float farClip;
14511402
1403+ // get the lens details from the current camera
1404+ if (::viewFrustumFromOffset) {
1405+ fov = ::viewFrustumOffsetCamera.getFieldOfView();
1406+ nearClip = ::viewFrustumOffsetCamera.getNearClip();
1407+ farClip = ::viewFrustumOffsetCamera.getFarClip();
1408+ } else {
1409+ fov = ::myCamera.getFieldOfView();
1410+ nearClip = ::myCamera.getNearClip();
1411+ farClip = ::myCamera.getFarClip();
1412+ }
14521413
14531414 printf("reshape() width=%d, height=%d, aspectRatio=%f fov=%f near=%f far=%f \n",
14541415 width,height,aspectRatio,fov,nearClip,farClip);
@@ -1472,7 +1433,9 @@ void reshape(int width, int height) · 17 unmodified lines
14721433 glLoadIdentity();
14731434
14741435 // XXXBHG - If we're in view frustum mode, then we need to do this little bit of hackery so that
1475− // OpenGL won't clip our frustum rendering lines. This is a debug hack for sure!
1436+ // OpenGL won't clip our frustum rendering lines. This is a debug hack for sure! Basically, this makes
1437+ // the near clip a little bit closer (therefor you see more) and the far clip a little bit farther (also,
1438+ // to see more.)
14761439 if (::frustumOn) {
14771440 nearClip -= 0.01f;
14781441 farClip += 0.01f;