Hi Mathias,
I have just modified the osgpick example to check for MOVE events and
it works perfectly.
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::MOVE):
{
osgViewer::View* view = dynamic_castosgViewer::View*(aa);
if (view) pick(view,ea);
return false;
}
I don't know what you've done wrong, but perhaps you can look at the
attached osgpick.cpp for reference.
Robert.
On Mon, Jun 1, 2009 at 1:30 PM, Matthias Asselborn
matthias.asselb...@gmx.de wrote:
iam holding the mouse button not down.
i want a pick each time i move my mouse!
i thought its implemented with : MOVE ...
but its not working
...
Thank you!
Cheers,
Matthias
--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=13254#13254
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
/* OpenSceneGraph example, osgpick.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the Software), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/* osgpick sample
* demonstrate use of osgUtil/PickVisitor for picking in a HUD or
* in a 3d scene,
*/
#include osgUtil/Optimizer
#include osgDB/ReadFile
#include osgViewer/Viewer
#include osgViewer/CompositeViewer
#include osgGA/TerrainManipulator
#include osgGA/StateSetManipulator
#include osgGA/AnimationPathManipulator
#include osgGA/TrackballManipulator
#include osgGA/FlightManipulator
#include osgGA/DriveManipulator
#include osgGA/KeySwitchMatrixManipulator
#include osgGA/StateSetManipulator
#include osgGA/AnimationPathManipulator
#include osgGA/TerrainManipulator
#include osg/Material
#include osg/Geode
#include osg/BlendFunc
#include osg/Depth
#include osg/Projection
#include osg/MatrixTransform
#include osg/Camera
#include osg/io_utils
#include osg/ShapeDrawable
#include osgText/Text
#include sstream
// class to handle events with a pick
class PickHandler : public osgGA::GUIEventHandler {
public:
PickHandler(osgText::Text* updateText):
_updateText(updateText) {}
~PickHandler() {}
bool handle(const osgGA::GUIEventAdapter ea,osgGA::GUIActionAdapter aa);
virtual void pick(osgViewer::View* view, const osgGA::GUIEventAdapter ea);
void setLabel(const std::string name)
{
if (_updateText.get()) _updateText-setText(name);
}
protected:
osg::ref_ptrosgText::Text _updateText;
};
bool PickHandler::handle(const osgGA::GUIEventAdapter ea,osgGA::GUIActionAdapter aa)
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::MOVE):
{
osgViewer::View* view = dynamic_castosgViewer::View*(aa);
if (view) pick(view,ea);
return false;
}
case(osgGA::GUIEventAdapter::PUSH):
{
osgViewer::View* view = dynamic_castosgViewer::View*(aa);
if (view) pick(view,ea);
return false;
}
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey()=='c')
{
osgViewer::View* view = dynamic_castosgViewer::View*(aa);
osg::ref_ptrosgGA::GUIEventAdapter event = new osgGA::GUIEventAdapter(ea);
event-setX((ea.getXmin()+ea.getXmax())*0.5);
event-setY((ea.getYmin()+ea.getYmax())*0.5);
if (view) pick(view,*event);
}
return false;
}
default:
return false;
}
}
void PickHandler::pick(osgViewer::View* view, const osgGA::GUIEventAdapter ea)
{
osgUtil::LineSegmentIntersector::Intersections intersections;
std::string gdlist=;
float x = ea.getX();
float y = ea.getY();
#if 0
osg::ref_ptr osgUtil::LineSegmentIntersector picker = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, x, y);
osgUtil::IntersectionVisitor iv(picker.get());
view-getCamera()-accept(iv);
if (picker-containsIntersections())
{
intersections = picker-getIntersections();
#else
if