Hi Sanat, Have a look at the osganimation example.
FYI, Viewer::frame() calls updateTraversal() for you, so you don't need to call it yourself. Robert. On Thu, Jul 22, 2010 at 11:41 AM, Sanat Talmaki <[email protected]> wrote: > Hi, > > I am trying to set new values for the position of my PAT node for every run > of while(!viewer.done()) > > > Code: > while( !viewer.done() ) > { > osg::Vec3d positionVector; > // fire off the cull and draw traversals of the scene. > viewer.frame(); > viewer.updateTraversal(); > receiveSignal(gpsInstance, gpsLat, gpsLon); > setBackhoe(gpsLat, gpsLon, mapNode, surface, objectPlacer, backhoe1PAT); > return 0; > } > > > > And in my function: > > > Code: > void setBackhoe(double gpsLat, > double gpsLon, > osgEarth::MapNode* mapNode, > osg::Node *surface, > osgEarthUtil::ObjectPlacer* objectPlacer, > osg::PositionAttitudeTransform* backhoe1PAT > //osg::Vec3d &positionVector > ) > { > osg::Matrixd positionMatrix1; > objectPlacer->createPlacerMatrix(gpsLat, gpsLon, 131, positionMatrix1); > static double latitude; > static double longitude; > static double height; > //static double x, y; > static double X1 = positionMatrix1.getTrans().x(); > static double Y1 = positionMatrix1.getTrans().y(); > static double Z1 = positionMatrix1.getTrans().z(); > //get SpatialReferenceSystem SRS for terrain (i.e. map) and lat-long. > const SpatialReference* terrain_srs = > mapNode->getMap()->getProfile()->getSRS(); > const SpatialReference* latlong_srs = terrain_srs->getGeographicSRS(); > //convert from projected to lat-long: > terrain_srs->transform(X1, Y1, latlong_srs, longitude, latitude ); > //to go from lat-long to projected: > latlong_srs->transform(longitude, latitude, terrain_srs, X1, Y1); > //set backhoe 1 exactly over terrain: letting the callback do that > work. > //set the PAT value of backhoe1: > backhoe1PAT->setPosition(osg::Vec3d(X1, Y1, 0.0)); > return ; > } > > > > The problem I'm having is the my PAT node resets to (0,0,0) as soon as the > function is exited. But since I was passing in by pointer a PAT node which I > created in my main(), I thought this would not happen. > > How can I keep the current position value in my PAT node till it is updated > in the next run ? > > Been stuck on this for quite a while so was hoping to get some advise. > > Thanks. > > Best, > > Sanat > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=30176#30176 > > > > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

