Talking about Actionscript 3 and Flash.
You should all know Papervision3D, one of the best open source 3D engine for the Flash platform.
The biggest problem with this library, in my opinion, is the lack of basics tutorials explaining how does it work.
Just like what’s happening with Box2D, this is scaring a lot of developers because they just think it’s impossible to make it work.
This is a very basic tutorials, for the absolute beginners, that will explain how to download, install and make Papervision3D work.
First, you will find the last version of the library at http://code.google.com/p/papervision3d/.
We are going to create a Flash project, so download the zip file and not the swc one.
Unzip the org
folder: it’s the one containing all needed files.
Then you just have to create your fla
file in the same folder that contains the org
folder you just unzipped.
Then let’s create the “hello world” of Papervision3D
package {
import flash.display.Sprite;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;
import org.papervision3d.objects.primitives.Plane;
public class papervision extends Sprite {
public var viewport:Viewport3D = new Viewport3D();
public var scene:Scene3D = new Scene3D();
public var camera:Camera3D = new Camera3D();
public var renderer:BasicRenderEngine = new BasicRenderEngine();
public var plane:Plane = new Plane();
public function papervision() {
addChild(viewport);
scene.addChild(plane);
renderer.renderScene(scene, camera, viewport);
}
}
}
Now, let’s look at a Papervision3D project as a movie
Lines 2-7: importing necessary libraries
Line 9: creating a Viewport3D
variable. Think about it as a nice cinema screen where you see what happens into the world of Papervision3D. The movie will start in a minute, just grab some junk food and a can of cola.
Line 10: creating a Scene3D
variable. This is the world itself… so now you have a world and a screen to see what happens into the world
Line 11: creating a Camera3D
variable. Like in a movie, the camera sees what happens in the world, and shows it on the screen
Line 12: creating a BasicRenderEngine
variable. This is the “action” command the director gives when he wants te camera to capture the action
Line 13: creating a Plane
variable. A default plane is our first and only actor
Line 15: adding the viewport to the stage
Line 16: adding the plane to the scene
Line 17: render the scene
And this the amazing result :)
Download the source code with all needed libraries.
Never miss an update! Subscribe, and I will bother you by email only when a new game or full source code comes out.