Changeset 387
- Timestamp:
- Jun 16, 2012, 1:57:23 PM (13 years ago)
- Location:
- experimental/distortionNG
- Files:
-
- 2 added
- 3 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 } -
experimental/distortionNG/DistortionSetupStrategyProjectSyntropy.cpp
r384 r387 387 387 for(int col=0;col<distortionMeshColumns;col++) 388 388 { 389 float x=col/distortionMeshColumns; // Vertex X 390 float y=row/distortionMeshRows; // Vertex Y 391 float z=col/distortionMeshColumns; // TexCoord X 392 float w=row/distortionMeshRows; // TexCoord Y 393 if(_distortionType==VERTEXDISTORTION || _distortionType==COMBINEDDISTORTION) 389 float x=(float)col/(float)(distortionMeshColumns-1); // Vertex X 390 float y=(float)row/(float)(distortionMeshRows-1); // Vertex Y 391 float z=(float)col/(float)(distortionMeshColumns-1); // TexCoord X 392 float w=(float)row/(float)(distortionMeshRows-1); // TexCoord Y 393 394 /* if(_distortionType==VERTEXDISTORTION || _distortionType==COMBINEDDISTORTION) 394 395 { 395 396 x = vertexMeshVec2->at(row*col).x(); … … 400 401 z = texCoordMeshVec2->at(row*col).x(); 401 402 w = texCoordMeshVec2->at(row*col).y(); 402 } 403 }*/ 403 404 404 405 distortionMesh->at(row*distortionMeshColumns+col).set(x,y,z,w); 405 406 } 406 407 } 408 409 for (osg::Vec4Array::iterator it = distortionMesh->begin(); it != distortionMesh->end(); ++it) 410 { 411 OSG_ALWAYS<<"final vector: "<<(*it).x()<<" "<<(*it).y()<<" "<<(*it).z()<<" "<<(*it).w()<<std::endl; 412 } 413 407 414 408 415 distortionSet->setDistortionMesh(distortionMesh); -
experimental/distortionNG/main.cpp
r383 r387 58 58 // ---- test plugin read / write 59 59 //osgDB::writeObjectFile( *_distortionSet, "distortionset.dist" ); 60 _distortionSet = NULL;61 _distortionSet = dynamic_cast<osgViewer::DistortionSet*>( osgDB::readObjectFile( "distortionset.dist" ) );60 //_distortionSet = NULL; 61 //_distortionSet = dynamic_cast<osgViewer::DistortionSet*>( osgDB::readObjectFile( "distortionset.dist" ) ); 62 62 // ------------ Test ende ----------- 63 63
Note: See TracChangeset
for help on using the changeset viewer.