Changeset 382 for experimental


Ignore:
Timestamp:
Jun 15, 2012, 10:35:40 AM (12 years ago)
Author:
Torben Dannhauer
Message:
 
Location:
experimental/distortionNG
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • experimental/distortionNG/DistortionSetupStrategyProjectSyntropy.cpp

    r379 r382  
    9595                                        frustumValues[j]=atof(const_cast<char*>(valueString.c_str()));
    9696                                }
    97 
    98                         }
    99 
     97                        }
    10098                }
    10199                inputFile.close();
     
    168166}
    169167
    170 int DistortionSetupStrategyProjectSyntropy::readMeshPointsFromCSVFile(std::string filePath, osg::Vec2Array* meshPointsVec2, osg::Vec3Array* meshPointsVec3, int displayWidth, int displayHeight)
    171 {
    172 
     168int DistortionSetupStrategyProjectSyntropy::readMeshPointsFromCSVFile(std::string filePath, osg::Vec2Array* tmpMesh)
     169{
    173170        int numValues=6;
    174171        std::string line, valueString;
     
    211208                                }
    212209
    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                        }
    228213                }
    229214                inputFile.close();
     
    237222        return 0;
    238223}
    239 
    240 
    241 
    242 
    243 
    244224
    245225void DistortionSetupStrategyProjectSyntropy::delegateDistortionSetup(osgViewer::DistortionSet* distortionSet)
     
    322302                distortionSet->setViewOffset(viewOffset);
    323303                distortionSet->setProjectionOffset(projectionOffset);
    324 return;
     304
    325305                // ******************************* //
    326306                // ******* Distortion Mesh ******* //
     
    334314                        //***    both Arrays are listed in "HorizontalLine-after-HorizontalLine" order,           ***//
    335315                        //***    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)                                                                                    ***//
    337317                        //*******************************************************************************************//
    338318                       
    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
    354333
    355334                        //*******************************************************************************************//
    356                         //***    MESH WARPING                                                                     ***//
     335                        //***    MESH WARPING                                                                                                                                     ***//
    357336                        //***    Both Vertex Warping and Texcoord Warping is supported. Although there might      ***//
    358337                        //***    be a preferred version for osgvisual, both options should be implemented in osg  ***//
    359338                        //*******************************************************************************************//
    360339
     340                        // Exctract mesh dimensions from file and pass them to the container
    361341                        int distortionMeshRows=0, distortionMeshColumns=0;
    362 
    363342                        readMeshDimensionsFromCSVFile(_distortionFilename, &distortionMeshRows, &distortionMeshColumns);
    364343
     
    366345                        distortionSet->setDistortionMeshColumns(distortionMeshColumns);
    367346
    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);
    370351
    371352                        if((_distortionType==TEXCOORDDISTORTION) || (_distortionType==COMBINEDDISTORTION))
    372353                        {
    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);
    375355                        }
    376356
    377357                        if((_distortionType==VERTEXDISTORTION) || (_distortionType==COMBINEDDISTORTION))
    378358                        {
    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                        }
    384370                }
    385 
    386         }
    387 
    388 }
     371        }
     372}
  • experimental/distortionNG/DistortionSetupStrategyProjectSyntropy.h

    r377 r382  
    4040        int readFrustumFromCSVFile(std::string filePath, int numValues, float* frustumValues);
    4141        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);
    4443
    4544        bool _distortionInitialized;                            //Is Distortion already initialized?
Note: See TracChangeset for help on using the changeset viewer.