Changeset 273 for osgVisual/trunk


Ignore:
Timestamp:
Mar 19, 2011, 5:39:16 PM (13 years ago)
Author:
Torben Dannhauer
Message:
 
Location:
osgVisual/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/trunk/bin/osgVisualConfig.xml

    r249 r273  
    1515 
    1616  <scenery>
    17     <terrain filename="D:/OpenSceneGraph/VPB-Testdatensatz/DB_Small/database.ive" filename2="J:\BRD1m_MUC0.25m_srtmEU_BM\terrain.ive"></terrain>
    18     <animationpath filename="salzburg.path"></animationpath>
     17    <terrain filename="D:/OpenSceneGraph/VPB-Testdatensatz/DB_Small/database.ive" filename2="J:\BRD1m_MUC0.25m_srtmEU_BM\terrain.ive.terrainmod"></terrain>
     18    <animationpath filename="airport_muc.path"></animationpath>
    1919    <models>
    2020      <model objectname="TestObject" trackingid="1" label="TestText!" dynamic="no">
  • osgVisual/trunk/include/util/visual_util.h

    r226 r273  
    296296        static bool strToBool(std::string s);
    297297
     298        template<class T>
     299        class FindTopMostNodeOfTypeVisitor : public osg::NodeVisitor
     300        {
     301        public:
     302                FindTopMostNodeOfTypeVisitor():
     303                        osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
     304                        _foundNode(0)
     305                {}
     306
     307                void apply(osg::Node& node)
     308                {
     309                        T* result = dynamic_cast<T*>(&node);
     310                        if (result)
     311                        {
     312                                _foundNode = result;
     313                        }
     314                        else
     315                        {
     316                                traverse(node);
     317                        }
     318                }
     319
     320                T* _foundNode;
     321        };
     322
     323        template<class T>
     324        static T* findTopMostNodeOfType(osg::Node* node)
     325        {
     326                if (!node) return 0;
     327
     328                FindTopMostNodeOfTypeVisitor<T> fnotv;
     329                node->accept(fnotv);
     330
     331                return fnotv._foundNode;
     332        }
     333
    298334private:
    299335        /**
  • osgVisual/trunk/src/core/visual_core.cpp

    r248 r273  
    1717
    1818#include <visual_core.h>
     19#include <visual_util.h>
     20#include <osgTerrain/Terrain>
    1921
    2022using namespace osgVisual;
     
    172174        if( model.valid() )
    173175        {
    174         rootNode->addChild( model.get() );
     176        osgTerrain::Terrain* terrain = util::findTopMostNodeOfType<osgTerrain::Terrain>(model.get());
     177                if (!terrain)
     178                {
     179                        terrain = new osgTerrain::Terrain;
     180                        terrain->addChild(model.get());
     181
     182                        model = terrain;                       
     183                }
     184                rootNode->addChild( terrain );
    175185                return true;
    176186        }
     
    353363        }
    354364
     365        osgTerrain::Terrain* terrain = util::findTopMostNodeOfType<osgTerrain::Terrain>(rootNode);
     366    if (!terrain)
     367    {
     368        OSG_ALWAYS << "No TerrainNode found!" << std::endl;
     369    }
     370        else
     371        {
     372                OSG_ALWAYS << "BorderEqual activated" << std::endl;
     373                terrain->setEqualizeBoundaries(true);
     374        }
    355375
    356376        //testObj = new visual_object( rootNode, "testStab", objectMountedCameraManip );
Note: See TracChangeset for help on using the changeset viewer.