diff --git a/applications/osgconv/osgconv.cpp b/applications/osgconv/osgconv.cpp index 3c97e1a9c..050c6663e 100644 --- a/applications/osgconv/osgconv.cpp +++ b/applications/osgconv/osgconv.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -18,6 +19,7 @@ #include #include +#include #include #include @@ -74,6 +76,37 @@ class MyGraphicsContext { osg::ref_ptr _gc; }; +class DefaultNormalsGeometryVisitor + : public osg::NodeVisitor +{ +public: + + DefaultNormalsGeometryVisitor() + : osg::NodeVisitor( osg::NodeVisitor::TRAVERSE_ALL_CHILDREN ) { + } + + virtual void apply( osg::Geode & geode ) + { + for( unsigned int ii = 0; ii < geode.getNumDrawables(); ++ii ) + { + osg::ref_ptr< osg::Geometry > geometry = dynamic_cast< osg::Geometry * >( geode.getDrawable( ii ) ); + if( geometry.valid() ) + { + osg::ref_ptr< osg::Vec3Array > newnormals = new osg::Vec3Array; + newnormals->push_back( osg::Z_AXIS ); + geometry->setNormalArray( newnormals.get() ); + geometry->setNormalBinding( osg::Geometry::BIND_OVERALL ); + } + } + } + + virtual void apply( osg::Node & node ) + { + traverse( node ); + } + +}; + class CompressTexturesVisitor : public osg::NodeVisitor { public: @@ -369,10 +402,21 @@ static void usage( const char *prog, const char *msg ) osg::notify(osg::NOTICE)<< std::endl; osg::notify(osg::NOTICE) << msg << std::endl; } + + // basic usage osg::notify(osg::NOTICE)<< std::endl; osg::notify(osg::NOTICE)<<"usage:"<< std::endl; osg::notify(osg::NOTICE)<<" " << prog << " [options] infile1 [infile2 ...] outfile"<< std::endl; osg::notify(osg::NOTICE)<< std::endl; + + // print env options - especially since optimizer is always _on_ + osg::notify(osg::NOTICE)<<"environment:" << std::endl; + osg::ApplicationUsage::UsageMap um = osg::ApplicationUsage::instance()->getEnvironmentalVariables(); + std::string envstring; + osg::ApplicationUsage::instance()->getFormattedString( envstring, um ); + osg::notify(osg::NOTICE)<accept( dngv ); + } + + // apply any user-specified simplification + if ( do_simplify ) + { + osgUtil::Simplifier simple; + simple.setSmoothing( smooth ); + osg::notify( osg::ALWAYS ) << " smoothing: " << smooth << std::endl; + simple.setSampleRatio( simplifyPercent ); + root->accept( simple ); + } + osgDB::ReaderWriter::WriteResult result = osgDB::Registry::instance()->writeNode(*root,fileNameOut,osgDB::Registry::instance()->getOptions()); if (result.success()) {