Changeset 377
- Timestamp:
- Jun 14, 2012, 2:43:38 PM (12 years ago)
- Location:
- experimental/distortionNG
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/distortionNG/DistortionSetupStrategy.h
r376 r377 37 37 virtual void delegateDistortionSetup(osgViewer::DistortionSet* distortionSet)=0; 38 38 39 enum distortionType { VERTEXDISTORTION, TEXCOORDDISTORTION, COMBINEDDISTORTION };39 enum distortionType { VERTEXDISTORTION, TEXCOORDDISTORTION, COMBINEDDISTORTION, UNDEFINED}; 40 40 41 41 protected: -
experimental/distortionNG/DistortionSetupStrategyProjectSyntropy.cpp
r376 r377 25 25 DistortionSetupStrategyProjectSyntropy::DistortionSetupStrategyProjectSyntropy() 26 26 { 27 _switchDistortionTypeVortexToTexcoords=false; 28 29 _intensityMapFilename="./resources/ProjectSyntropy/blending_1.bmp"; 30 31 _frustumVortexDistortionFilename="./resources/ProjectSyntropy/Vertices/frustum_1.csv"; 32 _frustumTexcoordDistortionFilename="./resources/ProjectSyntropy/TexCoords/frustum_1.csv"; 33 34 _meshVortexDistortionFilename="./resources/ProjectSyntropy/Vertices/warpmap_1.csv"; 35 _meshTexcoordDistortionFilename="./resources/ProjectSyntropy/TexCoords/warpmap_1.csv"; 36 27 _blendmapFilename = ""; 28 _frustumFilename = ""; 29 _distortionFilename = ""; 30 _distortionType = DistortionSetupStrategy::UNDEFINED; 37 31 38 32 _distortionInitialized=false; … … 41 35 DistortionSetupStrategyProjectSyntropy::~DistortionSetupStrategyProjectSyntropy() 42 36 { 37 43 38 } 44 39 45 40 void DistortionSetupStrategyProjectSyntropy::setDistortionInputFiles( std::string distortionFile, std::string blendmapFile, std::string frustumFile, DistortionSetupStrategy::distortionType type) 46 41 { 47 42 _distortionType = type; 43 _blendmapFilename = blendmapFile; 44 _frustumFilename = frustumFile; 45 _distortionFilename = distortionFile; 48 46 } 49 47 … … 213 211 214 212 // Insertion of Values U and V (corresponding to values[2],values[3] in a temporary Array 215 // which is returned and merged into distortionSet later 216 if(_switchDistortionTypeVortexToTexcoords) 213 // which is returned and merged into distortionSet later 214 215 if((_distortionType==TEXCOORDDISTORTION) || (_distortionType==COMBINEDDISTORTION)) 217 216 { 218 217 tempVec2.set(values[2],values[3]); 219 218 meshPointsVec2->push_back(tempVec2); 220 219 } 221 else220 if((_distortionType==VERTEXDISTORTION) || (_distortionType==COMBINEDDISTORTION)) 222 221 { 223 222 tempVec3.set(values[2]*displayWidth,values[3]*displayHeight,0.0); … … 251 250 } 252 251 252 if( _distortionType == DistortionSetupStrategy::UNDEFINED || _blendmapFilename.empty() || _frustumFilename.empty() || _distortionFilename.empty() ) 253 { 254 OSG_ALWAYS<<"DistortionSetupStrategyProjectSyntropy::delegateDistortionSetup : You have not specified the imput filenames and distortion type!"<<std::endl; 255 return; 256 } 257 253 258 //OSG_ALWAYS<<"drin"<<std::endl; 254 259 255 if (_distortionInitialized==false )260 if (_distortionInitialized==false ) 256 261 { 257 262 … … 261 266 262 267 osg::Image* intensityMap=NULL; 263 intensityMap=osgDB::readImageFile(_ intensityMapFilename);268 intensityMap=osgDB::readImageFile(_blendmapFilename); 264 269 osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface(); 265 270 if (!wsi) … … 293 298 double zNear=0.1, zFar=100.0; 294 299 295 if(_switchDistortionTypeVortexToTexcoords) readFrustumFromCSVFile(_frustumTexcoordDistortionFilename, numFrustumValues, frustumValues); 296 else readFrustumFromCSVFile(_frustumVortexDistortionFilename, numFrustumValues, frustumValues); 297 300 readFrustumFromCSVFile(_frustumFilename, numFrustumValues, frustumValues); 301 298 302 osg::Matrixd viewOffset=osg::Matrixd(); 299 303 osg::Matrixd projectionOffset=osg::Matrixd(); … … 308 312 309 313 //Frustum Parameters: Left, Right, Bottom, Top, zNear, zFar 314 //Alternative: viewer->camera->setprojectionmatrixasfrustum? 310 315 projectionOffset.makeFrustum(osg::inDegrees(frustumValues[6]), osg::inDegrees(frustumValues[7]), osg::inDegrees(frustumValues[8]), osg::inDegrees(frustumValues[9]), zNear, zFar); 311 316 … … 349 354 //*******************************************************************************************// 350 355 351 352 356 int distortionMeshRows=0, distortionMeshColumns=0; 353 if(_switchDistortionTypeVortexToTexcoords) readMeshDimensionsFromCSVFile(_meshTexcoordDistortionFilename, &distortionMeshRows, &distortionMeshColumns); 354 else readMeshDimensionsFromCSVFile(_meshVortexDistortionFilename, &distortionMeshRows, &distortionMeshColumns);357 358 readMeshDimensionsFromCSVFile(_distortionFilename, &distortionMeshRows, &distortionMeshColumns); 355 359 356 360 distortionSet->setDistortionMeshRows(distortionMeshRows); 357 361 distortionSet->setDistortionMeshColumns(distortionMeshColumns); 358 362 359 360 361 363 osg::Vec2Array* distortionMeshVec2 = new osg::Vec2Array; 362 364 osg::Vec3Array* distortionMeshVec3 = new osg::Vec3Array; 363 365 364 if( _switchDistortionTypeVortexToTexcoords)365 { 366 readMeshPointsFromCSVFile(_ meshTexcoordDistortionFilename, distortionMeshVec2, distortionMeshVec3, width, height);366 if((_distortionType==TEXCOORDDISTORTION) || (_distortionType==COMBINEDDISTORTION)) 367 { 368 readMeshPointsFromCSVFile(_distortionFilename, distortionMeshVec2, distortionMeshVec3, width, height); 367 369 distortionSet->getDistortionInternals()->getChild(osgViewer::DistortionSet::MESH)->asGeode()->getDrawable(0)->asGeometry()->setTexCoordArray(0,distortionMeshVec2); 368 370 } 369 else 370 { 371 readMeshPointsFromCSVFile(_meshVortexDistortionFilename, distortionMeshVec2, distortionMeshVec3, width, height); 371 372 if((_distortionType==VERTEXDISTORTION) || (_distortionType==COMBINEDDISTORTION)) 373 { 374 readMeshPointsFromCSVFile(_distortionFilename, distortionMeshVec2, distortionMeshVec3, width, height); 372 375 distortionSet->getDistortionInternals()->getChild(osgViewer::DistortionSet::MESH)->asGeode()->getDrawable(0)->asGeometry()->setVertexArray(distortionMeshVec3); 373 376 -
experimental/distortionNG/DistortionSetupStrategyProjectSyntropy.h
r376 r377 44 44 45 45 bool _distortionInitialized; //Is Distortion already initialized? 46 bool _switchDistortionTypeVortexToTexcoords; //Indicates if Texcoord- (true) or Vortexdistortion (false) is selected 46 DistortionSetupStrategy::distortionType _distortionType; //might be VERTEXDISTORTION, TEXCOORDDISTORTION, COMBINEDDISTORTION or UNDEFINED... 47 std::string _blendmapFilename; 48 std::string _frustumFilename; 49 std::string _distortionFilename; 47 50 48 //Paths of Blending/Warping related Files49 std::string _intensityMapFilename;50 51 std::string _frustumVortexDistortionFilename;52 std::string _frustumTexcoordDistortionFilename;53 54 std::string _meshVortexDistortionFilename;55 std::string _meshTexcoordDistortionFilename;56 51 };
Note: See TracChangeset
for help on using the changeset viewer.