Show
Ignore:
Timestamp:
06/30/05 11:08:31 (9 years ago)
Author:
robert
Message:

Added tri sripping and support for outputing files.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgsimplifier/osgsimplifier.cpp

    r2898 r4367  
    1111 
    1212#include <osgDB/ReadFile> 
     13#include <osgDB/WriteFile> 
    1314#include <osgUtil/Optimizer> 
    1415#include <osgUtil/Simplifier> 
     16#include <osgUtil/TriStripVisitor> 
     17#include <osgUtil/Optimizer> 
    1518#include <osgProducer/Viewer> 
    1619 
     
    4851        return 1; 
    4952    } 
     53    std::string outputFileName; 
     54    while (arguments.read("-o",outputFileName)) {} 
    5055 
    5156    // report any errors if they have occured when parsing the program aguments. 
     
    8388    } 
    8489 
    85     osg::Timer_t end_tick = osg::Timer::instance()->tick(); 
     90    osg::Timer_t end_load_tick = osg::Timer::instance()->tick(); 
    8691 
    87     std::cout << "Time to load = "<<osg::Timer::instance()->delta_s(start_tick,end_tick)<<std::endl; 
     92    std::cout << "Time to load = "<<osg::Timer::instance()->delta_s(start_tick,end_load_tick)<<std::endl; 
    8893 
    8994    osgUtil::Simplifier simplifier(sampleRatio); 
    90      
    9195    loadedModel->accept(simplifier); 
     96 
     97    osg::Timer_t end_simplifier_tick = osg::Timer::instance()->tick(); 
     98 
     99    std::cout << "Time to simplify = "<<osg::Timer::instance()->delta_s(end_load_tick, end_simplifier_tick)<<std::endl; 
     100 
     101    osgUtil::TriStripVisitor tsv; 
     102    tsv.setMinStripSize(3); 
     103    loadedModel->accept(tsv); 
     104    tsv.stripify(); 
     105 
     106    osg::Timer_t end_tristrip_tick = osg::Timer::instance()->tick(); 
     107 
     108    std::cout << "Time to tri strip = "<<osg::Timer::instance()->delta_s(end_simplifier_tick, end_tristrip_tick)<<std::endl; 
     109 
     110    // run optimization over the scene graph 
     111    osgUtil::Optimizer optimzer; 
     112    optimzer.optimize(loadedModel.get()); 
     113 
     114    if (!outputFileName.empty()) 
     115    { 
     116        std::cout << "Writing out scene graph as '" << outputFileName << "'"<<std::endl; 
     117        osgDB::writeNodeFile(*loadedModel,outputFileName); 
     118        return 0; 
     119    } 
    92120 
    93121    // set the scene to render