- Timestamp:
- Jun 30, 2012, 8:56:16 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.