Changeset 387 for experimental/distortionNG/DistortionManipulator.cpp
- Timestamp:
- Jun 16, 2012, 1:57:23 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/distortionNG/DistortionManipulator.cpp
r386 r387 547 547 for(unsigned int i=0;i<_distortionSet->getDistortionMesh()->size();i++) 548 548 { 549 osg::Vec4 tmpSrc = _distortionSet->getDistortionMesh()->at(i); 550 549 551 // Scale vector with the screen resolution 550 osg::Vec3 tmpVec = osg::Vec3( _distortionSet->getDistortionMesh()->at(i).x()*_screenPixWidth,551 _distortionSet->getDistortionMesh()->at(i).y()*_screenPixHeight,552 osg::Vec3 tmpVec = osg::Vec3( tmpSrc.x()*_screenPixWidth, 553 tmpSrc.y()*_screenPixHeight, 552 554 0.0 ); 553 555 vertices->push_back( tmpVec ); … … 555 557 556 558 // Note texCoords 557 osg::Vec2 tmpTexCoords = osg::Vec2( _distortionSet->getDistortionMesh()->at(i).z()*_screenPixWidth,558 _distortionSet->getDistortionMesh()->at(i).w()*_screenPixHeight );559 osg::Vec2 tmpTexCoords = osg::Vec2( tmpSrc.z()*_screenPixWidth, 560 tmpSrc.w()*_screenPixHeight ); 559 561 texCoords->push_back(tmpTexCoords); 562 //OSG_ALWAYS<<"Transfering texcoord vertex : X:"<<tmpTexCoords.x()<<" Y:"<<tmpTexCoords.y()<<std::endl; 560 563 561 564 colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); 562 565 } 563 566 564 // Apply arrays567 // --------- Apply Arrays ----------------- 565 568 osg::Geometry* geom = _distortionSet->getDistortionInternals()->getChild(osgViewer::DistortionSet::MESH)->asGeode()->getDrawable(0)->asGeometry(); 566 569 567 geom->removePrimitiveSet(0); 570 // If arraysize differs: Replace primite sets 571 bool regeneratePrimitiveSets = true; 572 osg::Vec3Array* prevArray = dynamic_cast<osg::Vec3Array*>(geom->getVertexArray()); 573 if(prevArray) 574 regeneratePrimitiveSets = prevArray->size()!=vertices->size()?true:false; 575 576 // Set new Arrays 568 577 geom->setVertexArray(vertices); 569 578 geom->setTexCoordArray(0, texCoords); // todo: 0 ist hardcoded und müsste durch getTexUnitScene() ersetzt werden 570 579 geom->setColorArray(colors); 571 572 // Quads grid 580 581 // If required: regenerate primitiveset: 582 OSG_ALWAYS<<"PrimitiveSet regeneration required!"<<std::endl; 583 geom->removePrimitiveSet(0, geom->getNumPrimitiveSets()); 584 //// Create new primitives : Quads grid 573 585 unsigned int rows = _distortionSet->getDistortionMeshRows(); 574 586 unsigned int columns = _distortionSet->getDistortionMeshColumns(); … … 583 595 geom->addPrimitiveSet( de.get() ); 584 596 } 585 586 //geom->dirtyDisplayList(); 587 } 597 }
Note: See TracChangeset
for help on using the changeset viewer.