示例#1
0
文件: System.cpp 项目: nixz/covise
bool System::getDateOfLastModification(osgTerrain::TerrainTile *source, Date &date)
{
    typedef std::list<osgTerrain::Layer *> Layers;
    Layers layers;

    if (source->getElevationLayer())
    {
        layers.push_back(source->getElevationLayer());
    }

    for (unsigned int i = 0; i < source->getNumColorLayers(); ++i)
    {
        osgTerrain::Layer *layer = source->getColorLayer(i);
        if (layer)
        {
            layers.push_back(layer);
        }
    }

    typedef std::list<std::string> Filenames;
    Filenames filenames;

    for (Layers::iterator itr = layers.begin();
         itr != layers.end();
         ++itr)
    {
        osgTerrain::CompositeLayer *compositeLayer = dynamic_cast<osgTerrain::CompositeLayer *>(*itr);
        if (compositeLayer)
        {
            for (unsigned int i = 0; i < compositeLayer->getNumLayers(); ++i)
            {
                filenames.push_back(compositeLayer->getFileName(i));
            }
        }
        else
        {
            filenames.push_back((*itr)->getFileName());
        }
    }

    bool modified = false;
    for (Filenames::iterator itr = filenames.begin();
         itr != filenames.end();
         ++itr)
    {
        Date lastModification;
        if (lastModification.setWithDateOfLastModification(*itr))
        {
            if (lastModification > date)
            {
                date = lastModification;
                modified = true;
            }
        }
    }

    return modified;
}
示例#2
0
osg::Sequence* createSequence(osg::ArgumentParser& arguments)
{
    // assumes any remaining parameters are models
    osg::Sequence* seq = new osg::Sequence;

    typedef std::vector<std::string> Filenames;
    Filenames filenames;

    if (arguments.argc() > 1)
    {
        for (int i = 1; i < arguments.argc(); ++i)
        {
            filenames.push_back(arguments[i]);
        }
    }
    else
    {
        filenames.push_back("cow.osgt");
        filenames.push_back("dumptruck.osgt");
        filenames.push_back("cessna.osgt");
        filenames.push_back("glider.osgt");
    }

    for(Filenames::iterator itr = filenames.begin();
        itr != filenames.end();
        ++itr)
    {
        // load model
        osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFile(*itr);

        if (node)
        {
            seq->addChild(createScaledNode(node.get(), 100.0f));
            seq->setTime(seq->getNumChildren()-1, 1.0f);
        }
    }

    // loop through all children
    seq->setInterval(osg::Sequence::LOOP, 0,-1);

    // real-time playback, repeat indefinitively
    seq->setDuration(1.0f, -1);

    seq->setMode(osg::Sequence::START);

    return seq;
}
示例#3
0
void Application::_loadModelFiles ( const Filenames& filenames )
{
  for ( Filenames::const_iterator iter = filenames.begin(); iter != filenames.end(); ++iter )
  {
    const std::string filename ( *iter );
    if ( ".minerva" == boost::filesystem::extension ( filename ) )
    {
      OsgTools::Group::removeAllChildren ( _models.get() );

      std::cout << "Loading filename " << filename << std::endl;

      Minerva::Document::MinervaDocument::RefPtr document ( new Minerva::Document::MinervaDocument );
      document->read ( filename );

      osg::ref_ptr < osg::Node > model ( document->buildScene() );
      
      // Hook things up.
      _models->addChild ( model );

      // Based on the scene size, set the near and far clipping plane distances.
      this->_setNearAndFarClippingPlanes();

      // Set the document.
      _document = document;

      // Set the global timespan.
      _animationController->globalTimeSpan ( document->timeSpanOfData() );

      // Set the navigator data.
      _navigator->body ( document->body() );

      Usul::Math::Matrix44d m ( Usul::Registry::Database::instance()[this->_documentSection()][VRV::Constants::Keys::HOME_POSITION].get<Usul::Math::Matrix44d> ( Usul::Math::Matrix44d(), true ) );
      _home.set ( &m[0] );

      // Push it back so we can see it.
      this->viewScene();
    }
  }
}