diff --git a/src/osgPlugins/rot/ReaderWriterROT.cpp b/src/osgPlugins/rot/ReaderWriterROT.cpp index 78f65b8b1..8cdafc48f 100644 --- a/src/osgPlugins/rot/ReaderWriterROT.cpp +++ b/src/osgPlugins/rot/ReaderWriterROT.cpp @@ -10,8 +10,8 @@ * */ -/* file: src/osgPlugins/rot/ReaderWriterROT.cpp - * author: Mike Weiblen http://mew.cx/ 2004-04-25 +/* file: src/osgPlugins/rot/ReaderWriterROT.cpp + * author: Mike Weiblen http://mew.cx/ 2004-07-15 * copyright: (C) 2004 Michael Weiblen * license: OpenSceneGraph Public License (OSGPL) */ @@ -32,8 +32,21 @@ /////////////////////////////////////////////////////////////////////////// /** - * An OSG reader plugin for the rotation pseudo-loader. + * An OSG reader plugin for the ".rot" pseudo-loader, which inserts a + * rotation transform above the loaded geometry. + * This pseudo-loader makes it simple to change the orientation of a saved + * model by specifying a correcting rotation as part of the filename. + * + * Usage: .,,.globe + * where: + * = an model filename. + * = rotation around X axis [degrees] + * = rotation around Y axis [degrees] + * = rotation around Z axis [degrees] + * + * example: osgviewer cow.osg.30,60,-90.rot */ + class ReaderWriterROT : public osgDB::ReaderWriter { public: @@ -43,7 +56,7 @@ public: virtual bool acceptsExtension(const std::string& extension) { - return osgDB::equalCaseInsensitive( extension, EXTENSION_NAME ); + return osgDB::equalCaseInsensitive( extension, EXTENSION_NAME ); } virtual ReadResult readNode(const std::string& fileName, diff --git a/src/osgPlugins/scale/ReaderWriterSCALE.cpp b/src/osgPlugins/scale/ReaderWriterSCALE.cpp index be0a4b3aa..0c37b4c04 100644 --- a/src/osgPlugins/scale/ReaderWriterSCALE.cpp +++ b/src/osgPlugins/scale/ReaderWriterSCALE.cpp @@ -10,8 +10,8 @@ * */ -/* file: src/osgPlugins/scale/ReaderWriterSCALE.cpp - * author: Mike Weiblen http://mew.cx/ 2004-04-25 +/* file: src/osgPlugins/scale/ReaderWriterSCALE.cpp + * author: Mike Weiblen http://mew.cx/ 2004-07-15 * copyright: (C) 2004 Michael Weiblen * license: OpenSceneGraph Public License (OSGPL) */ @@ -32,8 +32,23 @@ /////////////////////////////////////////////////////////////////////////// /** - * An OSG reader plugin for the scaling pseudo-loader. + * An OSG reader plugin for the ".scale" pseudo-loader, which inserts a + * scale transform above the loaded geometry. + * This pseudo-loader make it simple to change the size of a saved model + * by specifying a correcting scale factor as part of the filename. + * + * Usage: .,,.globe + * ..globe + * where: + * = an model filename. + * = scale factor along the X axis. + * = scale factor along the Y axis. + * = scale factor along the Z axis. + * = uniform scale factor applied to all axes. + * + * example: osgviewer cow.osg.5.scale cessna.osg */ + class ReaderWriterSCALE : public osgDB::ReaderWriter { public: @@ -43,7 +58,7 @@ public: virtual bool acceptsExtension(const std::string& extension) { - return osgDB::equalCaseInsensitive( extension, EXTENSION_NAME ); + return osgDB::equalCaseInsensitive( extension, EXTENSION_NAME ); } virtual ReadResult readNode(const std::string& fileName, @@ -79,11 +94,11 @@ public: int sx, sy, sz; int count = sscanf( params.c_str(), "%d,%d,%d", &sx, &sy, &sz ); if( count == 1 ) - { - // if only one value supplied, apply uniform scaling - sy = sx; - sz = sx; - } + { + // if only one value supplied, apply uniform scaling + sy = sx; + sz = sx; + } else if( count != 3 ) { osg::notify(osg::WARN) << "Bad parameters for " EXTENSION_NAME " pseudo-loader: \"" << params << "\"" << std::endl; @@ -104,12 +119,9 @@ public: xform->setMatrix( osg::Matrix::scale( sx, sy, sz ) ); xform->addChild( node ); - // TODO: should we force GL_NORMALIZE on? - // osg::StateSet* ss = xform->getOrCreateStateSet(); - // ss->setMode( GL_NORMALIZE, osg::StateAttribute::ON ); - // Or since the scale is static, perhaps renormalization - // would be better performed once at loadtime with a - // .normalize pseudo-loader? + // turn on GL_NORMALIZE to prevent problems with scaled normals + osg::StateSet* ss = xform->getOrCreateStateSet(); + ss->setMode( GL_NORMALIZE, osg::StateAttribute::ON ); return xform; } diff --git a/src/osgPlugins/trans/ReaderWriterTRANS.cpp b/src/osgPlugins/trans/ReaderWriterTRANS.cpp index 719f78118..302b3eab1 100644 --- a/src/osgPlugins/trans/ReaderWriterTRANS.cpp +++ b/src/osgPlugins/trans/ReaderWriterTRANS.cpp @@ -10,8 +10,8 @@ * */ -/* file: src/osgPlugins/trans/ReaderWriterTRANS.cpp - * author: Mike Weiblen http://mew.cx/ 2004-04-25 +/* file: src/osgPlugins/trans/ReaderWriterTRANS.cpp + * author: Mike Weiblen http://mew.cx/ 2004-07-15 * copyright: (C) 2004 Michael Weiblen * license: OpenSceneGraph Public License (OSGPL) */ @@ -32,8 +32,21 @@ /////////////////////////////////////////////////////////////////////////// /** - * An OSG reader plugin for the translation pseudo-loader. + * An OSG reader plugin for the ".trans" pseudo-loader, which inserts a + * translation transform above the loaded geometry. + * This pseudo-loader make it simple to change the origin of a saved model + * by specifying a correcting translation as part of the filename. + * + * Usage: .,,.globe + * where: + * = an model filename. + * = translation along the X axis. + * = translation along the Y axis. + * = translation along the Z axis. + * + * example: osgviewer cow.osg.25,0,0.trans cessna.osg */ + class ReaderWriterTRANS : public osgDB::ReaderWriter { public: @@ -43,7 +56,7 @@ public: virtual bool acceptsExtension(const std::string& extension) { - return osgDB::equalCaseInsensitive( extension, EXTENSION_NAME ); + return osgDB::equalCaseInsensitive( extension, EXTENSION_NAME ); } virtual ReadResult readNode(const std::string& fileName,