Changeset 340
- Timestamp:
- Mar 24, 2012, 10:00:11 AM (13 years ago)
- Location:
- experimental/distortionNG
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/distortionNG/distortionNG.cpp
r339 r340 52 52 if ( viewer ) 53 53 { 54 osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, ea.getX(), ea.getY()); 54 osg::notify(osg::ALWAYS)<<std::endl<<"Intersection:"<<std::endl<<"ea.getX()="<<ea.getX()<<std::endl; 55 osg::notify(osg::ALWAYS)<<"ea.getY()="<<ea.getY()<<std::endl; 56 osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::PROJECTION, ea.getX(), ea.getY()); 55 57 osgUtil::IntersectionVisitor iv( intersector.get() ); 56 58 //viewer->getCamera()->accept( iv ); … … 67 69 if ( ea.getEventType() == osgGA::GUIEventAdapter::DRAG ) 68 70 { 69 osg::notify(osg::ALWAYS)<<std::endl<<"ea.getGraphicsContext()="<<ea.getGraphicsContext()<<std::endl;71 osg::notify(osg::ALWAYS)<<std::endl<<"Drag:"<<std::endl<<"ea.getGraphicsContext()="<<ea.getGraphicsContext()<<std::endl; 70 72 osg::notify(osg::ALWAYS)<<"ea.getXnormalized()="<<ea.getXnormalized()<<std::endl; 71 73 osg::notify(osg::ALWAYS)<<"ea.getYnormalized()="<<ea.getYnormalized()<<std::endl; … … 112 114 closestVertexIndex = result.indexList[i]; 113 115 } 114 //OSG_NOTIFY(osg::ALWAYS)<<"maxRatio="<<maxRatio<<std::endl;115 //OSG_NOTIFY(osg::ALWAYS)<<"closestVertexIndex="<<closestVertexIndex<<std::endl;116 OSG_NOTIFY(osg::ALWAYS)<<"maxRatio="<<maxRatio<<std::endl; 117 OSG_NOTIFY(osg::ALWAYS)<<"closestVertexIndex="<<closestVertexIndex<<std::endl; 116 118 } 117 119 OSG_NOTIFY(osg::ALWAYS)<<"nearest vertex: X="<<(*vertices)[closestVertexIndex].x()<<" Y="<<(*vertices)[closestVertexIndex].y()<<" Z="<<(*vertices)[closestVertexIndex].z()<<std::endl; -
experimental/distortionNG/extViewer.cpp
r339 r340 148 148 geom->setTexCoordArray(1,texcoords1); 149 149 150 //// Quads grid 150 // Quads grid 151 for ( unsigned int row=0; row<rows-1; row++ ) // each strip consists of two affected vertex rows, so we need only row-1 strips. 152 { 153 osg::ref_ptr<osg::DrawElementsUInt> de = new osg::DrawElementsUInt(GL_QUAD_STRIP, columns*2); // columns*2 = number of involved vertices for this strip. 154 for ( unsigned int col=0; col<columns; col++ ) 155 { 156 (*de)[col*2 + 0] = row*columns + col; 157 (*de)[col*2 + 1] = (row+1)*columns + col; 158 } 159 geom->addPrimitiveSet( de.get() ); 160 } 161 162 //// Triangle grid 151 163 //for ( unsigned int row=0; row<rows-1; row++ ) // each strip consists of two affected vertex rows, so we need only row-1 strips. 152 164 //{ 153 // osg::ref_ptr<osg::DrawElementsUInt> de = new osg::DrawElementsUInt( GL_QUAD_STRIP, columns*2); // columns*2 = number of involved vertices for this strip.165 // osg::ref_ptr<osg::DrawElementsUInt> de = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLE_STRIP, columns * 2 ); 154 166 // for ( unsigned int col=0; col<columns; col++ ) 155 167 // { … … 159 171 // geom->addPrimitiveSet( de.get() ); 160 172 //} 161 162 // Triangle grid163 for ( unsigned int row=0; row<rows-1; row++ ) // each strip consists of two affected vertex rows, so we need only row-1 strips.164 {165 osg::ref_ptr<osg::DrawElementsUInt> de = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLE_STRIP, columns * 2 );166 for ( unsigned int col=0; col<columns; col++ )167 {168 (*de)[col*2 + 0] = row*columns + col;169 (*de)[col*2 + 1] = (row+1)*columns + col;170 }171 geom->addPrimitiveSet( de.get() );172 }173 173 174 174 return geom.release(); … … 340 340 geode->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF ); 341 341 geode->getOrCreateStateSet()->setAttributeAndModes( new osg::PolygonOffset(1.0f, 1.0f) ); 342 osg::ref_ptr<distortionHandler> selector = new distortionHandler( camera, distortionMesh );342 osg::ref_ptr<distortionHandler> selectorHandler = new distortionHandler( camera, distortionMesh ); 343 343 osg::ref_ptr<osg::Group> root = new osg::Group; 344 344 root->addChild(geode); 345 root->addChild(selector->createVertexHighlighter()); 346 addEventHandler( selector.get() ); 345 osg::Geode* selectorHighlighter = selectorHandler->createVertexHighlighter(); 346 selectorHighlighter->setCullingActive(false); // disable the culling for the selector, otherwise the selector is culled away on the edge. 347 root->addChild(selectorHighlighter); 348 addEventHandler( selectorHandler.get() ); 347 349 camera->addChild(root); 348 350 // Avoid that the highlighter is culled away -
experimental/distortionNG/main.cpp
r331 r340 140 140 /* 141 141 ToDo: 142 143 The intersection works and the selector highlighter is set and displayed correctly. 144 Next steps: 145 * use a variable to control whether distortion setup is active or not. temporarily track the Ctrl Key to enably(push or disable(release) the edit mode. 146 * Hide the highlighter and disable the intersection/drag tracking on diabled edit mode. 147 * catch up dragging values and translate them in the correct coordinate frame. 148 * apply dragging values: 149 * a) either on the texture coordinate while the grid is constant, 150 * b) or apply them on the grid node coordinates while the texture coordinates are constant (check/compare solutions!) 142 151 * 143 * distortionHandler::handle startet Intersections. Da jedoch das distortion Mesh keine Geometry der Scene mehr ist, gibt es keine Intersection 144 * -> es muss die intersektion umgestellt werden, um das Distortion Mesh zu intersecten. 145 * Es muss geprüft werdne, ob bei dne Mausverschiebungen die texturecoordinaten verschoben, oder das Distortion Mesh verschoben wird. 146 147 148 149 152 150 153 151 154 */
Note: See TracChangeset
for help on using the changeset viewer.