[osg-users] [forum] Saving scene object to .obj file

Robert Osfield robert.osfield at gmail.com
Tue Apr 26 03:24:02 PDT 2011


Hi Matrin,

The shape drawable does not store or represent a mesh, rather
internally it creates the vertex and primitive data and display lists
it for rendering.  Given this there isn't anything to export to a
format like .obj.  Creating
conventional meshes is supported though, but .obj is very very crude
format so will loose much of OSG state and structure along the way.
Exporting to OpenFlight or Collada would probably be a better route.

Robert.

On Sat, Apr 23, 2011 at 2:36 PM, Martin Varsa <nabordelaspam at centrum.cz> wrote:
> Hi,
>
> I'd like to know if there is possibility to write geometry of objects to file for later use in 3D editor? I work on project where I create objects in virtual reality engine (it uses osg). So I'd like to save these created object do .obj or other file for use in 3D editor.
>
> I've tried this:
>
> Code:
>
> osg::ref_ptr<osg::Sphere> sphere = new osg::Sphere(osg::Vec3f(0,0,0), 1.0);
> osg::ref_ptr<osg::ShapeDrawable> sphereShape = new osg::ShapeDrawable(sphere);
> sphereShape->setUseDisplayList(false);
>
>
> if( osgDB::writeObjectFile(sphereShape.get(), "testfile.obj") ){
>  cout << "uspesne zapsano do souboru" << endl;
> } else {
>  cout << "cyhba pri zapisu do souboru" << endl;
> }
>
>
>
> but without success.
>
> Thank you a lot!
>
> Cheers,
> Martin
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=38751#38751
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



More information about the osg-users mailing list