Changeset 314 for experimental
- Timestamp:
- Sep 4, 2011, 7:20:19 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/distortionNG/extViewer.cpp
r313 r314 12 12 extViewer::extViewer() : Viewer() 13 13 { 14 15 14 } 16 15 17 16 extViewer::extViewer(osg::ArgumentParser& arguments) : Viewer(arguments) 18 17 { 19 18 // setUpViewForManualDistortion(0); 20 19 } 21 20 … … 163 162 osg::Geometry* extViewer::createMesh( unsigned int column, unsigned int row ) 164 163 { 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 167 178 for ( unsigned int i=0; i<row; ++i ) 168 179 { 169 180 for ( unsigned int j=0; j<column; ++j ) 170 181 { 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 173 195 } 174 196 } 175 197 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. 178 200 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 181 214 for ( unsigned int i=0; i<row-1; ++i ) 182 215 {
Note: See TracChangeset
for help on using the changeset viewer.