Ignore:
Timestamp:
Jun 15, 2012, 10:09:08 PM (12 years ago)
Author:
Torben Dannhauer
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • experimental/distortionNG/DistortionManipulator.cpp

    r381 r384  
    518518        updateDistortionViewProjectionMatrix();
    519519        updateDistortionMesh();
     520        _distortionSet->clearDirtyStatus();
    520521}
    521522
     
    539540void DistortionManipulator::updateDistortionMesh()
    540541{
    541 
    542 }
     542        // Create mesh vertex array
     543
     544        // Create textCoord array
     545
     546        // Apply arrays
     547
     548        osg::Vec3Array* vertices = new osg::Vec3Array;
     549        osg::Vec2Array* texCoords = new osg::Vec2Array;
     550
     551        for(unsigned int i=0;i<_distortionSet->getDistortionMesh()->size();i++)
     552        {
     553                // Scale vector with the screen resolution
     554                osg::Vec3 tmpVec = osg::Vec3(   _distortionSet->getDistortionMesh()->at(i).x()*_screenPixWidth,
     555                                                                                _distortionSet->getDistortionMesh()->at(i).y()*_screenPixHeight,
     556                                                                                0.0     );
     557                vertices->push_back( tmpVec );
     558                OSG_ALWAYS<<"X:"<<tmpVec.x()<<" Y:"<<tmpVec.y()<<" Z:"<<tmpVec.z()<<std::endl;
     559
     560                // Note texCoords
     561                osg::Vec2 tmpTexCoords = osg::Vec2(     _distortionSet->getDistortionMesh()->at(i).z()*_screenPixWidth,
     562                                                                                        _distortionSet->getDistortionMesh()->at(i).w()*_screenPixHeight );
     563                texCoords->push_back(tmpTexCoords);
     564        }
     565
     566        _distortionSet->getDistortionInternals()->getChild(osgViewer::DistortionSet::MESH)->asGeode()->getDrawable(0)->asGeometry()->setVertexArray(vertices);
     567        _distortionSet->getDistortionInternals()->getChild(osgViewer::DistortionSet::MESH)->asGeode()->getDrawable(0)->asGeometry()->setTexCoordArray(0, texCoords);    // todo: 0 ist hardcoded und müsste durch getTexUnitScene() ersetzt werden
     568        _distortionSet->getDistortionInternals()->getChild(osgViewer::DistortionSet::MESH)->asGeode()->getDrawable(0)->asGeometry()->dirtyDisplayList();
     569
     570}
Note: See TracChangeset for help on using the changeset viewer.