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
105Head myAvatar; // The rendered avatar of oneself105Head myAvatar; // The rendered avatar of oneself
106Camera myCamera; // My view onto the world (sometimes on myself :)106Camera myCamera; // My view onto the world (sometimes on myself :)
107Camera viewFrustumOffsetCamera; // The camera we use to sometimes show the view frustum from an offset mode107Camera viewFrustumOffsetCamera; // The camera we use to sometimes show the view frustum from an offset mode
108Camera currentCamera = myCamera; // could be either myCamera or viewFrustumOffsetCamera, this is the camera for OpenGL
109 108
110// Starfield information109// Starfield information
111char starFile[] = "https://s3-us-west-1.amazonaws.com/highfidelity/stars.txt";110char starFile[] = "https://s3-us-west-1.amazonaws.com/highfidelity/stars.txt";
@@ -738,47 +737,6 @@ void display(void) · 626 unmodified lines
738 myCamera.update ( 1.f/FPS );737 myCamera.update ( 1.f/FPS );
739 }738 }
740 739
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
782 // Note: whichCamera is used to pick between the normal camera myCamera for our 740 // Note: whichCamera is used to pick between the normal camera myCamera for our
783 // main camera, vs, an alternate camera. The alternate camera we support right now741 // main camera, vs, an alternate camera. The alternate camera we support right now
784 // is the viewFrustumOffsetCamera. But theoretically, we could use this same mechanism742 // is the viewFrustumOffsetCamera. But theoretically, we could use this same mechanism
@@ -1032,13 +990,8 @@ int setDisplayFrustum(int state) { · 247 unmodified lines
1032 990
1033int setFrustumOffset(int state) {991int setFrustumOffset(int state) {
1034 int value = setValue(state, &::viewFrustumFromOffset);992 int value = setValue(state, &::viewFrustumFromOffset);
1035 993
1036 // make sure we reset the camera for OpenGL appropriate994 // reshape so that OpenGL will get the right lens details for the camera of choice
1037 if (::viewFrustumFromOffset) {
1038 currentCamera = ::viewFrustumOffsetCamera;
1039 } else {
1040 currentCamera = myCamera;
1041 }
1042 reshape(::WIDTH,::HEIGHT);995 reshape(::WIDTH,::HEIGHT);
1043 996
1044 return value;997 return value;
@@ -1443,12 +1396,20 @@ void reshape(int width, int height) · 398 unmodified lines
1443 HEIGHT = height; 1396 HEIGHT = height;
1444 float aspectRatio = ((float)width/(float)height); // based on screen resize1397 float aspectRatio = ((float)width/(float)height); // based on screen resize
1445 1398
1446 1399 float fov;
1447 // get the lens details from the current camera1400 float nearClip;
1448 float fov = ::currentCamera.getFieldOfView();1401 float farClip;
1449 float nearClip = ::currentCamera.getNearClip();
1450 float farClip = ::currentCamera.getFarClip();
1451 1402
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 }
1452 1413
1453 printf("reshape() width=%d, height=%d, aspectRatio=%f fov=%f near=%f far=%f \n",1414 printf("reshape() width=%d, height=%d, aspectRatio=%f fov=%f near=%f far=%f \n",
1454 width,height,aspectRatio,fov,nearClip,farClip);1415 width,height,aspectRatio,fov,nearClip,farClip);
@@ -1472,7 +1433,9 @@ void reshape(int width, int height) · 17 unmodified lines
1472 glLoadIdentity();1433 glLoadIdentity();
1473 1434
1474 // XXXBHG - If we're in view frustum mode, then we need to do this little bit of hackery so that1435 // 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.)
1476 if (::frustumOn) {1439 if (::frustumOn) {
1477 nearClip -= 0.01f;1440 nearClip -= 0.01f;
1478 farClip += 0.01f;1441 farClip += 0.01f;