diff --git a/examples/osgsimulation/osgsimulation.cpp b/examples/osgsimulation/osgsimulation.cpp index ed8effafa..59c86f023 100644 --- a/examples/osgsimulation/osgsimulation.cpp +++ b/examples/osgsimulation/osgsimulation.cpp @@ -90,12 +90,12 @@ public: ModelPositionCallback(): _latitude(0.0), _longitude(0.0), - _height(1000.0) + _height(10000.0) {} void updateParameters() { - _longitude += (2.0*osg::PI)/360.0; + _latitude -= ((2.0*osg::PI)/360.0)/100.0; } @@ -174,12 +174,6 @@ public: }; -void addModel(osgProducer::Viewer* viewer,osg::Node* model) -{ - -} - - int main(int argc, char **argv) { // use an ArgumentParser object to manage the program arguments. @@ -197,7 +191,8 @@ int main(int argc, char **argv) // set up the value with sensible default event handlers. viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); - + viewer.getCullSettings().setComputeNearFarMode(osg::CullSettings::COMPUTE_NEAR_FAR_USING_PRIMITIVES); + viewer.getCullSettings().setNearFarRatio(0.0001f); // get details on keyboard and mouse bindings used by the viewer. viewer.getUsage(*arguments.getApplicationUsage()); @@ -219,29 +214,38 @@ int main(int argc, char **argv) return 1; } - osg::Node *root = createEarth(); - - if (!root) return 0; - - // add a viewport to the viewer and attach the scene graph. - viewer.setSceneData(root); - - - FindNamedNodeVisitor fnnv("cessna"); - root->accept(fnnv); + osg::ref_ptr root = createEarth(); - if (!fnnv._foundNodes.empty()) + if (!root) return 0; + + // add a viewport to the viewer and attach the scene graph. + viewer.setSceneData(root.get()); + + osg::CoordinateSystemNode* csn = dynamic_cast(root.get()); + if (csn) { - osgGA::NodeTrackerManipulator* tm = new osgGA::NodeTrackerManipulator; - tm->setTrackNode(fnnv._foundNodes[0].get()); - - std::cout<<"Found "<addChild(cessna); + mt->setUpdateCallback(new ModelPositionCallback); + csn->addChild(mt); + osgGA::NodeTrackerManipulator* tm = new osgGA::NodeTrackerManipulator; + tm->setTrackNode(cessna); + + unsigned int num = viewer.addCameraManipulator(tm); + viewer.selectCameraManipulator(num); + } + else + { + std::cout<<"Failed to read cessna.osg"< #include #include +#include #include #include @@ -90,6 +91,13 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup const osg::DisplaySettings *getDisplaySettings() const { return _ds.get(); } + void setCullSettings( const osg::CullSettings& cs) { _cullSettings = cs; } + + osg::CullSettings& getCullSettings() { return _cullSettings; } + + const osg::CullSettings& getCullSettings() const { return _cullSettings; } + + void setFrameStamp( osg::FrameStamp* fs ); @@ -202,6 +210,8 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup osg::ref_ptr _ds; bool _initialized; + + osg::CullSettings _cullSettings; unsigned int _frameNumber; osg::Timer _timer; diff --git a/src/osgProducer/OsgCameraGroup.cpp b/src/osgProducer/OsgCameraGroup.cpp index 3bfd044df..acf0e1e26 100644 --- a/src/osgProducer/OsgCameraGroup.cpp +++ b/src/osgProducer/OsgCameraGroup.cpp @@ -611,6 +611,17 @@ void OsgCameraGroup::frame() osg::Node* node = getTopMostSceneData(); if (node) node->getBound(); - CameraGroup::frame(); + + // pass on the cull settings to the scene views to keep + // the settings in sync. + for(SceneHandlerList::iterator itr = _shvec.begin(); + itr != _shvec.end(); + ++itr) + { + (*itr)->getSceneView()->setCullSettings(_cullSettings); + } + + + CameraGroup::frame(); }