Changeset 328 for experimental


Ignore:
Timestamp:
Mar 2, 2012, 10:41:12 PM (13 years ago)
Author:
Torben Dannhauer
Message:
 
Location:
experimental/distortionNG
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • experimental/distortionNG/extViewer.cpp

    r327 r328  
    7272        return;
    7373    }
     74       
     75        // Set up projection Matrix as it is done in View::setUpViewOnSingleScreen(
     76        double fovy, aspectRatio, zNear, zFar;
     77        _camera->getProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar);
     78
     79        double newAspectRatio = double(traits->width) / double(traits->height);
     80        double aspectRatioChange = newAspectRatio / aspectRatio;
     81        if (aspectRatioChange != 1.0)
     82        {
     83                _camera->getProjectionMatrix() *= osg::Matrix::scale(1.0/aspectRatioChange,1.0,1.0);
     84        }
     85
    7486
    7587    int tex_width = width;
     
    115127    }
    116128
    117         //getCamera()->setProjectionMatrixAsPerspective(90.0f, (float)tex_width/(float)tex_height, 1, 1000.0);
    118 
    119129    // distortion correction set up.
    120130    {
    121131        osg::Geode* geode = new osg::Geode();
    122132                //geode->addDrawable(createParoramicSphericalDisplayDistortionMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 1, 0.45, 0, projectorMatrix));
    123                 geode->addDrawable(createMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 20, 20));
     133                geode->addDrawable(createMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 20, 20, projectorMatrix));
    124134
    125135        // new we need to add the texture to the mesh, we do so by creating a
     
    163173}
    164174
    165 osg::Geometry* extViewer::createMesh(const osg::Vec3& origin, const osg::Vec3& widthVector, const osg::Vec3& heightVector, unsigned int columns, unsigned int rows )
     175osg::Geometry* extViewer::createMesh(const osg::Vec3& origin, const osg::Vec3& widthVector, const osg::Vec3& heightVector, unsigned int columns, unsigned int rows, const osg::Matrix& projectorMatrix)
    166176{
    167177        // Create Quad to render on
     
    194204                for ( unsigned int col=0; col<columns; col++ )
    195205                {
    196                         vertices->push_back( origin+dy*row+dx*col );
     206                        vertices->push_back( origin+dy*row+dx*col );    // geometry
    197207                        osg::Vec2 texcoord = osg::Vec2((float)col/(float)(columns-1), (float)row/(float)(rows-1));
    198208                        texcoords0->push_back( texcoord );
  • experimental/distortionNG/extViewer.h

    r316 r328  
    1616        void setUpViewForManualDistortion(unsigned int screenNum=0, osg::Image* intensityMap=0, const osg::Matrixd& projectorMatrix = osg::Matrixd());
    1717
    18                 static osg::Geometry* createMesh(const osg::Vec3& origin, const osg::Vec3& widthVector, const osg::Vec3& heightVector, unsigned int columns, unsigned int rows);
     18                static osg::Geometry* createMesh(const osg::Vec3& origin, const osg::Vec3& widthVector, const osg::Vec3& heightVector, unsigned int columns, unsigned int rows, const osg::Matrix& projectorMatrix);
    1919};
Note: See TracChangeset for help on using the changeset viewer.