From Paul Melis, remove redundent spaces
This commit is contained in:
@@ -44,19 +44,19 @@
|
||||
|
||||
// class to handle events with a pick
|
||||
class PickHandler : public osgGA::GUIEventHandler {
|
||||
public:
|
||||
public:
|
||||
|
||||
PickHandler():
|
||||
_mx(0.0f),
|
||||
_my(0.0f) {}
|
||||
|
||||
|
||||
~PickHandler() {}
|
||||
|
||||
|
||||
bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa)
|
||||
{
|
||||
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
|
||||
if (!view) return false;
|
||||
|
||||
|
||||
switch(ea.getEventType())
|
||||
{
|
||||
case(osgGA::GUIEventAdapter::PUSH):
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void pick(osgViewer::View* view, float x, float y)
|
||||
{
|
||||
osg::Node* node = 0;
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
osg::NodePath& nodePath = intersection.nodePath;
|
||||
node = (nodePath.size()>=1)?nodePath[nodePath.size()-1]:0;
|
||||
parent = (nodePath.size()>=2)?dynamic_cast<osg::Group*>(nodePath[nodePath.size()-2]):0;
|
||||
}
|
||||
}
|
||||
|
||||
// now we try to decorate the hit node by the osgFX::Scribe to show that its been "picked"
|
||||
if (parent && node)
|
||||
@@ -119,7 +119,7 @@ public:
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
float _mx, _my;
|
||||
|
||||
};
|
||||
@@ -130,7 +130,7 @@ int main( int argc, char **argv )
|
||||
|
||||
// use an ArgumentParser object to manage the program arguments.
|
||||
osg::ArgumentParser arguments(&argc,argv);
|
||||
|
||||
|
||||
// read the scene from the list of file specified commandline args.
|
||||
osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);
|
||||
|
||||
@@ -138,18 +138,19 @@ int main( int argc, char **argv )
|
||||
|
||||
// construct the viewer.
|
||||
osgViewer::CompositeViewer viewer(arguments);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (arguments.read("-1"))
|
||||
{
|
||||
{
|
||||
osgViewer::View* view = new osgViewer::View;
|
||||
view->setName("Single view");
|
||||
view->setSceneData(osgDB::readNodeFile("fountain.osg"));
|
||||
|
||||
|
||||
view->addEventHandler( new osgViewer::StatsHandler );
|
||||
|
||||
|
||||
view->setUpViewAcrossAllScreens();
|
||||
view->setCameraManipulator(new osgGA::TrackballManipulator);
|
||||
viewer.addView(view);
|
||||
@@ -174,7 +175,7 @@ int main( int argc, char **argv )
|
||||
|
||||
view->addEventHandler( statesetManipulator.get() );
|
||||
}
|
||||
|
||||
|
||||
// view two
|
||||
{
|
||||
osgViewer::View* view = new osgViewer::View;
|
||||
@@ -183,21 +184,21 @@ int main( int argc, char **argv )
|
||||
view->setUpViewOnSingleScreen(1);
|
||||
view->setSceneData(scene.get());
|
||||
view->setCameraManipulator(new osgGA::TrackballManipulator);
|
||||
|
||||
|
||||
view->addEventHandler( new osgViewer::StatsHandler );
|
||||
|
||||
|
||||
|
||||
// add the handler for doing the picking
|
||||
view->addEventHandler(new PickHandler());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (arguments.read("-3") || viewer.getNumViews()==0)
|
||||
{
|
||||
{
|
||||
|
||||
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
|
||||
if (!wsi)
|
||||
if (!wsi)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Error, no WindowSystemInterface available, cannot create windows."<<std::endl;
|
||||
return 1;
|
||||
@@ -245,7 +246,7 @@ int main( int argc, char **argv )
|
||||
statesetManipulator->setStateSet(view->getCamera()->getOrCreateStateSet());
|
||||
|
||||
view->addEventHandler( statesetManipulator.get() );
|
||||
|
||||
|
||||
view->addEventHandler( new osgViewer::StatsHandler );
|
||||
view->addEventHandler( new osgViewer::HelpHandler );
|
||||
view->addEventHandler( new osgViewer::WindowSizeHandler );
|
||||
@@ -262,10 +263,10 @@ int main( int argc, char **argv )
|
||||
view->getCamera()->setViewport(new osg::Viewport(traits->width/2,0, traits->width/2, traits->height/2));
|
||||
view->getCamera()->setGraphicsContext(gc.get());
|
||||
view->setCameraManipulator(new osgGA::TrackballManipulator);
|
||||
|
||||
|
||||
// add the handler for doing the picking
|
||||
view->addEventHandler(new PickHandler());
|
||||
|
||||
|
||||
}
|
||||
|
||||
// view three
|
||||
@@ -283,11 +284,11 @@ int main( int argc, char **argv )
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
while (arguments.read("-s")) { viewer.setThreadingModel(osgViewer::CompositeViewer::SingleThreaded); }
|
||||
while (arguments.read("-g")) { viewer.setThreadingModel(osgViewer::CompositeViewer::CullDrawThreadPerContext); }
|
||||
while (arguments.read("-c")) { viewer.setThreadingModel(osgViewer::CompositeViewer::CullThreadPerCameraDrawThreadPerContext); }
|
||||
|
||||
|
||||
// run the viewer's main frame loop
|
||||
return viewer.run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user