Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm looking for a way to export 3D graphics objects to the Collada (.dae) format. I need an automated way, i.e. using Blender to manually convert from another format is not a good solution.

I'm sure all of the following is not possible at the same time, but ideally:

  • Aspect ratio (BoxRatios) should be preserved

  • Colours should be preserved (if possible)

  • Visible bounding box should be preserved (if possible)

  • Initial view point should be preserved when opening the file in a viewer (if possible)

  • Supporting Polygon and Cuboid is sufficient.


Information that would help me implement this myself:

  • Which formats that Mathematica supports can theoretically handle most of the requirements above? Out of these, which one does Mathematica have the best support for?

  • Are there command line programs or other Mathematica-controllable tools that can convert a Mathematica-exportable format to Collada?

share|improve this question

2 Answers 2

I've used Assimp for this, though I have never managed to preserve box ratios, the bounding box, or the view point.

Graphics3D[{
 Red,
 Cuboid[],
 Blue,
 Cylinder[]}];
Export["g.lwo", %]
Run["assimp.exe export g.lwo out.dae"]

enter image description here

For OS X, pre-compiled Assimp binaries are available in MacPorts.

share|improve this answer
    
Do you recommend 3DS as the intermediary format or you're also not sure which one is best? –  Szabolcs Jun 24 at 18:15
    
Yeah, I am unsure -- I just use 3DS out of habit because it has always met my needs. But the library supports quite a few formats. –  mfvonh Jun 24 at 18:19
    
This was very promising, but unfortunately both assimp 3.0 (MacPorts) and assimp 3.1.1 (compiled it) produces broken DAE files. Neither Blender, nor OS X Preview can read them. I tried a complex object as well as a simple Graphcis3D[{Cylinder[]}]. –  Szabolcs Jun 24 at 18:34
    
@Szabolcs Try .lwo, I was able to get that to open in Blender. Seems like 3DS is specifically not advisable because it's resulting in unescaped XML like this: <visual_scene id="<3DSDummyRoot>" name="<3DSDummyRoot>">. It seems to lose color info; it may be worth playing with the available formats. –  mfvonh Jun 24 at 18:51
    
Alternatively you could pass it back through Mathematica and try to clean up the XML lol –  mfvonh Jun 24 at 18:54

I have successfully exported many 3D Mathematica objects in the .stl format (used for 3D printing). I use Cheetah3D on the Mac (now $69) to work with the object, add axes or colors, then export as a .dae for use in Collada environments like iBooks Author. Maybe Google Sketchup would also work; it has Collada as a native format but not sure what it imports. Hope this helps!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.