Ignore:
Timestamp:
Sep 7, 2011, 10:16:11 PM (13 years ago)
Author:
Torben Dannhauer
Message:
 
Location:
experimental/distortionNG
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • experimental/distortionNG/extViewer.cpp

    r315 r316  
    118118        osg::Geode* geode = new osg::Geode();
    119119                //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));
    120                 geode->addDrawable(createMesh(160, 190));
     120                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), 160, 190));
    121121
    122122        // new we need to add the texture to the mesh, we do so by creating a
     
    160160}
    161161
    162 osg::Geometry* extViewer::createMesh( unsigned int column, unsigned int row )
     162osg::Geometry* extViewer::createMesh(const osg::Vec3& origin, const osg::Vec3& widthVector, const osg::Vec3& heightVector, unsigned int columns, unsigned int rows )
    163163{
    164164        // Create Quad to render on
     
    166166
    167167        geom->setUseDisplayList( false );
     168
     169        osg::Vec3 xAxis(widthVector);
     170    float width = widthVector.length();
     171    xAxis /= width;
     172
     173    osg::Vec3 yAxis(heightVector);
     174    float height = heightVector.length();
     175    yAxis /= height;
     176
     177        osg::Vec3 dx = xAxis*(width/((float)(columns)));
     178    osg::Vec3 dy = yAxis*(height/((float)(rows)));
    168179
    169180
     
    176187        geom->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED);
    177188
    178         for ( unsigned int i=0; i<row; ++i )
     189        for ( unsigned int i=0; i<rows; ++i )
    179190        {
    180                 for ( unsigned int j=0; j<column; ++j )
     191                for ( unsigned int j=0; j<columns; ++j )
    181192                {
    182                         vertices->push_back( osg::Vec3((float)i, (float)j, 0.0f) );
    183                         texcoords0->push_back( osg::Vec2((float)i/(float)row, (float)j/(float)column) );
     193                        vertices->push_back( origin+dy*i+dx*j );
     194                        texcoords0->push_back( osg::Vec2((float)j/(float)columns, (float)i/(float)rows) );
    184195
    185196//      if (intensityMap)
     
    212223 //   geometry->addPrimitiveSet(elements);
    213224
    214         for ( unsigned int i=0; i<row-1; ++i )
     225        for ( unsigned int i=0; i<rows-1; ++i )
    215226        {
    216                 osg::ref_ptr<osg::DrawElementsUInt> de = new osg::DrawElementsUInt(GL_QUAD_STRIP, column*2);
    217                 for ( unsigned int j=0; j<column; ++j )
     227                osg::ref_ptr<osg::DrawElementsUInt> de = new osg::DrawElementsUInt(GL_QUAD_STRIP, columns*2);
     228                for ( unsigned int j=0; j<columns; ++j )
    218229                {
    219                         (*de)[j*2 + 0] = i*column + j;
    220                         (*de)[j*2 + 1] = (i+1)*column + j;
     230                        (*de)[j*2 + 0] = i*columns + j;
     231                        (*de)[j*2 + 1] = (i+1)*columns + j;
    221232                }
    222233                geom->addPrimitiveSet( de.get() );
  • experimental/distortionNG/extViewer.h

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