0

Can anyone guide me how do I convert OSG (OpenSceneGraph) file format image into STL file format. I tried to find ways by google searching but i didn't proper link for that.

I am working on processing where I need STL file. So could you please help me get it by OSG file.

Harald Scheirich
  • 9,676
  • 29
  • 53
Irfan Ghaffar7
  • 1,143
  • 4
  • 11
  • 30

2 Answers2

1

osgDB is the library for read/write scene graphs in different formats, and there's an OSG plugin to read/write scene graphs to STL format.

First, you need to build OSG linking to VRLM library, in which OSG depends to build de STL plugin. If you are using CMake, the keys are: OPENVRLM_INCLUDE_DIR, OPENVRLM_LIBRARY and OPENVRLM_LIBRARY_DEBUG. After a successfull build, you will find the builded plugin at bin\osgPlugins-3.0.1

Then, you only need to read the .osg scene graph and write the .stl scene graph. Something like this:

#include <osgDB/WriteFile>
#include <osgDB/ReadFile> 

...

osg::ref_ptr<osg::Node> node = osgDB::readNodeFile("node.osg");
osgDB::writeNodeFile(node, "node.stl");

...

osgDB will select STL plugin based on the file extension (.stl).

kanobius
  • 756
  • 9
  • 12
1

osgconv which is a tool that is part of OpenSceneGraph should do the trick if you have the STL file format available, I don't know what the requirements for the stl plugin to build but osgconv --formats would tell you which formats are supported by your build of OSG, see this reference or type in osgconv --help for all the options.

To convert just use osgconv infile outfile.stl this works with any format supported by OSG, reading and writing.

Harald Scheirich
  • 9,676
  • 29
  • 53