Animated Models: Blender to PV3D
June 30th, 2008 . Posted by brad in Blender, Cast3D, Papervision3DSome thoughts on the Blender/Papervision3d workflow, collada and Cast3d.
Blender’s collada (.dae) exporter does a great job of exporting mesh data for static models, but it stops playing nicely with PV3D as soon as you export keyframed animation or bone data. The great news is that Tim Knip, the man behind PV3D’s dae parser, is planning to add a blender flag to the parser, to remedy this.
Another great open-source 3d library for bringing animated models into PV3D, is Cast3D which has features like support for sound, animation controls & more. Brilliant!
Cast3d has it’s own lightweight xml format (.x3c) with a command line converter which builds .x3c files from studio max files (.3ds) . Again, blenders exporters prove a little buggy as the blender script exports 3ds files without the node info required by the cast3d converter.
Fortunately, Cast3D’s creator, Dmitri Sviridov, is working on a .dae to .x3c converter which he tells me will also work with blender .dae files! It’s well worth checking the cast3d site to check out it’s great animation support, but here’s a simple unanimated example for cast3d/pv3d 2.0.
(Since I can’t export models from blender to a usable .3ds, I downloaded a cool little model from Turbosquid for this post.)
Setting up Cast3D for Papervision 3d 2.0:
Cast3d is designed for use with a number of 3d engines so you may need to make some very minor tweaks to get it working with PV3D v2.0.
1) Open cast3d/core/Source3d.as
- a) Uncomment import cast3d.geom.ppv2.*;
- b) Make sure import statements for other 3d engines are commented out
2) Open cast3d/loader/Xc3loader.as:
- a) Uncomment import cast3d.loader.ppv2.Xc3PortLoader;
- b) Make sure import statements for other 3d engines are commented out
3) It should be working fine after the previous changes, but if not, try removing the Sandy3d, Away3d and older papervision folders:
- a) In the cast3d/geom folder, removed away3d, ppv3d and sandy3d folders
- b) In cast3d/loader folder, remove ppv3d and sandy3d folders.
Preparing Your Model:
You’ll need to use the command line converter to create .x3c file from the .3ds file. Launch command line prompt, navigate to the directory with the .3ds file and use the converter as follows.
C:\Buggy\3ds2XML buggy.3ds buggy.x3c
Now you’re ready to write some code.
Create a cast3d object:
var animator:Cast3d = new Cast3d(scene, camera);
Create an X3CLoader to load model:
var loader:X3CLoader = new Xc3Loader("models/buggy/buggy.x3c");
loader.resourcePath = "models/buggy/data";
loader.addEventListener(LoadEvent.LOAD_COMPLETE, cast3dLoadComplete);
loader.addEventListener(LoadEvent.LOAD_ERROR, cast3dLoadError);
loader.load(animator.source);
Create a Trackball Object to allow rotation of the model. (This class also ensures the camera always points at your model)
var manipulator:Trackball = new TrackBall(animator, stage, view.viewportWidth, view.viewportHeight, Manipulator.Z_UP, Manipulator.X_S,Manipulator.Z_S,Manipulator.Y_S );
Last you need to perform a cast3d render before rendering your PV3D scene.
animator.render(); render.renderScene(scene, camera, view);
And the result.

Nice!
Source
Complete project (fla, swf, source and model).
Links:
http://cast3d.org