Hi,

i want to auto generate a few LODs with osg::Simplifier 
then i want to add these nodes to an LOD 
whats going wrong
i see only the first Node from 0 - 300 pixels distance  

iam using Version 2.8.2 of OSG


Code:

int main( int argc, char **argv )
{
       glutInit(&argc, argv);
       glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_ALPHA );
       glutInitWindowPosition( 100, 100 );
       glutInitWindowSize( 800, 600 );
       glutCreateWindow( argv[0] );
       glutDisplayFunc( display );
       glutReshapeFunc( reshape );
       glutMouseFunc( mousebutton );
       glutMotionFunc( mousemove );
       glutPassiveMotionFunc( passivemousemove );
       glutKeyboardFunc( keyboard );

       osg::ref_ptr<osg::Group> root = new osg::Group;
       osg::ref_ptr<osg::Node> loadedModel = 
osgDB::readNodeFile("C:\\3001.ive");
       osg::ref_ptr<osg::LOD> pLod = new osg::LOD ;
       pLod->setRangeMode( osg::LOD::DISTANCE_FROM_EYE_POINT );

       float sampleRatio = 0.5f;
       float maxError = 4.0f;
       float multiplier = 0.8f;
       float minRatio = 0.001f;
       float ratio = sampleRatio;

       float LODnear = 0.0;  
       float LODfar = 300.0;

       for ( int i = 0 ; i < 3; i++)
       {
              ratio *= multiplier;
              osgUtil::Simplifier simplifier(ratio, maxError);
              osg::ref_ptr<osg::Node> simplNode = 
(osg::Node*)loadedModel->clone(osg::CopyOp::DEEP_COPY_ALL); 
              simplNode->accept(simplifier); 
              pLod->addChild( simplNode.get(), LODnear, LODfar ); 
              LODnear = LODfar;
              LODfar += 300.0;
       }
       root->addChild( pLod.get() ); 

       viewer = new osgViewer::Viewer;
       window = viewer->setUpViewerAsEmbeddedInWindow(100,100,800,600);
       viewer->setSceneData( root.get());
       viewer->setCameraManipulator( new cSphericalManipulator );
       viewer->addEventHandler(new osgViewer::StatsHandler);
       viewer->realize();
       glutMainLoop();
       return 0;
}





Thank you!

Cheers,
Matthias[/code]

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=18092#18092





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to