Ignore:
Timestamp:
Sep 4, 2011, 7:20:19 PM (13 years ago)
Author:
Torben Dannhauer
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • experimental/distortionNG/extViewer.cpp

    r313 r314  
    1212extViewer::extViewer() : Viewer()
    1313{
    14 
    1514}
    1615
    1716extViewer::extViewer(osg::ArgumentParser& arguments) : Viewer(arguments)
    1817{
    19 
     18//      setUpViewForManualDistortion(0);
    2019}
    2120
     
    163162osg::Geometry* extViewer::createMesh( unsigned int column, unsigned int row )
    164163{
    165         osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array(column * row);
    166         osg::ref_ptr<osg::Vec2Array> texcoords = new osg::Vec2Array(column * row);
     164        // Create Quad to render on
     165        osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
     166
     167        geom->setUseDisplayList( false );
     168
     169
     170        // Create vertices and coordinates
     171        osg::Vec3Array* vertices = new osg::Vec3Array;
     172    osg::Vec2Array* texcoords0 = new osg::Vec2Array;
     173    //osg::Vec2Array* texcoords1 = intensityMap==0 ? new osg::Vec2Array : 0;
     174    osg::Vec4Array* colors = new osg::Vec4Array;
     175
     176        geom->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED);
     177
    167178        for ( unsigned int i=0; i<row; ++i )
    168179        {
    169180                for ( unsigned int j=0; j<column; ++j )
    170181                {
    171                         (*vertices)[i*column + j].set( (float)i, (float)j, 0.0f );
    172                         (*texcoords)[i*column + j].set( (float)i/(float)row, (float)j/(float)column );
     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) );
     184
     185//      if (intensityMap)
     186//    {
     187//        colors->push_back(intensityMap->getColor(texcoord1));
     188//    }
     189//    else
     190//    {
     191        colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
     192//        if (texcoords1) texcoords1->push_back( texcoord1 );
     193//    }
     194
    173195                }
    174196        }
    175197
    176         osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
    177         geom->setUseDisplayList( false );
     198
     199        // Pass the created vertex array to the points geometry object.
    178200        geom->setUseVertexBufferObjects( true );
    179         geom->setVertexArray( vertices.get() );
    180         geom->setTexCoordArray( 0, texcoords.get() );
     201        geom->setVertexArray(vertices);
     202
     203        geom->setColorArray(colors);
     204    geom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
     205
     206    geom->setTexCoordArray(0,texcoords0);
     207    //if (texcoords1) geometry->setTexCoordArray(1,texcoords1);
     208
     209
     210
     211 //   osg::DrawElementsUShort* elements = new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES);
     212 //   geometry->addPrimitiveSet(elements);
     213
    181214        for ( unsigned int i=0; i<row-1; ++i )
    182215        {
Note: See TracChangeset for help on using the changeset viewer.