| 743 | | float fovx = 1.25f; |
| 744 | | float fovy = 1.0f; |
| 745 | | for( unsigned int i = 0; i < viewer.getNumberOfCameras(); i++ ) |
| 746 | | { |
| 747 | | Producer::Camera* cam = viewer.getCamera(i); |
| 748 | | //Producer::RenderSurface* rs = cam->getRenderSurface(); |
| 749 | | //rs->useCursor(false); |
| 750 | | fovx = cam->getLensHorizontalFov(); |
| 751 | | fovy = cam->getLensVerticalFov(); |
| 752 | | } |
| 753 | | |
| | 737 | double fovy, aspectRatio, zNear, zFar; |
| | 738 | viewer.getCamera()->getProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar); |
| | 739 | |
| | 740 | fovy = osg::DegreesToRadians(fovy); |
| | 741 | double fovx = atan(tan(fovy*0.5)*aspectRatio)*2.0; |
| | 742 | |
| 779 | | osg::Matrix homePosition; |
| 780 | | homePosition.makeLookAt(osg::Vec3(0.0f,0.0f,0.0f),osg::Vec3(0.0f,1.0f,0.0f),osg::Vec3(0.0f,0.0f,1.0f)); |
| 781 | | |
| 782 | | while( !viewer.done() ) |
| 783 | | { |
| 784 | | // wait for all cull and draw threads to complete. |
| 785 | | viewer.sync(); |
| 786 | | |
| 787 | | // update the scene by traversing it with the the update visitor which will |
| 788 | | // call all node update callbacks and animations. |
| 789 | | viewer.update(); |
| 790 | | |
| 791 | | //viewer.setView(homePosition); |
| 792 | | |
| 793 | | // fire off the cull and draw traversals of the scene. |
| 794 | | viewer.frame(); |
| 795 | | |
| 796 | | } |
| 797 | | |
| 798 | | // wait for all cull and draw threads to complete. |
| 799 | | viewer.sync(); |
| 800 | | |
| 801 | | // run a clean up frame to delete all OpenGL objects. |
| 802 | | viewer.cleanup_frame(); |
| 803 | | |
| 804 | | // wait for all the clean up frame to complete. |
| 805 | | viewer.sync(); |
| 806 | | |
| 807 | | return 0; |
| 808 | | } |
| 809 | | |
| | 765 | // switch off the cursor |
| | 766 | osgViewer::Viewer::Windows windows; |
| | 767 | viewer.getWindows(windows); |
| | 768 | for(osgViewer::Viewer::Windows::iterator itr = windows.begin(); |
| | 769 | itr != windows.end(); |
| | 770 | ++itr) |
| | 771 | { |
| | 772 | (*itr)->useCursor(false); |
| | 773 | } |
| | 774 | |
| | 775 | |
| | 776 | return viewer.run(); |
| | 777 | } |
| | 778 | |