Added Dragger::s/getActivationModKeyMask(..) and Dragger::s/getActivationKeyEvent(...) methods to make it possible to have draggers that only respond when you press a specified modified key or standard key.
Changed the optional dragger in osgvolume to require the shift key to be pressed for the dragger to become active.
This commit is contained in:
parent
cb1b874167
commit
6e6a7c960e
@ -1,12 +1,12 @@
|
|||||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||||
*
|
*
|
||||||
* This application is open source and may be redistributed and/or modified
|
* This application is open source and may be redistributed and/or modified
|
||||||
* freely and without restriction, both in commericial and non commericial applications,
|
* freely and without restriction, both in commericial and non commericial applications,
|
||||||
* as long as this copyright notice is maintained.
|
* as long as this copyright notice is maintained.
|
||||||
*
|
*
|
||||||
* This application is distributed in the hope that it will be useful,
|
* This application is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <osgDB/ReadFile>
|
#include <osgDB/ReadFile>
|
||||||
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include <osg/Switch>
|
#include <osg/Switch>
|
||||||
#include <osgText/Text>
|
#include <osgText/Text>
|
||||||
|
#include <osg/Group>
|
||||||
|
|
||||||
#include <osgViewer/Viewer>
|
#include <osgViewer/Viewer>
|
||||||
#include <osgViewer/ViewerEventHandlers>
|
#include <osgViewer/ViewerEventHandlers>
|
||||||
@ -26,135 +27,167 @@
|
|||||||
#include <osgGA/StateSetManipulator>
|
#include <osgGA/StateSetManipulator>
|
||||||
#include <osgGA/AnimationPathManipulator>
|
#include <osgGA/AnimationPathManipulator>
|
||||||
#include <osgGA/TerrainManipulator>
|
#include <osgGA/TerrainManipulator>
|
||||||
#include <osgGA/SphericalManipulator>
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#ifdef _WINDOWS
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <GL/glext.h>
|
||||||
|
#include <GL/wglext.h>
|
||||||
|
#include "vsynctoggle_custom.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
// use an ArgumentParser object to manage the program arguments.
|
// use an ArgumentParser object to manage the program arguments.
|
||||||
osg::ArgumentParser arguments(&argc,argv);
|
osg::ArgumentParser arguments(&argc,argv);
|
||||||
|
|
||||||
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
|
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
|
||||||
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the standard OpenSceneGraph example which loads and visualises 3d models.");
|
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the standard OpenSceneGraph example which loads and visualises 3d models.");
|
||||||
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
|
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
|
||||||
arguments.getApplicationUsage()->addCommandLineOption("--image <filename>","Load an image and render it on a quad");
|
arguments.getApplicationUsage()->addCommandLineOption("--image <filename>","Load an image and render it on a quad");
|
||||||
arguments.getApplicationUsage()->addCommandLineOption("--dem <filename>","Load an image/DEM and render it on a HeightField");
|
arguments.getApplicationUsage()->addCommandLineOption("--dem <filename>","Load an image/DEM and render it on a HeightField");
|
||||||
arguments.getApplicationUsage()->addCommandLineOption("--login <url> <username> <password>","Provide authentication information for http file access.");
|
arguments.getApplicationUsage()->addCommandLineOption("--login <url> <username> <password>","Provide authentication information for http file access.");
|
||||||
|
|
||||||
osgViewer::Viewer viewer(arguments);
|
osgViewer::Viewer viewer(arguments);
|
||||||
|
|
||||||
unsigned int helpType = 0;
|
unsigned int helpType = 0;
|
||||||
if ((helpType = arguments.readHelpType()))
|
if ((helpType = arguments.readHelpType()))
|
||||||
|
{
|
||||||
|
arguments.getApplicationUsage()->write(std::cout, helpType);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// report any errors if they have occurred when parsing the program arguments.
|
||||||
|
if (arguments.errors())
|
||||||
|
{
|
||||||
|
arguments.writeErrorMessages(std::cout);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arguments.argc()<=1)
|
||||||
|
{
|
||||||
|
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string url, username, password;
|
||||||
|
while(arguments.read("--login",url, username, password))
|
||||||
|
{
|
||||||
|
if (!osgDB::Registry::instance()->getAuthenticationMap())
|
||||||
{
|
{
|
||||||
arguments.getApplicationUsage()->write(std::cout, helpType);
|
osgDB::Registry::instance()->setAuthenticationMap(new osgDB::AuthenticationMap);
|
||||||
return 1;
|
osgDB::Registry::instance()->getAuthenticationMap()->addAuthenticationDetails(
|
||||||
|
url,
|
||||||
|
new osgDB::AuthenticationDetails(username, password)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set up the camera manipulators.
|
||||||
|
{
|
||||||
|
osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
|
||||||
|
|
||||||
|
keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() );
|
||||||
|
keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() );
|
||||||
|
keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() );
|
||||||
|
keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() );
|
||||||
|
|
||||||
|
std::string pathfile;
|
||||||
|
char keyForAnimationPath = '5';
|
||||||
|
while (arguments.read("-p",pathfile))
|
||||||
|
{
|
||||||
|
osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile);
|
||||||
|
if (apm || !apm->valid())
|
||||||
|
{
|
||||||
|
unsigned int num = keyswitchManipulator->getNumMatrixManipulators();
|
||||||
|
keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm );
|
||||||
|
keyswitchManipulator->selectMatrixManipulator(num);
|
||||||
|
++keyForAnimationPath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// report any errors if they have occurred when parsing the program arguments.
|
viewer.setCameraManipulator( keyswitchManipulator.get() );
|
||||||
if (arguments.errors())
|
}
|
||||||
{
|
|
||||||
arguments.writeErrorMessages(std::cout);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arguments.argc()<=1)
|
// add the state manipulator
|
||||||
{
|
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
|
||||||
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string url, username, password;
|
// add the thread model handler
|
||||||
while(arguments.read("--login",url, username, password))
|
viewer.addEventHandler(new osgViewer::ThreadingHandler);
|
||||||
{
|
|
||||||
if (!osgDB::Registry::instance()->getAuthenticationMap())
|
|
||||||
{
|
|
||||||
osgDB::Registry::instance()->setAuthenticationMap(new osgDB::AuthenticationMap);
|
|
||||||
osgDB::Registry::instance()->getAuthenticationMap()->addAuthenticationDetails(
|
|
||||||
url,
|
|
||||||
new osgDB::AuthenticationDetails(username, password)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// set up the camera manipulators.
|
// add the window size toggle handler
|
||||||
{
|
viewer.addEventHandler(new osgViewer::WindowSizeHandler);
|
||||||
osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
|
|
||||||
|
|
||||||
keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() );
|
// add the stats handler
|
||||||
keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() );
|
viewer.addEventHandler(new osgViewer::StatsHandler);
|
||||||
keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() );
|
|
||||||
keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() );
|
|
||||||
keyswitchManipulator->addMatrixManipulator( '5', "Spherical", new osgGA::SphericalManipulator() );
|
|
||||||
|
|
||||||
std::string pathfile;
|
// add the help handler
|
||||||
char keyForAnimationPath = '6';
|
viewer.addEventHandler(new osgViewer::HelpHandler(arguments.getApplicationUsage()));
|
||||||
while (arguments.read("-p",pathfile))
|
|
||||||
{
|
|
||||||
osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile);
|
|
||||||
if (apm || !apm->valid())
|
|
||||||
{
|
|
||||||
unsigned int num = keyswitchManipulator->getNumMatrixManipulators();
|
|
||||||
keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm );
|
|
||||||
keyswitchManipulator->selectMatrixManipulator(num);
|
|
||||||
++keyForAnimationPath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
viewer.setCameraManipulator( keyswitchManipulator.get() );
|
// add the record camera path handler
|
||||||
}
|
viewer.addEventHandler(new osgViewer::RecordCameraPathHandler);
|
||||||
|
|
||||||
// add the state manipulator
|
// add the LOD Scale handler
|
||||||
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
|
viewer.addEventHandler(new osgViewer::LODScaleHandler);
|
||||||
|
|
||||||
// add the thread model handler
|
// add the screen capture handler
|
||||||
viewer.addEventHandler(new osgViewer::ThreadingHandler);
|
viewer.addEventHandler(new osgViewer::ScreenCaptureHandler);
|
||||||
|
|
||||||
// add the window size toggle handler
|
// load the data
|
||||||
viewer.addEventHandler(new osgViewer::WindowSizeHandler);
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
||||||
|
if (!loadedModel)
|
||||||
|
{
|
||||||
|
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// add the stats handler
|
// any option left unread are converted into errors to write out later.
|
||||||
viewer.addEventHandler(new osgViewer::StatsHandler);
|
arguments.reportRemainingOptionsAsUnrecognized();
|
||||||
|
|
||||||
// add the help handler
|
// report any errors if they have occurred when parsing the program arguments.
|
||||||
viewer.addEventHandler(new osgViewer::HelpHandler(arguments.getApplicationUsage()));
|
if (arguments.errors())
|
||||||
|
{
|
||||||
// add the record camera path handler
|
arguments.writeErrorMessages(std::cout);
|
||||||
viewer.addEventHandler(new osgViewer::RecordCameraPathHandler);
|
return 1;
|
||||||
|
}
|
||||||
// add the LOD Scale handler
|
|
||||||
viewer.addEventHandler(new osgViewer::LODScaleHandler);
|
|
||||||
|
|
||||||
// add the screen capture handler
|
|
||||||
viewer.addEventHandler(new osgViewer::ScreenCaptureHandler);
|
|
||||||
|
|
||||||
// load the data
|
|
||||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
|
||||||
if (!loadedModel)
|
|
||||||
{
|
|
||||||
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// any option left unread are converted into errors to write out later.
|
|
||||||
arguments.reportRemainingOptionsAsUnrecognized();
|
|
||||||
|
|
||||||
// report any errors if they have occurred when parsing the program arguments.
|
|
||||||
if (arguments.errors())
|
|
||||||
{
|
|
||||||
arguments.writeErrorMessages(std::cout);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// optimize the scene graph, remove redundant nodes and state etc.
|
// optimize the scene graph, remove redundant nodes and state etc.
|
||||||
osgUtil::Optimizer optimizer;
|
osgUtil::Optimizer optimizer;
|
||||||
optimizer.optimize(loadedModel.get());
|
optimizer.optimize(loadedModel.get());
|
||||||
|
|
||||||
viewer.setSceneData( loadedModel.get() );
|
osg::ref_ptr<osg::Group> group = new osg::Group();
|
||||||
|
group->addChild(loadedModel.get());
|
||||||
|
|
||||||
viewer.realize();
|
viewer.setSceneData( group.get() );
|
||||||
|
|
||||||
return viewer.run();
|
{
|
||||||
|
char tmp[256];
|
||||||
|
tmp[sizeof(tmp) - 1] = 0;
|
||||||
|
getcwd(tmp, sizeof(tmp) - 1);
|
||||||
|
|
||||||
|
std::string path(tmp);
|
||||||
|
path += "\\system\\cache\\planet";
|
||||||
|
|
||||||
|
tmp[sizeof(tmp) - 1] = 0;
|
||||||
|
snprintf(tmp, sizeof(tmp) - 1, "%s", path.c_str());
|
||||||
|
//_putenv(tmp);
|
||||||
|
// osgDB::Registry::instance()->setFileCache(new osgDB::FileCache( tmp ) );
|
||||||
|
viewer.getDatabasePager()->setTargetMaximumNumberOfPageLOD(500);
|
||||||
|
|
||||||
|
#ifdef _WINDOWS
|
||||||
|
osg::ref_ptr<baronvsync::CVsyncDrawable> vsync = new baronvsync::CVsyncDrawable();
|
||||||
|
osg::ref_ptr<osg::Geode> vsyncGeode = new osg::Geode();
|
||||||
|
vsyncGeode->addDrawable(vsync.get());
|
||||||
|
vsync->SetVSync(false);
|
||||||
|
group->addChild(vsyncGeode.get());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
viewer.realize();
|
||||||
|
|
||||||
|
return viewer.run();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,6 @@ osg::Node* addDraggerToScene(osg::Node* scene, const std::string& name)
|
|||||||
|
|
||||||
osgManipulator::Dragger* dragger = createDragger(name);
|
osgManipulator::Dragger* dragger = createDragger(name);
|
||||||
|
|
||||||
dragger->setHandleEvents(true);
|
|
||||||
|
|
||||||
osg::Group* root = new osg::Group;
|
osg::Group* root = new osg::Group;
|
||||||
root->addChild(dragger);
|
root->addChild(dragger);
|
||||||
@ -110,6 +109,17 @@ osg::Node* addDraggerToScene(osg::Node* scene, const std::string& name)
|
|||||||
|
|
||||||
dragger->addTransformUpdating(selection);
|
dragger->addTransformUpdating(selection);
|
||||||
|
|
||||||
|
// we want the dragger to handle it's own events automatically
|
||||||
|
dragger->setHandleEvents(true);
|
||||||
|
|
||||||
|
// if we don't set an activation key or mod mask then any mouse click on
|
||||||
|
// the dragger will activate it, however if do define either of ActivationModKeyMask or
|
||||||
|
// and ActivationKeyEvent then you'll have to press either than mod key or the specified key to
|
||||||
|
// be able to activate the dragger when you mouse click on it. Please note the follow allows
|
||||||
|
// activation if either the ctrl key or the 'a' key is pressed and held down.
|
||||||
|
dragger->setActivationModKeyMask(osgGA::GUIEventAdapter::MODKEY_CTRL);
|
||||||
|
dragger->setActivationKeyEvent('a');
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1477,6 +1477,7 @@ int main( int argc, char **argv )
|
|||||||
#endif
|
#endif
|
||||||
dragger->setupDefaultGeometry();
|
dragger->setupDefaultGeometry();
|
||||||
dragger->setHandleEvents(true);
|
dragger->setHandleEvents(true);
|
||||||
|
dragger->setActivationModKeyMask(osgGA::GUIEventAdapter::MODKEY_SHIFT);
|
||||||
dragger->addDraggerCallback(new DraggerVolumeTileCallback(tile.get(), tile->getLocator()));
|
dragger->addDraggerCallback(new DraggerVolumeTileCallback(tile.get(), tile->getLocator()));
|
||||||
dragger->setMatrix(osg::Matrix::translate(0.5,0.5,0.5)*tile->getLocator()->getTransform());
|
dragger->setMatrix(osg::Matrix::translate(0.5,0.5,0.5)*tile->getLocator()->getTransform());
|
||||||
|
|
||||||
|
@ -217,8 +217,11 @@ class OSGMANIPULATOR_EXPORT Dragger : public osg::MatrixTransform
|
|||||||
void setHandleEvents(bool flag);
|
void setHandleEvents(bool flag);
|
||||||
bool getHandleEvents() const { return _handleEvents; }
|
bool getHandleEvents() const { return _handleEvents; }
|
||||||
|
|
||||||
void setDraggerActive(bool active) { _draggerActive = active; }
|
void setActivationModKeyMask(unsigned int mask) { _activationModKeyMask = mask; }
|
||||||
bool getDraggerActive() const { return _draggerActive; }
|
unsigned int getActivationModKeyMask() const { return _activationModKeyMask; }
|
||||||
|
|
||||||
|
void setActivationKeyEvent(int key) { _activationKeyEvent = key; }
|
||||||
|
int getActivationKeyEvent() const { return _activationKeyEvent; }
|
||||||
|
|
||||||
|
|
||||||
virtual void traverse(osg::NodeVisitor& nv);
|
virtual void traverse(osg::NodeVisitor& nv);
|
||||||
@ -260,8 +263,17 @@ class OSGMANIPULATOR_EXPORT Dragger : public osg::MatrixTransform
|
|||||||
virtual bool receive(const MotionCommand& command);
|
virtual bool receive(const MotionCommand& command);
|
||||||
void dispatch(MotionCommand& command);
|
void dispatch(MotionCommand& command);
|
||||||
|
|
||||||
|
void setDraggerActive(bool active) { _draggerActive = active; }
|
||||||
|
bool getDraggerActive() const { return _draggerActive; }
|
||||||
|
|
||||||
bool _handleEvents;
|
bool _handleEvents;
|
||||||
bool _draggerActive;
|
bool _draggerActive;
|
||||||
|
|
||||||
|
unsigned int _activationModKeyMask;
|
||||||
|
int _activationKeyEvent;
|
||||||
|
bool _activationPermittedByModKeyMask;
|
||||||
|
bool _activationPermittedByKeyEvent;
|
||||||
|
|
||||||
osgManipulator::PointerInfo _pointer;
|
osgManipulator::PointerInfo _pointer;
|
||||||
|
|
||||||
Dragger* _parentDragger;
|
Dragger* _parentDragger;
|
||||||
|
@ -125,7 +125,11 @@ bool PointerInfo::projectWindowXYIntoObject(const osg::Vec2d& windowCoord, osg::
|
|||||||
//
|
//
|
||||||
Dragger::Dragger() :
|
Dragger::Dragger() :
|
||||||
_handleEvents(false),
|
_handleEvents(false),
|
||||||
_draggerActive(false)
|
_draggerActive(false),
|
||||||
|
_activationModKeyMask(0),
|
||||||
|
_activationKeyEvent(0),
|
||||||
|
_activationPermittedByModKeyMask(false),
|
||||||
|
_activationPermittedByKeyEvent(false)
|
||||||
{
|
{
|
||||||
_parentDragger = this;
|
_parentDragger = this;
|
||||||
getOrCreateStateSet()->setDataVariance(osg::Object::DYNAMIC);
|
getOrCreateStateSet()->setDataVariance(osg::Object::DYNAMIC);
|
||||||
@ -135,7 +139,13 @@ Dragger::Dragger() :
|
|||||||
}
|
}
|
||||||
|
|
||||||
Dragger::Dragger(const Dragger& rhs, const osg::CopyOp& copyop):
|
Dragger::Dragger(const Dragger& rhs, const osg::CopyOp& copyop):
|
||||||
osg::MatrixTransform(rhs, copyop)
|
osg::MatrixTransform(rhs, copyop),
|
||||||
|
_handleEvents(rhs._handleEvents),
|
||||||
|
_draggerActive(false),
|
||||||
|
_activationModKeyMask(rhs._activationModKeyMask),
|
||||||
|
_activationKeyEvent(rhs._activationKeyEvent),
|
||||||
|
_activationPermittedByModKeyMask(false),
|
||||||
|
_activationPermittedByKeyEvent(false)
|
||||||
{
|
{
|
||||||
osg::notify(osg::NOTICE)<<"CompositeDragger::CompositeDragger(const CompositeDragger& rhs, const osg::CopyOp& copyop) not Implemented yet."<<std::endl;
|
osg::notify(osg::NOTICE)<<"CompositeDragger::CompositeDragger(const CompositeDragger& rhs, const osg::CopyOp& copyop) not Implemented yet."<<std::endl;
|
||||||
}
|
}
|
||||||
@ -250,65 +260,98 @@ bool Dragger::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&
|
|||||||
|
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
|
|
||||||
switch (ea.getEventType())
|
bool activationPermitted = true;
|
||||||
|
if (_activationModKeyMask!=0 || _activationKeyEvent!=0)
|
||||||
{
|
{
|
||||||
case osgGA::GUIEventAdapter::PUSH:
|
_activationPermittedByModKeyMask = (_activationModKeyMask!=0) ?
|
||||||
|
((ea.getModKeyMask() & _activationModKeyMask)!=0) :
|
||||||
|
false;
|
||||||
|
|
||||||
|
if (_activationKeyEvent!=0)
|
||||||
{
|
{
|
||||||
osgUtil::LineSegmentIntersector::Intersections intersections;
|
switch (ea.getEventType())
|
||||||
|
|
||||||
_pointer.reset();
|
|
||||||
|
|
||||||
if (view->computeIntersections(ea.getX(),ea.getY(),intersections))
|
|
||||||
{
|
{
|
||||||
_pointer.setCamera(view->getCamera());
|
case osgGA::GUIEventAdapter::KEYDOWN:
|
||||||
_pointer.setMousePosition(ea.getX(), ea.getY());
|
|
||||||
|
|
||||||
for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin();
|
|
||||||
hitr != intersections.end();
|
|
||||||
++hitr)
|
|
||||||
{
|
{
|
||||||
_pointer.addIntersection(hitr->nodePath, hitr->getLocalIntersectPoint());
|
if (ea.getKey()==_activationKeyEvent) _activationPermittedByKeyEvent = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
for (osg::NodePath::iterator itr = _pointer._hitList.front().first.begin();
|
case osgGA::GUIEventAdapter::KEYUP:
|
||||||
itr != _pointer._hitList.front().first.end();
|
|
||||||
++itr)
|
|
||||||
{
|
{
|
||||||
osgManipulator::Dragger* dragger = dynamic_cast<osgManipulator::Dragger*>(*itr);
|
if (ea.getKey()==_activationKeyEvent) _activationPermittedByKeyEvent = false;
|
||||||
if (dragger)
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
activationPermitted = _activationPermittedByModKeyMask || _activationPermittedByKeyEvent;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (activationPermitted || _draggerActive)
|
||||||
|
{
|
||||||
|
switch (ea.getEventType())
|
||||||
|
{
|
||||||
|
case osgGA::GUIEventAdapter::PUSH:
|
||||||
|
{
|
||||||
|
osgUtil::LineSegmentIntersector::Intersections intersections;
|
||||||
|
|
||||||
|
_pointer.reset();
|
||||||
|
|
||||||
|
if (view->computeIntersections(ea.getX(),ea.getY(),intersections))
|
||||||
|
{
|
||||||
|
_pointer.setCamera(view->getCamera());
|
||||||
|
_pointer.setMousePosition(ea.getX(), ea.getY());
|
||||||
|
|
||||||
|
for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin();
|
||||||
|
hitr != intersections.end();
|
||||||
|
++hitr)
|
||||||
{
|
{
|
||||||
if (dragger==this)
|
_pointer.addIntersection(hitr->nodePath, hitr->getLocalIntersectPoint());
|
||||||
|
}
|
||||||
|
for (osg::NodePath::iterator itr = _pointer._hitList.front().first.begin();
|
||||||
|
itr != _pointer._hitList.front().first.end();
|
||||||
|
++itr)
|
||||||
|
{
|
||||||
|
osgManipulator::Dragger* dragger = dynamic_cast<osgManipulator::Dragger*>(*itr);
|
||||||
|
if (dragger)
|
||||||
{
|
{
|
||||||
dragger->handle(_pointer, ea, aa);
|
if (dragger==this)
|
||||||
dragger->setDraggerActive(true);
|
{
|
||||||
handled = true;
|
dragger->handle(_pointer, ea, aa);
|
||||||
|
dragger->setDraggerActive(true);
|
||||||
|
handled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
case osgGA::GUIEventAdapter::DRAG:
|
||||||
case osgGA::GUIEventAdapter::DRAG:
|
case osgGA::GUIEventAdapter::RELEASE:
|
||||||
case osgGA::GUIEventAdapter::RELEASE:
|
|
||||||
{
|
|
||||||
if (_draggerActive)
|
|
||||||
{
|
{
|
||||||
_pointer._hitIter = _pointer._hitList.begin();
|
if (_draggerActive)
|
||||||
_pointer.setCamera(view->getCamera());
|
{
|
||||||
_pointer.setMousePosition(ea.getX(), ea.getY());
|
_pointer._hitIter = _pointer._hitList.begin();
|
||||||
|
_pointer.setCamera(view->getCamera());
|
||||||
|
_pointer.setMousePosition(ea.getX(), ea.getY());
|
||||||
|
|
||||||
handle(_pointer, ea, aa);
|
handle(_pointer, ea, aa);
|
||||||
|
|
||||||
handled = true;
|
handled = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_draggerActive && ea.getEventType() == osgGA::GUIEventAdapter::RELEASE)
|
if (_draggerActive && ea.getEventType() == osgGA::GUIEventAdapter::RELEASE)
|
||||||
{
|
{
|
||||||
setDraggerActive(false);
|
setDraggerActive(false);
|
||||||
_pointer.reset();
|
_pointer.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return handled;
|
return handled;
|
||||||
|
@ -45,7 +45,6 @@ SET(TARGET_H
|
|||||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
# Remove -pedantic flag as it barfs on ffmoeg headers
|
# Remove -pedantic flag as it barfs on ffmoeg headers
|
||||||
STRING(REGEX REPLACE "-pedantic" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
STRING(REGEX REPLACE "-pedantic" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
|
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
|
||||||
|
@ -459,7 +459,7 @@ void RayTracedTechnique::init()
|
|||||||
|
|
||||||
osg::ref_ptr<TexGenLocatorCallback> locatorCallback = new TexGenLocatorCallback(texgen, masterLocator, layerLocator);
|
osg::ref_ptr<TexGenLocatorCallback> locatorCallback = new TexGenLocatorCallback(texgen, masterLocator, layerLocator);
|
||||||
masterLocator->addCallback(locatorCallback.get());
|
masterLocator->addCallback(locatorCallback.get());
|
||||||
layerLocator->addCallback(locatorCallback.get());
|
if (masterLocator != layerLocator) layerLocator->addCallback(locatorCallback.get());
|
||||||
|
|
||||||
stateset->setTextureAttributeAndModes(0, texgen, osg::StateAttribute::ON);
|
stateset->setTextureAttributeAndModes(0, texgen, osg::StateAttribute::ON);
|
||||||
|
|
||||||
|
@ -215,14 +215,24 @@ BEGIN_OBJECT_REFLECTOR(osgManipulator::Dragger)
|
|||||||
__bool__getHandleEvents,
|
__bool__getHandleEvents,
|
||||||
"",
|
"",
|
||||||
"");
|
"");
|
||||||
I_Method1(void, setDraggerActive, IN, bool, active,
|
I_Method1(void, setActivationModKeyMask, IN, unsigned int, mask,
|
||||||
Properties::NON_VIRTUAL,
|
Properties::NON_VIRTUAL,
|
||||||
__void__setDraggerActive__bool,
|
__void__setActivationModKeyMask__unsigned_int,
|
||||||
"",
|
"",
|
||||||
"");
|
"");
|
||||||
I_Method0(bool, getDraggerActive,
|
I_Method0(unsigned int, getActivationModKeyMask,
|
||||||
Properties::NON_VIRTUAL,
|
Properties::NON_VIRTUAL,
|
||||||
__bool__getDraggerActive,
|
__unsigned_int__getActivationModKeyMask,
|
||||||
|
"",
|
||||||
|
"");
|
||||||
|
I_Method1(void, setActivationKeyEvent, IN, int, key,
|
||||||
|
Properties::NON_VIRTUAL,
|
||||||
|
__void__setActivationKeyEvent__int,
|
||||||
|
"",
|
||||||
|
"");
|
||||||
|
I_Method0(int, getActivationKeyEvent,
|
||||||
|
Properties::NON_VIRTUAL,
|
||||||
|
__int__getActivationKeyEvent,
|
||||||
"",
|
"",
|
||||||
"");
|
"");
|
||||||
I_Method1(void, traverse, IN, osg::NodeVisitor &, x,
|
I_Method1(void, traverse, IN, osg::NodeVisitor &, x,
|
||||||
@ -314,15 +324,30 @@ BEGIN_OBJECT_REFLECTOR(osgManipulator::Dragger)
|
|||||||
__void__dispatch__MotionCommand_R1,
|
__void__dispatch__MotionCommand_R1,
|
||||||
"",
|
"",
|
||||||
"");
|
"");
|
||||||
|
I_ProtectedMethod1(void, setDraggerActive, IN, bool, active,
|
||||||
|
Properties::NON_VIRTUAL,
|
||||||
|
Properties::NON_CONST,
|
||||||
|
__void__setDraggerActive__bool,
|
||||||
|
"",
|
||||||
|
"");
|
||||||
|
I_ProtectedMethod0(bool, getDraggerActive,
|
||||||
|
Properties::NON_VIRTUAL,
|
||||||
|
Properties::CONST,
|
||||||
|
__bool__getDraggerActive,
|
||||||
|
"",
|
||||||
|
"");
|
||||||
|
I_SimpleProperty(int, ActivationKeyEvent,
|
||||||
|
__int__getActivationKeyEvent,
|
||||||
|
__void__setActivationKeyEvent__int);
|
||||||
|
I_SimpleProperty(unsigned int, ActivationModKeyMask,
|
||||||
|
__unsigned_int__getActivationModKeyMask,
|
||||||
|
__void__setActivationModKeyMask__unsigned_int);
|
||||||
I_SimpleProperty(osgManipulator::CompositeDragger *, Composite,
|
I_SimpleProperty(osgManipulator::CompositeDragger *, Composite,
|
||||||
__CompositeDragger_P1__getComposite,
|
__CompositeDragger_P1__getComposite,
|
||||||
0);
|
0);
|
||||||
I_SimpleProperty(osgManipulator::Dragger::Constraints &, Constraints,
|
I_SimpleProperty(osgManipulator::Dragger::Constraints &, Constraints,
|
||||||
__Constraints_R1__getConstraints,
|
__Constraints_R1__getConstraints,
|
||||||
0);
|
0);
|
||||||
I_SimpleProperty(bool, DraggerActive,
|
|
||||||
__bool__getDraggerActive,
|
|
||||||
__void__setDraggerActive__bool);
|
|
||||||
I_SimpleProperty(osgManipulator::Dragger::DraggerCallbacks &, DraggerCallbacks,
|
I_SimpleProperty(osgManipulator::Dragger::DraggerCallbacks &, DraggerCallbacks,
|
||||||
__DraggerCallbacks_R1__getDraggerCallbacks,
|
__DraggerCallbacks_R1__getDraggerCallbacks,
|
||||||
0);
|
0);
|
||||||
|
Loading…
Reference in New Issue
Block a user