Hi,
Some examples from the Cookbook (book by Rui Wang & Xuelei Qian) use this
code snippet, given at page 39.
class PickHandler : public osgGA::GUIEventHandler
{
public:
// This virtual method must be overrode by subclasses.
virtual void doUserOperations(
osgUtil::LineSegmentIntersector::Intersection& ) = 0;
virtual bool handle( const osgGA::GUIEventAdapter& ea,
osgGA::GUIActionAdapter& aa )
{
if ( ea.getEventType()!=osgGA::GUIEventAdapter::RELEASE
||ea.getButton()!=osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON
||!(ea.getModKeyMask()&osgGA::GUIEventAdapter::MODKEY_CTRL) )
return false;
osgViewer::View* viewer = dynamic_cast<osgViewer::View*>(&aa);
if ( viewer )
{
osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector =
new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW,
ea.getX(), ea.getY());
osgUtil::IntersectionVisitor iv( intersector.get() );
viewer->getCamera()->accept( iv );
if ( intersector->containsIntersections() )
{
osgUtil::LineSegmentIntersector::Intersection& result =
*(intersector->getIntersections().begin());
doUserOperations( result );
}
}
return false;
}
};
I couldn't compile examples 1 and 2 from chapter 2, and example 1 from
chapter 5.
I'm using Debian 10 and the latest version of OSG. My command to compile
the last one is:
$ g++ cook5.1.cpp -losg -losgAnimation -losgGA -losgUtil -losgViewer -o
cook5.1
I get the following error message:
cook5.1.cpp: In member function ‘virtual bool
osgCookBook::PickHandler::handle(const osgGA::GUIEventAdapter&,
osgGA::GUIActionAdapter&)’:
cook5.1.cpp:72:62: error: binding reference of type
‘osgUtil::LineSegmentIntersector::Intersection&’ to ‘const
osgUtil::LineSegmentIntersector::Intersection’ discards qualifiers
osgUtil::LineSegmentIntersector::Intersection& result =
*(intersector->getIntersections().begin());
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The message is the same in the previous examples. Anyone knows what's going
on?
Thanks,
Rodrigo.
--
You received this message because you are subscribed to the Google Groups
"OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/osg-users/f0e93c54-f8aa-4651-bc11-1d22bc626343%40googlegroups.com.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org