I've found how to export a 3D OpenGL scene to ppm
. But is it possible to export to the STL
format ? This is the format required for 3D printing.
There's a package for STL parsing but I don't know whether it is possible to use it with OpenGL.
Someone proposes to close this question for unclearness. I just want to know whether it is possible to export a 3D Haskell OpenGL graphic to a file appropriate for 3D printing (not necessarily STL, but as far as I know this is the only way - I may be wrong.) Sorry if it's still unclear, it may be due to my wording and my English. I do the best I can.
Just for info, here is an example with the R package rgl
:
And here is how the STL
file looks like in ASCII representation (it takes 3.7 MB):
solid testSTL.stl produced by RGL
facet normal -0.9965197 -0.05894169 -0.05894333
outer loop
vertex 0.8633249 0 0
vertex 0.8656725 0 -0.03968928
vertex 0.8642709 0.0237557 -0.03974825
endloop
endfacet
facet normal -0.9965196 -0.05894321 -0.05894424
outer loop
vertex 0.8633249 0 0
vertex 0.8642709 0.0237557 -0.03974825
vertex 0.8619304 0.0235772 0
endloop
endfacet
facet normal -0.9827041 -0.05841724 -0.1757272
outer loop
vertex 0.8656725 0 -0.03968928
vertex 0.8726366 0 -0.07863396
vertex 0.8712143 0.02428522 -0.0787534
endloop
endfacet
...
So that does not sound impossible to have a STL converter for Haskell...
EDIT
There's a possible way but I didn't manage on Windows (that's frustrating)
convert the OpenGL graphic to
ppm
using thegl-capture
library; convert theppm
tosvg
using ImageMagick (or perhaps don't necessarily convert - theppm
can be opened in InkScape, see next steps)install OpenSCAD and InkScape (there exist portable versions)
install this InkScape extension and follow the instructions
EDIT
Another possible way here. Similarly, I've failed.