문제

I've tried to create, and export a sphere using OpenSceneGraph. I've got no error message, but the exported .obj file is empty.

I have no idea, what do I wrong.

int main( int argc, char** argv )
{
    osg::ref_ptr<osg::Group> root = new osg::Group;

    osg::Sphere* unitSphere = new osg::Sphere( osg::Vec3(0,0,0), 1.0);
    osg::ShapeDrawable* unitSphereDrawable = new osg::ShapeDrawable(unitSphere);

    osg::Geode* basicShapesGeode = new osg::Geode();
    basicShapesGeode->addDrawable(unitSphereDrawable);

    root->addChild(basicShapesGeode);

    osgDB::writeNodeFile(*(root.get()), "sphere.obj");

    return 0;
}

I would like to export a snowman, which is just 3 spheres, one above the other. But if I try to export spheres, or other shapes, the .obj file is empty.

도움이 되었습니까?

해결책

I think the ShapeDrawable is kind of a custom class, that isn't just basic geometry in an array (like the saver wants to see to export).

Those classes are kind of deprecated anyway because they use older OpenGL calls that don't perform all that well anyway.

What are you really trying to accomplish?

I believe the osgWorks library (a supplementary toolkit not part of basic OSG) has tools that create actual geometry-based spheres, etc.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top