Hello,

I'm trying to render a box in OpenSceneGraph, which should be very
simple. However, I just don't get a box in my viewer and I can't seem
to find the mistake.

This is my code for the box:

  osg::Group* root = new osg::Group();
  osg::Box* cube = new osg::Box(osg::Vec3f(0.0f, 0.0f, 0.0f), 1.0f,
1.0f, 1.0f);

  osg::ShapeDrawable* cubeDrawable = new osg::ShapeDrawable(cube);
  osg::Geode* geode = new osg::Geode();
  if (!geode->addDrawable(cubeDrawable) ) {
     std::cerr << "Error adding drawable to geode" << std::endl;
  }
  if (!root->addChild(geode) ) {
     std::cerr << "Error adding geode to root" << std::endl;
  }


To view this, I'm using osgProducer:

  osgProducer::Viewer viewer;
  viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS);
  viewer.setSceneData(root);
  viewer.realize();

  while(!viewer.done()) {
     viewer.sync();
     viewer.update();
     viewer.frame();
  }


At first I don't see anything in my viewer. When I search through the
scene manually, I find something, but it is not a box. It looks like a
plane or a part of a plane, which sometimes seems to be hidden behind
something. When I move the scene, this object does not move
constantly, but jumps from one position to the next.

Where is the mistake? Is it a problem, that I did not associate a
StateSet? Should I add a light source? Am I unable to use osgProducer?
Or does the code work fine with you and I somehox got a corrupted
version of OpenSceneGraph?


Kind regards,

Thomas
_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to