Changeset 394 for experimental
- Timestamp:
- Jun 30, 2012, 8:56:16 PM (12 years ago)
- Location:
- experimental/distortionNG
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/distortionNG/DistortionSetupStrategy.h
r377 r394 37 37 virtual void delegateDistortionSetup(osgViewer::DistortionSet* distortionSet)=0; 38 38 39 enum distortionType { VERTEXDISTORTION, TEXCOORDDISTORTION, COMBINEDDISTORTION, UNDEFINED};40 41 39 protected: 42 40 -
experimental/distortionNG/DistortionSetupStrategyProjectSyntropy.cpp
r393 r394 28 28 _blendmapFilename = ""; 29 29 _frustumFilename = ""; 30 _vertexDistortionFilename = ""; 31 _texCoordDistortionFilename = ""; 32 _distortionType = DistortionSetupStrategy::UNDEFINED; 30 _distortionFilename = ""; 33 31 34 32 _distortionInitialized=false; … … 40 38 } 41 39 42 void DistortionSetupStrategyProjectSyntropy::setDistortionInputFiles( std::string vertexDistortionFile, std::string texCoordDistortionFile, std::string blendmapFile, std::string frustumFile, DistortionSetupStrategy::distortionType type) 43 { 44 _distortionType = type; 40 void DistortionSetupStrategyProjectSyntropy::setDistortionInputFiles(std::string distortionFile, std::string blendmapFile, std::string frustumFile) 41 { 45 42 _blendmapFilename = blendmapFile; 46 43 _frustumFilename = frustumFile; 47 _vertexDistortionFilename = vertexDistortionFile; 48 _texCoordDistortionFilename = texCoordDistortionFile; 44 _distortionFilename = distortionFile; 49 45 } 50 46 … … 168 164 } 169 165 170 int DistortionSetupStrategyProjectSyntropy::readMeshPointsFromCSVFile(std::string filePath, osg::Vec 2Array* tmpMesh)166 int DistortionSetupStrategyProjectSyntropy::readMeshPointsFromCSVFile(std::string filePath, osg::Vec4Array* tmpMesh) 171 167 { 172 168 int numValues=6; … … 211 207 212 208 // Store values into array 213 tmpMesh->push_back(osg::Vec 2(values[0], values[1]));209 tmpMesh->push_back(osg::Vec4(values[0], values[1], values[2], values[3])); 214 210 } 215 211 } … … 233 229 } 234 230 235 if( _distortionType == DistortionSetupStrategy::UNDEFINED 236 || _blendmapFilename.empty() 237 || _frustumFilename.empty() 238 || ( _vertexDistortionFilename.empty() && _distortionType == DistortionSetupStrategy::VERTEXDISTORTION ) 239 || ( _texCoordDistortionFilename.empty() && _distortionType == DistortionSetupStrategy::TEXCOORDDISTORTION ) 240 ) 241 { 242 OSG_ALWAYS<<"DistortionSetupStrategyProjectSyntropy::delegateDistortionSetup : You have not specified the imput filenames and distortion type correctly!"<<std::endl; 231 if( _blendmapFilename.empty() || _frustumFilename.empty() || _distortionFilename.empty() ) 232 { 233 OSG_ALWAYS<<"DistortionSetupStrategyProjectSyntropy::delegateDistortionSetup : You have not specified the imput filenames correctly!"<<std::endl; 243 234 return; 244 235 } … … 348 339 //*******************************************************************************************// 349 340 //*** MESH WARPING ***// 350 //*** Both Vertex Warping and Texcoord Warping is supported. Although there might ***// 341 //*** Both Vertex Warping and Texcoord Warping is supported. 342 //*** The input file contains . Although there might ***// 351 343 //*** be a preferred version for osgvisual, both options should be implemented in osg ***// 352 344 //*******************************************************************************************// 353 345 354 346 // Exctract mesh dimensions from file and pass them to the container. 355 // If soley texCoordDistortion is used, _texCoordDistortionFilename is used to determine the dimensions, otherwise _vertexDistortionFilename 347 356 348 int distortionMeshRows=0, distortionMeshColumns=0; 357 readMeshDimensionsFromCSVFile(_distortion Type==DistortionSetupStrategy::TEXCOORDDISTORTION?_texCoordDistortionFilename:_vertexDistortionFilename, &distortionMeshRows, &distortionMeshColumns);349 readMeshDimensionsFromCSVFile(_distortionFilename, &distortionMeshRows, &distortionMeshColumns); 358 350 359 351 distortionSet->setDistortionMeshRows(distortionMeshRows); 360 352 distortionSet->setDistortionMeshColumns(distortionMeshColumns); 361 353 362 // If vertex- and texCoord distortion is combined: Ensure both files have the same dimensions363 if(_distortionType==DistortionSetupStrategy::COMBINEDDISTORTION)364 {365 int texCoordRows=0, texCoordColumns=0;366 readMeshDimensionsFromCSVFile(_texCoordDistortionFilename, &distortionMeshRows, &distortionMeshColumns);367 if(distortionMeshRows!=texCoordRows || distortionMeshColumns!=texCoordColumns)368 {369 OSG_ALWAYS<<"The mesh dimensions of the vertex- and textureCoordinate-file differ!"<<std::endl;370 return;371 }372 }373 374 354 // Read in the mesh arrays 375 osg::Vec2Array* vertexMeshVec2 = new osg::Vec2Array; 376 osg::Vec2Array* texCoordMeshVec2 = new osg::Vec2Array; 377 osg::Vec4Array* distortionMesh = new osg::Vec4Array(distortionMeshRows*distortionMeshColumns); 378 379 if((_distortionType==VERTEXDISTORTION) || (_distortionType==COMBINEDDISTORTION)) 380 { 381 readMeshPointsFromCSVFile(_vertexDistortionFilename, vertexMeshVec2); 382 } 383 384 if((_distortionType==TEXCOORDDISTORTION) || (_distortionType==COMBINEDDISTORTION)) 385 { 386 readMeshPointsFromCSVFile(_texCoordDistortionFilename, texCoordMeshVec2); 387 } 388 389 // Transfer the read values into the combinedArray 390 for(int row=0;row<distortionMeshRows;row++) 391 { 392 for(int col=0;col<distortionMeshColumns;col++) 393 { 394 float x=(float)col/(float)(distortionMeshColumns-1); // Vertex X 395 float y=(float)row/(float)(distortionMeshRows-1); // Vertex Y 396 float z=(float)col/(float)(distortionMeshColumns-1); // TexCoord X 397 float w=(float)row/(float)(distortionMeshRows-1); // TexCoord Y 398 399 if(_distortionType==VERTEXDISTORTION || _distortionType==COMBINEDDISTORTION) 400 { 401 x = vertexMeshVec2->at(row*distortionMeshColumns + col).x(); 402 y = vertexMeshVec2->at(row*distortionMeshColumns + col).y(); 403 } 404 if(_distortionType==TEXCOORDDISTORTION || _distortionType==COMBINEDDISTORTION) 405 { 406 z = texCoordMeshVec2->at(row*distortionMeshColumns + col).x(); 407 w = texCoordMeshVec2->at(row*distortionMeshColumns + col).y(); 408 } 409 410 distortionMesh->at(row*distortionMeshColumns+col).set(x,y,z,w); 411 } 412 } 355 osg::Vec4Array* distortionMesh = new osg::Vec4Array; 356 readMeshPointsFromCSVFile(_distortionFilename, distortionMesh); 413 357 414 358 #if 1 … … 421 365 422 366 distortionSet->setDistortionMesh(distortionMesh); 423 //distortionSet->setDistortionMeshColumns(distortionMeshColumns);424 //distortionSet->setDistortionMeshRows(distortionMeshRows);425 367 distortionSet->setDistortionMeshDimensions(distortionMeshRows, distortionMeshColumns); 426 368 } -
experimental/distortionNG/DistortionSetupStrategyProjectSyntropy.h
r383 r394 35 35 ~DistortionSetupStrategyProjectSyntropy(); 36 36 void delegateDistortionSetup(osgViewer::DistortionSet* distortionSet); 37 void setDistortionInputFiles( std::string vertexDistortionFile, std::string texCoordDistortionFile, std::string blendmapFile, std::string frustumFile, DistortionSetupStrategy::distortionType type);37 void setDistortionInputFiles(std::string distortionFile, std::string blendmapFile, std::string frustumFile); 38 38 private: 39 39 //Functions related to CSV-File-Reading 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::Vec 2Array* tmpMesh);42 int readMeshPointsFromCSVFile(std::string filePath, osg::Vec4Array* tmpMesh); 43 43 44 44 bool _distortionInitialized; //Is Distortion already initialized? 45 DistortionSetupStrategy::distortionType _distortionType; //might be VERTEXDISTORTION, TEXCOORDDISTORTION, COMBINEDDISTORTION or UNDEFINED...46 45 std::string _blendmapFilename; 47 46 std::string _frustumFilename; 48 std::string _vertexDistortionFilename; 49 std::string _texCoordDistortionFilename; 50 47 std::string _distortionFilename; 51 48 }; -
experimental/distortionNG/extViewer.cpp
r392 r394 100 100 osg::Vec3 dy = yAxis*(height/((float)(rows-1))); 101 101 102 103 102 // Create vertices and coordinates 104 103 osg::Vec3Array* vertices = new osg::Vec3Array; … … 112 111 for ( unsigned int col=0; col<columns; col++ ) 113 112 { 113 osg::Vec3 vertex = origin+dy*row+dx*col; 114 114 115 // Create coordinates of the mesh node (geometry). 115 vertices->push_back( origin+dy*row+dx*col ); 116 117 // Create tex coordinates 118 osg::Vec2 texcoord = osg::Vec2((float)col/(float)(columns-1), (float)row/(float)(rows-1)); 116 vertices->push_back( vertex ); 119 117 120 118 // Set Coordinates for RTT-Texture (scene rendering) 121 texcoords0->push_back( texcoord);119 texcoords0->push_back( osg::Vec2( vertex.x(), vertex.y()) ); 122 120 123 121 // Set Color of the mesh node -
experimental/distortionNG/main.cpp
r393 r394 96 96 DistortionSetupStrategyProjectSyntropy* psStrategy = new DistortionSetupStrategyProjectSyntropy(); 97 97 psStrategy->setDistortionInputFiles( "./resources/ProjectSyntropy/Vertices/warpmap_1.csv", 98 "./resources/ProjectSyntropy/TexCoords/warpmap_1.csv",98 //"./resources/ProjectSyntropy/TexCoords/warpmap_1.csv", 99 99 "./resources/ProjectSyntropy/blending_1.bmp", 100 "./resources/ProjectSyntropy/Vertices/frustum_1.csv", 101 DistortionSetupStrategy::TEXCOORDDISTORTION ); 100 "./resources/ProjectSyntropy/Vertices/frustum_1.csv" ); 102 101 distortionManip->setDistortionSetupStrategy( psStrategy ); 103 102 viewer.addEventHandler(distortionManip);
Note: See TracChangeset
for help on using the changeset viewer.