Changeset 382 for experimental/distortionNG
- Timestamp:
- Jun 15, 2012, 10:35:40 AM (12 years ago)
- Location:
- experimental/distortionNG
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/distortionNG/DistortionSetupStrategyProjectSyntropy.cpp
r379 r382 95 95 frustumValues[j]=atof(const_cast<char*>(valueString.c_str())); 96 96 } 97 98 } 99 97 } 100 98 } 101 99 inputFile.close(); … … 168 166 } 169 167 170 int DistortionSetupStrategyProjectSyntropy::readMeshPointsFromCSVFile(std::string filePath, osg::Vec2Array* meshPointsVec2, osg::Vec3Array* meshPointsVec3, int displayWidth, int displayHeight) 171 { 172 168 int DistortionSetupStrategyProjectSyntropy::readMeshPointsFromCSVFile(std::string filePath, osg::Vec2Array* tmpMesh) 169 { 173 170 int numValues=6; 174 171 std::string line, valueString; … … 211 208 } 212 209 213 // Insertion of Values U and V (corresponding to values[2],values[3] in a temporary Array 214 // which is returned and merged into distortionSet later 215 216 if((_distortionType==TEXCOORDDISTORTION) || (_distortionType==COMBINEDDISTORTION)) 217 { 218 tempVec2.set(values[2],values[3]); 219 meshPointsVec2->push_back(tempVec2); 220 } 221 if((_distortionType==VERTEXDISTORTION) || (_distortionType==COMBINEDDISTORTION)) 222 { 223 tempVec3.set(values[2]*displayWidth,values[3]*displayHeight,0.0); 224 meshPointsVec3->push_back(tempVec3); 225 } 226 } 227 210 // Store values into array 211 tmpMesh->push_back(osg::Vec2(values[2], values[3])); 212 } 228 213 } 229 214 inputFile.close(); … … 237 222 return 0; 238 223 } 239 240 241 242 243 244 224 245 225 void DistortionSetupStrategyProjectSyntropy::delegateDistortionSetup(osgViewer::DistortionSet* distortionSet) … … 322 302 distortionSet->setViewOffset(viewOffset); 323 303 distortionSet->setProjectionOffset(projectionOffset); 324 return; 304 325 305 // ******************************* // 326 306 // ******* Distortion Mesh ******* // … … 334 314 //*** both Arrays are listed in "HorizontalLine-after-HorizontalLine" order, ***// 335 315 //*** sorted from topleft (0,0,0 vertices; 0,0 texcoords) to bottomright ***// 336 //*** (1920,1080,0 vertices; 1,1 texcoords) ***//316 //*** (1920,1080,0 vertices; 1,1 texcoords) ***// 337 317 //*******************************************************************************************// 338 318 339 if(0) 340 { 341 osg::Vec3Array* vertices = (osg::Vec3Array*) distortionMeshGeometry->getVertexArray(); 342 osg::Vec2Array* texcoords0 = (osg::Vec2Array*) distortionMeshGeometry->getTexCoordArray(0); 343 344 for (osg::Vec3Array::iterator it = vertices->begin(); it != vertices->end(); ++it) 345 { 346 OSG_ALWAYS<<"Vertice "<<(*it).x()<<" "<<(*it).y()<<" "<<(*it).z()<<std::endl; 347 } 348 349 for (osg::Vec2Array::iterator it = texcoords0->begin(); it != texcoords0->end(); ++it) 350 { 351 OSG_ALWAYS<<"Texcoord "<<(*it).x()<<" "<<(*it).y()<<std::endl; 352 } 353 } 319 #if 1 320 osg::Vec3Array* vertices = (osg::Vec3Array*) distortionMeshGeometry->getVertexArray(); 321 osg::Vec2Array* texcoords0 = (osg::Vec2Array*) distortionMeshGeometry->getTexCoordArray(0); 322 323 for (osg::Vec3Array::iterator it = vertices->begin(); it != vertices->end(); ++it) 324 { 325 OSG_ALWAYS<<"Vertice "<<(*it).x()<<" "<<(*it).y()<<" "<<(*it).z()<<std::endl; 326 } 327 328 for (osg::Vec2Array::iterator it = texcoords0->begin(); it != texcoords0->end(); ++it) 329 { 330 OSG_ALWAYS<<"Texcoord "<<(*it).x()<<" "<<(*it).y()<<std::endl; 331 } 332 #endif 354 333 355 334 //*******************************************************************************************// 356 //*** MESH WARPING ***//335 //*** MESH WARPING ***// 357 336 //*** Both Vertex Warping and Texcoord Warping is supported. Although there might ***// 358 337 //*** be a preferred version for osgvisual, both options should be implemented in osg ***// 359 338 //*******************************************************************************************// 360 339 340 // Exctract mesh dimensions from file and pass them to the container 361 341 int distortionMeshRows=0, distortionMeshColumns=0; 362 363 342 readMeshDimensionsFromCSVFile(_distortionFilename, &distortionMeshRows, &distortionMeshColumns); 364 343 … … 366 345 distortionSet->setDistortionMeshColumns(distortionMeshColumns); 367 346 368 osg::Vec2Array* distortionMeshVec2 = new osg::Vec2Array; 369 osg::Vec3Array* distortionMeshVec3 = new osg::Vec3Array; 347 osg::Vec2Array* tmpMeshVec2 = new osg::Vec2Array; 348 osg::Vec3Array* vertexMeshVec3 = new osg::Vec3Array; 349 350 readMeshPointsFromCSVFile(_distortionFilename, tmpMeshVec2); 370 351 371 352 if((_distortionType==TEXCOORDDISTORTION) || (_distortionType==COMBINEDDISTORTION)) 372 353 { 373 readMeshPointsFromCSVFile(_distortionFilename, distortionMeshVec2, distortionMeshVec3, width, height); 374 distortionSet->getDistortionInternals()->getChild(osgViewer::DistortionSet::MESH)->asGeode()->getDrawable(0)->asGeometry()->setTexCoordArray(0,distortionMeshVec2); 354 distortionSet->getDistortionInternals()->getChild(osgViewer::DistortionSet::MESH)->asGeode()->getDrawable(0)->asGeometry()->setTexCoordArray(0,tmpMeshVec2); 375 355 } 376 356 377 357 if((_distortionType==VERTEXDISTORTION) || (_distortionType==COMBINEDDISTORTION)) 378 358 { 379 readMeshPointsFromCSVFile(_distortionFilename, distortionMeshVec2, distortionMeshVec3, width, height); 380 distortionSet->getDistortionInternals()->getChild(osgViewer::DistortionSet::MESH)->asGeode()->getDrawable(0)->asGeometry()->setVertexArray(distortionMeshVec3); 381 382 } 383 359 for(unsigned int i=0;i<tmpMeshVec2->size();i++) 360 { 361 // Scale vector with the screen resolution 362 osg::Vec3 tmpVec = osg::Vec3( tmpMeshVec2->at(i).x()*width, 363 tmpMeshVec2->at(i).y()*height, 364 0.0 ); 365 vertexMeshVec3->push_back( tmpVec ); 366 } 367 distortionSet->getDistortionInternals()->getChild(osgViewer::DistortionSet::MESH)->asGeode()->getDrawable(0)->asGeometry()->setVertexArray(vertexMeshVec3); 368 369 } 384 370 } 385 386 } 387 388 } 371 } 372 } -
experimental/distortionNG/DistortionSetupStrategyProjectSyntropy.h
r377 r382 40 40 int readFrustumFromCSVFile(std::string filePath, int numValues, float* frustumValues); 41 41 int readMeshDimensionsFromCSVFile(std::string filePath, int* meshRows, int* meshColumns); 42 int readMeshPointsFromCSVFile(std::string filePath, osg::Vec2Array* meshPointsVec2, osg::Vec3Array* meshPointsVec3); 43 int readMeshPointsFromCSVFile(std::string filePath, osg::Vec2Array* meshPointsVec2, osg::Vec3Array* meshPointsVec3, int displayWidth, int displayHeight); 42 int readMeshPointsFromCSVFile(std::string filePath, osg::Vec2Array* tmpMesh); 44 43 45 44 bool _distortionInitialized; //Is Distortion already initialized?
Note: See TracChangeset
for help on using the changeset viewer.