我尝试使用OpenSceneGraph创建和导出球体。我没有错误消息,但是导出的.obj文件为空。

我不知道,我怎么了?

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




我想导出一个雪人,它只有3个球体,一个在另一个上。但是,如果我尝试导出球体或其他形状,则.obj文件为空。

最佳答案

我认为ShapeDrawable是一个自定义类,它不仅是数组中的基本几何图形(就像保护程序希望看到要导出的那样)。

这些类无论如何都已被弃用,因为它们使用的老旧OpenGL调用无论如何都不能很好地执行。

您真正想完成什么?

我相信osgWorks库(不是基本OSG的补充工具包)具有创建实际基于几何的球体等的工具。

关于c++ - 使用OpenSceneGraph创建和导出球体,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20419298/

10-11 22:42
查看更多