Hi Nan, The osgViewer::Viewer already has a Camere assigned to so there is no need to create one. You can create and assign your own Camera to the Viewer, but you'd have to assign a Renderer to it so it can render it's scene, the default Viewer's Camera is already set up correctly so there is no need to do this.
Robert. On Mon, Feb 7, 2011 at 1:09 PM, Nan WANG <[email protected]> wrote: > Hi, > > I could not fine source code on this topic. > I tried these code, but nothing rendered, what is the problem? > > Code: > > osg::Node* tankNode = NULL; > osg::Group* root = NULL; > osgViewer::Viewer viewer; > osg::Vec3 tankPosit; > osg::PositionAttitudeTransform* tankXform; > osg::ref_ptr<osg::Camera> camera = new osg::Camera; > > tankNode = osgDB::readNodeFile("cow.osg"); > > root = new osg::Group(); > tankXform = new osg::PositionAttitudeTransform(); > > root->addChild(tankXform); > tankXform->addChild(tankNode); > > tankPosit.set(0,2,0); > tankXform->setPosition( tankPosit ); > viewer.setCameraManipulator(new osgGA::TrackballManipulator()); > camera->addChild(root); > osg::Vec4 bgColor(0.2f, 0.2f, 0.6f, 1.0f); > > viewer.setCamera(camera); > viewer.setSceneData( root ); > viewer.realize(); > > while( !viewer.done() ) > { > viewer.frame(); > } > > > > Thanks > > Nan > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=36424#36424 > > > > > > _______________________________________________ > 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

