Hi,

works for me on Linux, OSG 1.2. I attach the whole file in case someone else 
wants to try it. 

Alberto

El Martes 05 Junio 2007, Thomas Giricz escribió:
> 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



#include <osgDB/ReadFile>
#include <osg/ref_ptr>
#include <osgProducer/Viewer>
#include <osgDB/ReadFile>
#include <osg/Node>
#include <osg/Group>
#include <osg/ShapeDrawable>
#include <osg/MatrixTransform>
#include <osg/Matrix>
#include <osg/Vec3d>
#include <osgProducer/Viewer>
#include <osg/CameraNode>
#include <osg/DisplaySettings>

#include <Producer/CameraConfig>
#include <Producer/Camera>

int main()
{

	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;
   }


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

   while(!viewer.done()) {
      viewer.sync();
      viewer.update();
      viewer.frame();
   }
}
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to