If you haven’t yet seen it, VizualPV3D is the excellent GUI interface from Juxt Interactive for creating 3D scenes using Papervision3D. It’s currently in alpha, but definitely worth checking out as it already has loads of great features and makes creating complex 3D scenes in Flash very easy indeed.
Having played around with the program for a while I then wanted to import the scenes I’d created into a new AS3 project but couldn’t find any classes included to do that. I think these features may be added in a future version, but for now I wanted something simple and reusable to try and get the geometry and materials of the scene imported quickly, so I wrote a basic class to do just that.
The class is called VizualPV3DLoader and currently supports the following: basic primitive shapes (cube, cylinder, cone, sphere and plane), basic materials (wireframe, flatshade, cellshade, gourad and phong), external BitmapAssetMaterial’s, positioning elements in the 3d scene and grouping elements together within empty DisplayObject3D containers.
The class itself extends DisplayObject3D, so you can add it straight into your main scene. From there you can access all the groups and objects in it by name. I’m looking at adding in a few more features in the future, including: more materials, text3D support and maybe event integration with a physics library.
Usage is fairly easy…
//include the class import me.pv3d.VizualPV3DLoader; //elsewhere add it to your papervision3d scene var vLoader:VizualPV3DLoader = new VizualPV3DLoader('assets/', light); vLoader.load('scene.xml'); scene.addChild(vLoader);
The constructor takes a couple of parameters, the first is for the assets directory (where your external textures are stored) and the second is for an instance of PointLight3D for use with any shaded materials. You can also add a listener for a VizualPV3DEvent.SCENE_READY event, which might be useful if its a really complex scene that takes a while to process.
Below is a screen grab of a simple demo I made with the class and a link to view the demo and download the source code, maybe someone will find it useful.