Papervision3D
Papervision 3D: Great White and MD2
by Brian Hodge on Feb.27, 2009, under Papervision3D
The studio that I am working at, Streetwise, has had me checking out the various 3D engines available to Actionscript3. I played with Papervision3D first and was immediately disappointed with the lack of tutorials. I then moved onto Away3D because it appeared to have an abundance of tutorials all delivered on an easy to navigate, well constructed website. After a few projects in Away3D it became apparent to me that Away3D is a “PORT” of Papervision3D, meaning it borrows from, or ” EXTENDS”, from Papervision3D. After asking some other developers on stackoverflow.com, I came to the conclusion that I needed to give Papervision3D another shot. Thanks to google, I found more tutorials and a strong backing behind Papervision3D. When I was looking around at was being done out there, I stumbled upon http://www.saveyoursensible.com, a neat little site that utilizes a 3D character that you can interact with. I was reading somewhere where people were discussing this mixture of Papervision3D and an md2 for light-wieght, low poly, character animations. I found a quake model that I like, downloaded the md2 and used the following to produce it in the flash runtime. The following shows how to render and md2 in the flash runtime using the Papervision3D API.
-
- package com.streetwise.ui
- {
- import org.papervision3d.view.Viewport3D;
- import org.papervision3d.scenes.Scene3D;
- import org.papervision3d.cameras.Camera3D;
- import org.papervision3d.events.FileLoadEvent;
- import org.papervision3d.materials.BitmapFileMaterial;
- import org.papervision3d.objects.parsers.MD2;
- import org.papervision3d.render.BasicRenderEngine;
- {
- private var viewport:Viewport3D;
- private var scene:Scene3D;
- private var camera:Camera3D;
- private var _quakeGuy:MD2;
- private var renderer:BasicRenderEngine;
- public function Main():void
- {
- if(stage) init();
- }
- {
- viewport = new Viewport3D(550, 400, false, true);
- addChild(viewport);
- scene = new Scene3D();
- camera = new Camera3D();
- renderer = new BasicRenderEngine();
- camera.zoom = 400;
- camera.focus = 12;
- _quakeGuy = new MD2(false);
- _quakeGuy.rotationX = -90;
- _quakeGuy.rotationY = -90;
- _quakeGuy.addEventListener( FileLoadEvent.ANIMATIONS_COMPLETE, onAnimationsComplete );
- _quakeGuy.load("assets/quakeguy/tris.md2 " , new BitmapFileMaterial("assets/quakeguy/quake.png"));
- scene.addChild( _quakeGuy );
- }
- private function onAnimationsComplete( event:FileLoadEvent ) : void
- {
- _quakeGuy.play();
- }
- {
- renderer.renderScene(scene, camera, viewport);
- }
- }
- }
It is important to try things, play with functionality, learn how to dig into the docs make something new. The more you experiment, the better you get at experimenting. I was in no way the first to do this, but I now have a great understanding.
The next step is to purchase QTiP, a plugin for 3D Studio Max, which enables you to create your own md2 files complete with animation. This is how the developers of the sensibles project above achieved their goal.