Changeset 407 for experimental
- Timestamp:
- Aug 5, 2012, 11:09:39 PM (12 years ago)
- Location:
- experimental/distortionNG
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/distortionNG/DistortionManipulator.cpp
r406 r407 308 308 return; 309 309 310 OSG_ALWAYS<<"ToDo: resetDistortion()"<<std::endl; 310 311 _distortionSet->setDistortionMeshDimensions(2, 2, true); // Reset dimensions and coordinates/texcoords & rebuild mesh data 312 updateDistortionMesh(); // Rebuild OSG Mesh (drawable) 313 // Restore ProjectionMatrix 314 315 // Set up projection Matrix as it is done in View::setUpViewOnSingleScreen( 316 double fovy, aspectRatio, zNear, zFar; 317 _camera->getProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar); 318 319 double newAspectRatio = double(_distortionSet->intensityMap()->width) / double(_distortionSet->intensityMap()->height); 320 double aspectRatioChange = newAspectRatio / aspectRatio; 321 if (aspectRatioChange != 1.0) 322 { 323 _camera->getProjectionMatrix() *= osg::Matrix::scale(1.0/aspectRatioChange,1.0,1.0); 324 } 325 326 311 327 } 312 328 … … 599 615 0.0 ); 600 616 vertices->push_back( tmpVec ); 601 //OSG_ALWAYS<<"Transfering mesh vertex : X:"<<tmpVec.x()<<" Y:"<<tmpVec.y()<<" Z:"<<tmpVec.z()<<std::endl;617 OSG_ALWAYS<<"Transfering mesh vertex : X:"<<tmpVec.x()<<" Y:"<<tmpVec.y()<<" Z:"<<tmpVec.z()<<std::endl; 602 618 603 619 // Note texCoords … … 606 622 607 623 texCoords->push_back(tmpTexCoords); 608 //OSG_ALWAYS<<"Transfering texcoord vertex : X:"<<tmpTexCoords.x()<<" Y:"<<tmpTexCoords.y()<<std::endl;624 OSG_ALWAYS<<"Transfering texcoord vertex : X:"<<tmpTexCoords.x()<<" Y:"<<tmpTexCoords.y()<<std::endl; 609 625 610 626 colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); -
experimental/distortionNG/DistortionSet.cpp
r398 r407 27 27 _matrixDirty = false; 28 28 29 _distortionMeshRows = 2; 30 _distortionMeshColumns = 2; 31 _distortionMesh = new osg::Vec4Array(); 29 setDistortionMeshDimensions(2, 2); 32 30 33 31 _intensityMap = NULL; … … 52 50 } 53 51 54 void DistortionSet::setDistortionMeshDimensions(int rows, int cols )52 void DistortionSet::setDistortionMeshDimensions(int rows, int cols, bool enforceMeshRebuild) 55 53 { 56 54 _distortionMeshRows = rows; 57 55 _distortionMeshColumns = cols; 58 56 59 if( _distortionMesh->size() != _distortionMeshRows * _distortionMeshColumns) // If dimensions differ: discard current mesh and create a new one57 if(!_distortionMesh.valid() || enforceMeshRebuild || _distortionMesh->size() != _distortionMeshRows * _distortionMeshColumns) // If dimensions differ: discard current mesh and create a new one 60 58 { 61 59 _distortionMesh = new osg::Vec4Array(_distortionMeshRows * _distortionMeshColumns); … … 64 62 for(int col=0;col<_distortionMeshColumns;col++) 65 63 { 66 float x=col/ _distortionMeshColumns; // Vertex X67 float y=row/ _distortionMeshRows; // Vertex Y68 float z=col/ _distortionMeshColumns; // TexCoord X69 float w=row/ _distortionMeshRows; // TexCoord Y64 float x=col/(float)(_distortionMeshColumns-1); // Vertex X 65 float y=row/(float)(_distortionMeshRows-1); // Vertex Y 66 float z=col/(float)(_distortionMeshColumns-1); // TexCoord X 67 float w=row/(float)(_distortionMeshRows-1); // TexCoord Y 70 68 71 69 _distortionMesh->at(row*_distortionMeshColumns+col).set(x,y,z,w); -
experimental/distortionNG/DistortionSet.h
r398 r407 59 59 void clearDirtyStatus() { _meshDirty = false; _matrixDirty = false;} 60 60 61 void setDistortionMeshDimensions(int rows, int cols );61 void setDistortionMeshDimensions(int rows, int cols, bool enforceMeshRebuild=false); 62 62 63 63 osg::Image* getIntensityMap() { return _intensityMap; } // Also for manipulating the intensity map -
experimental/distortionNG/main.cpp
r404 r407 230 230 * Laden des Containers. 231 231 * reset distortion implementieren. 232 * Anwenden der distortion auf die Meshknoten oder die texturekoordinaten232 * Anwenden der manuellen distortion auf die Meshknoten oder die texturekoordinaten 233 233 * 234 234 *
Note: See TracChangeset
for help on using the changeset viewer.