Changeset 377


Ignore:
Timestamp:
Jun 14, 2012, 2:43:38 PM (7 years ago)
Author:
Torben Dannhauer
Message:
 
Location:
experimental/distortionNG
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • experimental/distortionNG/DistortionSetupStrategy.h

    r376 r377  
    3737        virtual void delegateDistortionSetup(osgViewer::DistortionSet* distortionSet)=0;
    3838
    39         enum distortionType { VERTEXDISTORTION, TEXCOORDDISTORTION, COMBINEDDISTORTION};
     39        enum distortionType { VERTEXDISTORTION, TEXCOORDDISTORTION, COMBINEDDISTORTION, UNDEFINED};
    4040
    4141protected:
  • experimental/distortionNG/DistortionSetupStrategyProjectSyntropy.cpp

    r376 r377  
    2525DistortionSetupStrategyProjectSyntropy::DistortionSetupStrategyProjectSyntropy()
    2626{
    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;
    3731
    3832        _distortionInitialized=false;
     
    4135DistortionSetupStrategyProjectSyntropy::~DistortionSetupStrategyProjectSyntropy()
    4236{
     37
    4338}
    4439
    4540void DistortionSetupStrategyProjectSyntropy::setDistortionInputFiles( std::string distortionFile, std::string blendmapFile, std::string frustumFile, DistortionSetupStrategy::distortionType type)
    4641{
    47 
     42        _distortionType = type;
     43        _blendmapFilename = blendmapFile;
     44        _frustumFilename = frustumFile;
     45        _distortionFilename = distortionFile;
    4846}
    4947
     
    213211
    214212                                // 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))
    217216                                {
    218217                                        tempVec2.set(values[2],values[3]);
    219218                                        meshPointsVec2->push_back(tempVec2);
    220219                                }
    221                                 else
     220                                if((_distortionType==VERTEXDISTORTION) || (_distortionType==COMBINEDDISTORTION))
    222221                                {
    223222                                        tempVec3.set(values[2]*displayWidth,values[3]*displayHeight,0.0);
     
    251250        }
    252251
     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
    253258        //OSG_ALWAYS<<"drin"<<std::endl;
    254259
    255         if (_distortionInitialized==false)
     260        if (_distortionInitialized==false )
    256261        {
    257262
     
    261266
    262267                osg::Image* intensityMap=NULL;
    263                 intensityMap=osgDB::readImageFile(_intensityMapFilename);
     268                intensityMap=osgDB::readImageFile(_blendmapFilename);
    264269                osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
    265270                if (!wsi)
     
    293298                double zNear=0.1, zFar=100.0;
    294299
    295                 if(_switchDistortionTypeVortexToTexcoords)      readFrustumFromCSVFile(_frustumTexcoordDistortionFilename, numFrustumValues, frustumValues);
    296                 else                                            readFrustumFromCSVFile(_frustumVortexDistortionFilename, numFrustumValues, frustumValues);
    297 
     300                readFrustumFromCSVFile(_frustumFilename, numFrustumValues, frustumValues);
     301               
    298302                osg::Matrixd viewOffset=osg::Matrixd();
    299303                osg::Matrixd projectionOffset=osg::Matrixd();
     
    308312
    309313                //Frustum Parameters: Left, Right, Bottom, Top, zNear, zFar
     314                //Alternative: viewer->camera->setprojectionmatrixasfrustum?
    310315                projectionOffset.makeFrustum(osg::inDegrees(frustumValues[6]), osg::inDegrees(frustumValues[7]), osg::inDegrees(frustumValues[8]), osg::inDegrees(frustumValues[9]), zNear, zFar);
    311316
     
    349354                        //*******************************************************************************************//
    350355
    351 
    352356                        int distortionMeshRows=0, distortionMeshColumns=0;
    353                         if(_switchDistortionTypeVortexToTexcoords)      readMeshDimensionsFromCSVFile(_meshTexcoordDistortionFilename, &distortionMeshRows, &distortionMeshColumns);
    354                         else                                            readMeshDimensionsFromCSVFile(_meshVortexDistortionFilename, &distortionMeshRows, &distortionMeshColumns);
     357
     358                        readMeshDimensionsFromCSVFile(_distortionFilename, &distortionMeshRows, &distortionMeshColumns);
    355359
    356360                        distortionSet->setDistortionMeshRows(distortionMeshRows);
    357361                        distortionSet->setDistortionMeshColumns(distortionMeshColumns);
    358362
    359 
    360 
    361363                        osg::Vec2Array* distortionMeshVec2 = new osg::Vec2Array;
    362364                        osg::Vec3Array* distortionMeshVec3 = new osg::Vec3Array;
    363365
    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);
    367369                                distortionSet->getDistortionInternals()->getChild(osgViewer::DistortionSet::MESH)->asGeode()->getDrawable(0)->asGeometry()->setTexCoordArray(0,distortionMeshVec2);
    368370                        }
    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);
    372375                                distortionSet->getDistortionInternals()->getChild(osgViewer::DistortionSet::MESH)->asGeode()->getDrawable(0)->asGeometry()->setVertexArray(distortionMeshVec3);
    373376
  • experimental/distortionNG/DistortionSetupStrategyProjectSyntropy.h

    r376 r377  
    4444
    4545        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;
    4750
    48         //Paths of Blending/Warping related Files
    49         std::string _intensityMapFilename;
    50 
    51         std::string _frustumVortexDistortionFilename;
    52         std::string _frustumTexcoordDistortionFilename;
    53 
    54         std::string _meshVortexDistortionFilename;
    55         std::string _meshTexcoordDistortionFilename;
    5651};
Note: See TracChangeset for help on using the changeset viewer.