Cheetah3D to Babylon.JS exporter
Lately, I’ve been working a lot on MacOS X on 3D stuff, and I got the chance to take a look at how Cheetah3D works. For those who don’t know about it, it’s a mac only 3d software that’s not expensive and simple enough for devs like me to handle. It’s powerful enough to be used as a quick prototyping tool and a complex scene renderer. I’ll leave the technical details to 3d artists, but the point is I had to use it for realtime stuff.
This realtime stuff included native opengl on iOS and more recently webgl on your browser. Not being influenced or whatsoever, I recommended Babylon.JS for the work, and we went with it. That’s all that I can say regarding my job, so let’s go straight to the point : I made a simple export script for Cheetah3D to transform your scene into a babylon file which you can load in your browser. You can download and fork it on my github. Install is simple enough : just drop the js file into /Users/YOUR_USER/Library/Application Support/Cheetah3D/Scripts/Macro/
. This is a macro script for those who know a bit about Cheetah3D scripting, meaning it covers a lot of things : reading the scene, parsing, creating and saving a file. If you want to export your scene, just go to Tools/Scripts/Macro/Babylon file export
in Cheetah3D.
So, what can you do right now? It’s far from totally complete compared to babylon file specifications, but here’s what you get:
- mesh export with functional transform, naming and parenting
- multicamera export (only perspective, no support for orthogonal right now)
- light export with all babylon type managed :
- Cheetah3D spot light is a babylon spot (duh)
- Cheetah3D distant light is a babylon directional light
- Cheetah3D ambiant light is a babylon hemispheric light
- every other type is a babylon point light
- supports diffuse and specular color
- rotations must be on the -Y axis
- materials export:
- supports diffuse, emissive and specular color (plus specular power as “shininess”)
- supports only diffuse textures, Cheetah3D api is realy sparse on that
That’s it for first version, more features will come over time. Don’t hesitate to review my code as I really suck at javascript. That said, Cheetah3D’s api has got to be the worst thing in the world, including documentation that’s at least 2 years old (Material class method rib() doesn’t exist and is still documented), properties that don’t even exist and the most random descriptions I’ve had the displeasure to see in a documentation. If you ever do an export script for Cheetah3D : uvCoord() method on the PolyCore class returns a 4D vector combining first UV (x,y) with second UV (z,w). That took me forever to find out even though it seems simple.
Regarding licence, this script is under WTFPL :
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
To resume :
- Grab my script on Github
- Check out Cheetah3D if you don’t know about it
- Learn about Babylon.JS and why it’s awesome
- Drop me a bitcoin for beer related duties : 1Fxh5JYjPUryghwCfuYnWqDQTaucdV4kzs
Anyways, enjoy, feedback pls. Protip : don’t go loading your 60 million polygons models into Babylon.JS, chances are your browser will create a singularity.
Have fun, code safe.
Tuxic