Show
Ignore:
Timestamp:
09/29/03 15:14:34 (11 years ago)
Author:
robert
Message:

Added getPerspective() method to Matrix* and SceneView?

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgunittests/osgunittests.cpp

    r2222 r2323  
    1111    f.makeFrustum(left,right,bottom,top,zNear,zFar); 
    1212 
    13      
    14     double c_zNear = f(3,2) / (f(2,2)-1.0f); 
    15     double c_zFar = f(3,2) / (1.0f+f(2,2)); 
    16      
    17     double c_left = c_zNear * (f(2,0)-1.0f) / f(0,0); 
    18     double c_right = c_zNear * (1.0f+f(2,0)) / f(0,0); 
    19  
    20     double c_top = c_zNear * (1+f(2,1)) / f(1,1); 
    21     double c_bottom = c_zNear * (f(2,1)-1.0f) / f(1,1); 
    22      
    23     f.getFrustum(c_left,c_right,c_bottom,c_top,c_zNear,c_zFar); 
    24  
    25     std::cout << "testFrustum"<<std::endl; 
     13    double c_left=0; 
     14    double c_right=0; 
     15    double c_top=0; 
     16    double c_bottom=0; 
     17    double c_zNear=0; 
     18    double c_zFar=0; 
     19     
     20     
     21    std::cout << "testFrustum"<<f.getFrustum(c_left,c_right,c_bottom,c_top,c_zNear,c_zFar)<<std::endl; 
    2622    std::cout << "  left = "<<left<<" compute "<<c_left<<std::endl; 
    2723    std::cout << "  right = "<<right<<" compute "<<c_right<<std::endl; 
     
    4137    f.makeOrtho(left,right,bottom,top,zNear,zFar); 
    4238 
    43     double c_zNear = (f(3,2)+1.0f) / f(2,2); 
    44     double c_zFar = (f(3,2)-1.0f) / f(2,2); 
    45      
    46     double c_left = -(1.0f+f(3,0)) / f(0,0); 
    47     double c_right = (1.0f-f(3,0)) / f(0,0); 
    48  
    49     double c_bottom = -(1.0f+f(3,1)) / f(1,1); 
    50     double c_top = (1.0f-f(3,1)) / f(1,1); 
    51      
    52     f.getOrtho(c_left,c_right,c_bottom,c_top,c_zNear,c_zFar); 
    53  
    54  
    55     std::cout << "testOrtho"<<std::endl; 
     39    double c_left=0; 
     40    double c_right=0; 
     41    double c_top=0; 
     42    double c_bottom=0; 
     43    double c_zNear=0; 
     44    double c_zFar=0; 
     45 
     46    std::cout << "testOrtho "<< f.getOrtho(c_left,c_right,c_bottom,c_top,c_zNear,c_zFar) << std::endl; 
    5647    std::cout << "  left = "<<left<<" compute "<<c_left<<std::endl; 
    5748    std::cout << "  right = "<<right<<" compute "<<c_right<<std::endl; 
     
    5950    std::cout << "  bottom = "<<bottom<<" compute "<<c_bottom<<std::endl; 
    6051    std::cout << "  top = "<<top<<" compute "<<c_top<<std::endl; 
     52 
     53    std::cout << "  zNear = "<<zNear<<" compute "<<c_zNear<<std::endl; 
     54    std::cout << "  zFar = "<<zFar<<" compute "<<c_zFar<<std::endl; 
     55     
     56    std::cout << std::endl; 
     57} 
     58 
     59void testPerspective(double fovy,double aspect,double zNear,double zFar) 
     60{ 
     61    osg::Matrix f; 
     62    f.makePerspective(fovy,aspect,zNear,zFar); 
     63 
     64    double c_fovy=0; 
     65    double c_aspect=0; 
     66    double c_zNear=0; 
     67    double c_zFar=0; 
     68 
     69    std::cout << "testPerspective "<< f.getPerspective(c_fovy,c_aspect,c_zNear,c_zFar) << std::endl; 
     70    std::cout << "  fovy = "<<fovy<<" compute "<<c_fovy<<std::endl; 
     71    std::cout << "  aspect = "<<aspect<<" compute "<<c_aspect<<std::endl; 
    6172 
    6273    std::cout << "  zNear = "<<zNear<<" compute "<<c_zNear<<std::endl; 
     
    159170        testOrtho(-1,10,1,20,2.5,100000); 
    160171 
     172        testPerspective(20,1,1,1000); 
     173        testPerspective(90,2,1,1000); 
     174 
    161175        testLookAt(osg::Vec3(10.0,4.0,2.0),osg::Vec3(10.0,4.0,2.0)+osg::Vec3(0.0,1.0,0.0),osg::Vec3(0.0,0.0,1.0)); 
    162176        testLookAt(osg::Vec3(10.0,4.0,2.0),osg::Vec3(10.0,4.0,2.0)+osg::Vec3(1.0,1.0,0.0),osg::Vec3(0.0,0.0,1.0));