Changeset 316 for experimental
- Timestamp:
- Sep 7, 2011, 10:16:11 PM (13 years ago)
- Location:
- experimental/distortionNG
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/distortionNG/extViewer.cpp
r315 r316 118 118 osg::Geode* geode = new osg::Geode(); 119 119 //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)); 121 121 122 122 // new we need to add the texture to the mesh, we do so by creating a … … 160 160 } 161 161 162 osg::Geometry* extViewer::createMesh( unsigned int column, unsigned int row)162 osg::Geometry* extViewer::createMesh(const osg::Vec3& origin, const osg::Vec3& widthVector, const osg::Vec3& heightVector, unsigned int columns, unsigned int rows ) 163 163 { 164 164 // Create Quad to render on … … 166 166 167 167 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))); 168 179 169 180 … … 176 187 geom->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED); 177 188 178 for ( unsigned int i=0; i<row ; ++i )189 for ( unsigned int i=0; i<rows; ++i ) 179 190 { 180 for ( unsigned int j=0; j<column ; ++j )191 for ( unsigned int j=0; j<columns; ++j ) 181 192 { 182 vertices->push_back( o sg::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) ); 184 195 185 196 // if (intensityMap) … … 212 223 // geometry->addPrimitiveSet(elements); 213 224 214 for ( unsigned int i=0; i<row -1; ++i )225 for ( unsigned int i=0; i<rows-1; ++i ) 215 226 { 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 ) 218 229 { 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; 221 232 } 222 233 geom->addPrimitiveSet( de.get() ); -
experimental/distortionNG/extViewer.h
r315 r316 16 16 void setUpViewForManualDistortion(unsigned int screenNum=0, osg::Image* intensityMap=0, const osg::Matrixd& projectorMatrix = osg::Matrixd()); 17 17 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); 19 19 };
Note: See TracChangeset
for help on using the changeset viewer.