hi sorry but, ... I m totally lost,
What I trying to do is is using QT with OSG. like I said before, I try to get the geode that I ve just clicked (x, y). like you said, I m now using Intersections. like that I suppose osgUtil::LineSegmentIntersector::Intersections inter; if(CGeneral::instance().viewer->computeIntersections((float)event->x(), (float)event->y(), inter)) { for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr= inter.begin();hitr!=inter.end(); ++hitr) { but I have an error Interface.cpp:66: error: 'class SimpleViewerQT' has no member named 'computeIntersections' SimpleViewerQT are like that declared like that class SimpleViewerQT : public osgViewer::SimpleViewer, public GraphicsWindowQT I looked http://www.openscenegraph.net/documentation/OpenSceneGraph/examples/osgpick/osgpick.cpp and on osgCamera but he use osgProducer (exacly like that I used too) is it possible do get intersections with osgSimpleViewer?? there certainly something wrong with me but I don't know what thanks for all On 2/27/07, Robert Osfield <[EMAIL PROTECTED] > wrote:
Hi Elekis, > class SimpleViewerQT : public osgViewer::Viewer, public GraphicsWindowQT osgViewer::Viewer isn't meant to be used like these, one attaches GraphicsWindow's to the Camera's that the Viewer maintains. See the osgcamera example if you want to know how. Robert. On 2/27/07, elekis <[EMAIL PROTECTED]> wrote: > thanks, I found something. > but I raised a other trouble(it's not my month, all that for a teacher :-( > ), > > with QT, I can't use osgViewer , I have to use osgSimpleViewer . if I use > osgViewer --> core dumped (see code below) . (I duno if it's normal) > > but in osgSimpleViewer I haven't computeIntersection function. > > so what I have to do make my own viewer?? or implement compute intersection > in my subclass of SimpleViewer.?? > > ______________________________________________________________________________ > (for the impatient, I ve just changing that line) > class SimpleViewerQT : public osgViewer::Viewer, public GraphicsWindowQT > ______________________________________________________________________________ > > > // C++ source file - (C) 2003 Robert Osfield, released under the OSGPL. > // (C) 2005 Mike Weiblen http://mew.cx/ released under the OSGPL. > // Simple example using GLUT to create an OpenGL window and OSG for > rendering. > // Derived from osgGLUTsimple.cpp and osgkeyboardmouse.cpp > > #include <osgViewer/Viewer> > #include <osgGA/TrackballManipulator> > #include <osgDB/ReadFile> > > #include <QtCore/QTimer> > #include <QtGui/QKeyEvent> > #include <QtGui/QApplication> > #include <QtOpenGL/QGLWidget> > > #include <iostream> > > class GraphicsWindowQT : public QGLWidget, virtual > osgViewer::GraphicsWindow > { > public: > > GraphicsWindowQT( QWidget * parent = 0, const char * name = 0, const > QGLWidget * shareWidget = 0, Qt::WFlags f = 0 ); > virtual ~GraphicsWindowQT() {} > > protected: > > virtual void resizeGL( int width, int height ); > virtual void keyPressEvent( QKeyEvent* event ); > virtual void keyReleaseEvent( QKeyEvent* event ); > virtual void mousePressEvent( QMouseEvent* event ); > virtual void mouseReleaseEvent( QMouseEvent* event ); > virtual void mouseMoveEvent( QMouseEvent* event ); > > QTimer _timer; > }; > > GraphicsWindowQT::GraphicsWindowQT( QWidget * parent, const > char * /*name*/, const QGLWidget * shareWidget, Qt::WFlags f): > QGLWidget(parent, shareWidget, f) > { > connect(&_timer, SIGNAL(timeout()), this, SLOT(updateGL())); > _timer.start(10); > } > > void GraphicsWindowQT::resizeGL( int width, int height ) > { > getEventQueue()->windowResize(0, 0, width, height ); > } > > void GraphicsWindowQT::keyPressEvent( QKeyEvent* event ) > { > getEventQueue()->keyPress( > (osgGA::GUIEventAdapter::KeySymbol) event->key() ); > } > > void GraphicsWindowQT::keyReleaseEvent( QKeyEvent* event ) > { > getEventQueue()->keyRelease( > (osgGA::GUIEventAdapter::KeySymbol) event->key() ); > } > > void GraphicsWindowQT::mousePressEvent( QMouseEvent* event > ) > { > int button = 0; > switch(event->button()) > { > case(Qt::LeftButton): button = 1; break; > case(Qt::MidButton): button = 2; break; > case(Qt::RightButton): button = 3; break; > case(Qt::NoButton): button = 0; break; > default: button = 0; break; > } > getEventQueue()->mouseButtonPress(event->x(), > event->y(), button); > } > > void GraphicsWindowQT::mouseReleaseEvent( QMouseEvent* > event ) > { > int button = 0; > switch(event->button()) > { > case(Qt::LeftButton): button = 1; break; > case(Qt::MidButton): button = 2; break; > case(Qt::RightButton): button = 3; break; > case(Qt::NoButton): button = 0; break; > default: button = 0; break; > } > getEventQueue()->mouseButtonRelease(event->x(), > event->y(), button); > } > > void GraphicsWindowQT::mouseMoveEvent( QMouseEvent* event ) > { > getEventQueue()->mouseMotion(event->x(), event->y()); > } > > > class SimpleViewerQT : public osgViewer::Viewer, public GraphicsWindowQT > { > public: > > SimpleViewerQT( QWidget * parent = 0, const char * name = 0, const > QGLWidget * shareWidget = 0, Qt::WFlags f = 0 ): > GraphicsWindowQT(parent, name, shareWidget, f) {} > > virtual void initializeGL() > { > QGLWidget::initializeGL(); > } > > virtual void paintGL() > { > frame(); > } > > }; > > > int main( int argc, char **argv ) > { > QApplication a( argc, argv ); > > if (argc<2) > { > std::cout << argv[0] <<": requires filename argument." << std::endl; > return 1; > } > > // load the scene. > osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile(argv[1]); > if (!loadedModel) > { > std::cout << argv[0] <<": No data loaded." << std::endl; > return 1; > } > > > SimpleViewerQT* viewerWindow = new SimpleViewerQT; > > viewerWindow->setSceneData(loadedModel.get()); > viewerWindow->setCameraManipulator(new > osgGA::TrackballManipulator); > > viewerWindow->show(); > a.connect ( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) ); > > return a.exec(); > } > > /*EOF*/ > > > > > > > > > > > > > > > > On 2/27/07, Robert Osfield < [EMAIL PROTECTED]> wrote: > > HI Elekis, > > > > The difference is simply in the data structure used to store the > > intersection hits. The osgViewer is based on the new > > IntersectionVisitor rather than the old IntersectVistor. For the new > > viewer you'll just need to use the LinerIntersector::Intersections > > structure. Have a look at the interface. As check the picking code > > in osgpick or osgmanipulator. > > > > Robert. > > > > On 2/27/07, elekis < [EMAIL PROTECTED]> wrote: > > > hi all, always trying to pass to OSGViewer, > > > I try to use computeIntersections (as with osg::Producer) > > > > > > in Producer I made that > > > > > > osgUtil::IntersectVisitor::HitList hlist; > > > if ( > > > CGeneral::instance().viewer.computeIntersections( > > > ea.getX(), ea.getY (), hlist)) > > > { > > > > > > for(osgUtil::IntersectVisitor::HitList::iterator > > > hitr=hlist.begin();hitr!=hlist.end(); ++hitr) > > > { > > > if > > > (hitr->_geode.valid()){ > > > > > > > > > with viewer, I tried the same thing, (execpt the ea changing with event) > > > > > > but I have that error. > > > > > > INTERFACE/Interface.cpp:44: error: no matching function for call to > > > 'SimpleViewerQT::computeIntersections(float, float, > > > std::vector<osgUtil::Hit, std::allocator<osgUtil::Hit> >&)' > > > > > > /usr/local/include/osgViewer/View:117: note: candidates > > > are: bool osgViewer::View::computeIntersections(float, > > > float, > > > > std::multiset<osgUtil::LineSegmentIntersector::Intersection, > > > > std::less<osgUtil::LineSegmentIntersector::Intersection>, > > > > std::allocator<osgUtil::LineSegmentIntersector::Intersection> > > > >&, unsigned int) > > > > > > /usr/local/include/osgViewer/View:120: note: > > > bool osgViewer::View::computeIntersections(float, > float, > > > osg::NodePath&, > > > > std::multiset<osgUtil::LineSegmentIntersector::Intersection, > > > > std::less<osgUtil::LineSegmentIntersector::Intersection>, > > > > std::allocator<osgUtil::LineSegmentIntersector::Intersection> > > > >&, unsigned int) > > > > > > > > > I ve tried google code search, and other search but all example are with > > > osgProducer. (event is the nme is not correct, I use viewer and not > > > simpleViewer.) > > > > > > thanks > > > > > > a+++ > > > > > > _______________________________________________ > > > osg-users mailing list > > > osg-users@openscenegraph.net > > > http://openscenegraph.net/mailman/listinfo/osg-users > > > http://www.openscenegraph.org/ > > > > > _______________________________________________ > > osg-users mailing list > > osg-users@openscenegraph.net > > http://openscenegraph.net/mailman/listinfo/osg-users > > http://www.openscenegraph.org/ > > > > > _______________________________________________ > osg-users mailing list > osg-users@openscenegraph.net > http://openscenegraph.net/mailman/listinfo/osg-users > http://www.openscenegraph.org/ > _______________________________________________ osg-users mailing list osg-users@openscenegraph.net http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
_______________________________________________ osg-users mailing list osg-users@openscenegraph.net http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/