[osg-users] problem with dragging in Osg

heishuijing_2000 heishuijing_2000 at 126.com
Thu Jul 3 19:42:55 PDT 2008

  Recently,i have a problem about dragging in Osg. I want to drag one surface of a box and make the box modified. During i am dragging,i modify the box constantly.Here what i do.

  1. I define a class as this:          class ModifyClass : public osgGA::GUIEventHandler
  2. In this function , virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa)
     i write a function 'DoDrag' to process the osgGA::GUIEventAdapter::DRAG message
  3. In the 'DoDrag' function,i compute the surface's points from mouse's drag,and then modify the surface and other 3 surfaces which is affected by the Dragging. Here is what i do:
     // m_selectedFace is the selected geometry face
     // p1 p2 p3 p4 are the points of the surface
     osg::Vec3Array* surfaces = dynamic_cast< osg::Vec3Array* >( m_selectedFace->getVertexArray() );
     this->setVertexArray( surfaces  );
     this->setPrimitiveSet( 0, new osg::DrawArrays( osg::PrimitiveSet::POLYGON, 0, surface_ver->size() ) );
  At first ,this does perfect,with my dragging ,the box is changed constantly.Unfortunately, after a short time,it is crashed with exception error,and then the programe is stopped.
  I was working with VS2003 and osg2.4 . I really want to know what is the error,and what should i do? 
  Anyone help me? Thank you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080704/0ff4e3da/attachment-0002.htm>

More information about the osg-users mailing list