Papervision3D 2.0 Released – Great White

New branch in the googlecode repo: http://papervision3d.googlecode.com/svn/trunk/branches/GreatWhite/

Well, if you’re into 3D and haven’t heard the buzz about Papervision3D 2.0, you’ve probably been under a rock or working for an agency on a 6 week deadline in a room with blacked out windows. We’ve all waited for this release with much anticipation and it’s been a long wait, but that wait is FINALLY over!

Ralph and Tim have been cracking away at 2.0 and putting in amazing amounts of hours to do so – these guys haven’t slept much, so give em’ a break if you find bugs with the alpha release. This is the first alpha release PV3D has had and we’re hoping the community rallies around it and helps to test and improve the code base.

What’s new? Glad you asked.

  • Shaders,shaded materials
  • phong, flat, cell, gouraud shading
  • bumpmaping
  • Viewport3D
  • BasicRenderEngine
  • Adoption of ASCollada with DAE object
  • MD2 support
  • Frustrum Camera
  • re-write of render loop – now there’s render lists centeralized in the RenderEngine
  • refactored and greatly improved InteractiveSceneManager(ISM) – much faster

upgrading current projects:

If you’re going to try 2.0 with your latest project, you need to be aware of a couple of things:

1. Setting up the initial scene is different – in a good way :) You no longer create a sprite container to pass to Scene3D, nor do you pass a boolean value for interactivity to Scene3D. Viewport3D extends Sprite, and includes the ability to do:

  • auto resizing/centering
  • interactivity
  • autoClipping
  • autoCulling

[as]var viewport:Viewport3D = new Viewport3D(0, 0, true, false);
addChild(viewport);

var renderer:BasicRenderEngine = new BasicRenderEngine();

var scene:Scene3D = new Scene3D();
var camera:FreeCamera3D = new FreeCamera3D();[/as]

Then, when you want to render:

[as]renderer.renderScene(scene, camera, viewport);[/as]

The new Viewport3D really opens up the doors to do cool things like BitmapViewportMaterial – think of using a camera’s view as a material ;)

[as]public function Viewport3D(viewportWidth:Number = 640, viewportHeight:Number = 480, autoScaleToStage:Boolean = false, interactive:Boolean = false, autoClipping:Boolean = true, autoCulling:Boolean = true)[/as]

2. The engine’s been refactored a bit and so you’ll have to go through and update your imports. Most notably, Objects have moved.

3. No more precision materials. Now all materials have a “precise” boolean. Just set it to true if you need precision.

[as]metalicBoxMaterial = new BitmapMaterial(boxTextureBitmap.bitmapData);
metalicBoxMaterial.precise = true;[/as]

Using shaders
[as]// create your light
var pointLight:PointLight3D = new PointLight3D();
pointLight.moveUp(350);
pointLight.moveRight(350);

// create your materials
var earthMaterial:MovieAssetMaterial = new MovieAssetMaterial(“earthMap”);
var earthBumpMaterial:MovieAssetMaterial = new MovieAssetMaterial(“earthMapBump2″);
// create shader
var earthShader:PhongShader = new PhongShader(pointLight, 0xFFFFFF,0×303030,20, earthBumpMaterial.bitmap, earthMaterial.bitmap);
// combine shader with original material, for a shaded material
var earthShadedMaterial:ShadedMaterial = new ShadedMaterial(earthMaterial, earthShader);
// add to sphere
var earth:Sphere = new Sphere(earthShadedMaterial, 250, 12, 12);

scene.addChild(earth);[/as]

I hope this helps the learning curve for 2.0! I’ll try and get the benchmark for 2.0 out there, but initially, an older revision of it was 23% faster than 1.9 Phunky!