From 2550c95c32c91e430c3e681b429ed84b127e1423 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 2 Aug 2016 17:52:45 +0100 Subject: [PATCH] Added GL_NORMALIZE usage to handle the case of the FlattenStaticTransform visitor not being applied to the scaled subgraphs causing lighting problems --- examples/osganimate/osganimate.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/examples/osganimate/osganimate.cpp b/examples/osganimate/osganimate.cpp index f8db214b7..3a790c4d8 100644 --- a/examples/osganimate/osganimate.cpp +++ b/examples/osganimate/osganimate.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -146,7 +147,7 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius) float size = radius/bs.radius()*0.3f; osg::MatrixTransform* positioned = new osg::MatrixTransform; positioned->setDataVariance(osg::Object::STATIC); - positioned->setMatrix(osg::Matrix::translate(-bs.center())* + positioned ->setMatrix(osg::Matrix::translate(-bs.center())* osg::Matrix::scale(size,size,size)* osg::Matrix::rotate(osg::inDegrees(-90.0f),0.0f,0.0f,1.0f)); @@ -180,6 +181,10 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius) model->addChild(xform); } + #ifndef OSG_GLES2_AVAILABLE + model->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON); + #endif + return model.release(); } @@ -247,6 +252,13 @@ int main( int argc, char **argv ) osgUtil::Optimizer optimzer; optimzer.optimize(rootnode); + std::string filename; + if (arguments.read("-o",filename)) + { + osgDB::writeNodeFile(*rootnode, filename); + return 1; + } + // set the scene to render viewer.setSceneData(rootnode);