Showing the changes to interface/src/main.cpp (1 of 1 file). Show all
Unified · Split
| @@ -105,7 +105,6 @@ ViewFrustum viewFrustum; // current state of view frustum, perspective, orient · 104 unmodified lines | ||
| 105 | 105 | Head myAvatar; // The rendered avatar of oneself |
| 106 | 106 | Camera myCamera; // My view onto the world (sometimes on myself :) |
| 107 | 107 | 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 | |
| 109 | 108 | |
| 110 | 109 | // Starfield information |
| 111 | 110 | char starFile[] = "https://s3-us-west-1.amazonaws.com/highfidelity/stars.txt"; |
| @@ -738,47 +737,6 @@ void display(void) · 626 unmodified lines | ||
| 738 | 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 | 740 | // Note: whichCamera is used to pick between the normal camera myCamera for our |
| 783 | 741 | // main camera, vs, an alternate camera. The alternate camera we support right now |
| 784 | 742 | // is the viewFrustumOffsetCamera. But theoretically, we could use this same mechanism |
| @@ -1032,13 +990,8 @@ int setDisplayFrustum(int state) { · 247 unmodified lines | ||
| 1032 | 990 | |
| 1033 | 991 | int setFrustumOffset(int state) { |
| 1034 | 992 | 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 | |
| 1042 | 995 | reshape(::WIDTH,::HEIGHT); |
| 1043 | 996 | |
| 1044 | 997 | return value; |
| @@ -1443,12 +1396,20 @@ void reshape(int width, int height) · 398 unmodified lines | ||
| 1443 | 1396 | HEIGHT = height; |
| 1444 | 1397 | float aspectRatio = ((float)width/(float)height); // based on screen resize |
| 1445 | 1398 | |
| 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; | |
| 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 | 1414 | printf("reshape() width=%d, height=%d, aspectRatio=%f fov=%f near=%f far=%f \n", |
| 1454 | 1415 | width,height,aspectRatio,fov,nearClip,farClip); |
| @@ -1472,7 +1433,9 @@ void reshape(int width, int height) · 17 unmodified lines | ||
| 1472 | 1433 | glLoadIdentity(); |
| 1473 | 1434 | |
| 1474 | 1435 | // 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 | 1439 | if (::frustumOn) { |
| 1477 | 1440 | nearClip -= 0.01f; |
| 1478 | 1441 | farClip += 0.01f; |