Hi John,

I don't know the cause of only the airplane showing up, but can
suggest a few things to try to explore what might be going wrong.

First up try loading each of the models with osgviewer and see if each
one loads up OK.

Second write out the completed scene graph to a .osg file just before
you run the viewer code.  Then try to load this scene graph into
osgviewer and see what happens.

On the osgProducer::Viewer -> osgViewer::Viewer conversion, with
osgViewer the Viewer::frame() method does the sync, update and event
traversals, and the rendering traversals all together.  Have a look at
the source code to Viewer::frame() to see what it's doing.  You can
break your frame loop out to call each traversals individually if you
want.  Have a look at discussions about this on the mailing
lists/forum and the website, and the examples.

In your case you can safely comment out the call to
viewer->updateTravesal() as viewer->frame() will be doing it for you.

Robert.





On Tue, Sep 28, 2010 at 4:10 PM, John Stokes <jstokes2...@yahoo.com> wrote:
> Hi,
>
> I've been migrating some code from OSG 0.9.9 to the latest stable release 
> (2.8.3), and I've run into an issue when migrating from OSGProducer::viewer 
> to OsgViewer::viewer. I have three models, an airplane.3ds model, a sky.3ds 
> model, and a globe.osga model. All three models load correctly (the nodes 
> returned from osgDB::readNodeFile are not NULL), but only the airplane model 
> shows up when the viewer display is rendered.
>
> The only functions that I needed to change from osgProducer to osgViewer were 
> my initialization and update functions. I've made sure to replace osgProducer 
> calls with equivalent osgViewer calls when I upgraded (see code below), but 
> is there anything I might have missed?
>
>
>
> Code:
>
>
> 3DPlaneViewer::Initialize(){
> osgViewer::Viewer* viewer = new osgViewer::Viewer();
>
> //scene root
> osg::Group* root = new osg::Group();
>
> //load globe and add transform of globe to root group
> osg::Node* globeNode = osgDB::readNodeFile("globe.osga");
> osg::MatrixTransform* globeTransform = new osg::MatrixTransform();
> globeTransform->addChild( globeNode );
>
> //create group for globe and sky
> osg::Group*terrainNodes = new Group();
> terrainNodes->asGroup()->addChild( globeTransform );
>
> //load airplane
> osg::Node* airplaneNode = osgDB::readNodeFile("airplane.3ds");
> //specify a location for plane on globe with lat, long, altitude
> osg::Matrixd airplaneMatrix;
> osg::EllipsoidModel* ellipse->computeLocalToWorldTransformFromLatLongHeight( 
> osg::DegreesToRadians(20.0f),osg::DegreesToRadians(-30.0f), 
> 15000,airplaneMatrix );
>
> //rotate airplane node
> airplaneMatrix.preMult( airplaneMatrix.rotate( 
> osg::Quat(osg::DegreesToRadians(180.0f), osg::Vec3f( 0, 0, 1 ) )));
>
> //setup matrix wrapper node
> osg::MatrixTransform* airplaneTransform = new osg::MatrixTransform();
> airplaneTransform->getOrCreateStateSet()->setMode(GL_RESCALE_NORMAL,osg::StateAttribute::ON);
> airplaneTransform->setMatrix(airplaneMatrix);
> airplaneTransform->addChild( airplaneNode );
> terrainNodes->asGroup()->addChild( airplaneTransform );
>
>
> //load and add the sky model
> osg::Node* skyNode = osgDB::readNodeFile("sky.3DS");
> osg::MatrixTransform* skyTransform = new osg::MatrixTransform();
> skyTransform->addChild( skyNode );
> terrainNodes->asGroup()->addChild( skyTransform );
>
> root->addChild( terrainNodes );
>
> //realize the scene in the viewer
> viewer->setSceneData(root);
> viewer->realize();
>
> }
>
> 3DPlaneViewer::Update()
> {
>
> //removed calls to osgProducer::sync()
> viewer->updateTraversal();
>
> //do some other updates on other objects in the scene
> viewer->frame();
> }
>
>
>
>
>
> Thanks,
> John
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=32136#32136
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to