Posts Tagged ‘PV3D’

This is an example video, of what can be achieved using basic Papervision and Actionscript Code.

All the tutorials on this website will help you to create something like what you see below, if you are not satisfied, or need clarification or help feel free to post a comment, and i will get back to you!
Bare in mind, this video is just an example, and is not complete (i.e some bugs exist, such as inverted textures..)

Papervision 3D Example from Thierry

When creating models/importing models into flash, and testing code in run time etc, sometimes it is very usefull to have Statistics displayed on the runtime page, to see how well your program is running, any memory leaks etc..

This however is very easy to set up in Papervision3D.
First you need to import StatView:
import org.papervision3d.view.stats.StatsView;

If you have employed BasicView for your scene setup, add

private var view:StatsView;

in your class, and then call it using:

addChild(new StatsView(renderer));

Thats it! very simple, you should end up with something looking like this in your window

  • Try and keep your models as simple as possible without loosing much on detail (obviously some sacrifices have to be made).
  • When exporting to a DAE file, try and use a model that is newly made, rather than editing one that is already textured and in a scene with other objects.
  • DO NOT, texture your objects, until you are ready to add your UVW map, this will avoid confusion in the DAE, where max has exported the files, with paths to textures that you no longer use, this will throw errors when testing movie in Actionscript.
  • Having a clean model, with few gemoetries and one UVW map will help reduce complications and errors in the long run – trust me, im speaking from experiance! :)
  • .DAE files, can be opened in Notepad, and edited – do not edit if you are unsure of what to do, you may end up corrupting your file, and having to re-export.
  • Notepad2, is a lot better than Notepad – with syntax highliting and numbered lines, get it here, its free!

If you have any tips you would like to add, please feel free to leave them in the comments! :)

This tutorial is designed for Flash Actionscript 3.0 with PV3D 2.0 (GreatWhite) repositries..

Before you begin, please make sure that you have downloaded the necessary PV3D repositries
from the SVN. [if you dont know how to this, then please check step 1 AND step 4 in this tutorial]

If you have already done this then please read on!

first off, we will create an empty .FLA file (this will allow us to read the .as file we will make
and will help us run it!)

File > New (ctrl+N)
select Flash File (Actionscript3) and click ok.
Now save that under whatever name you like.

Now we need to create an Actionscript file (.as)
File > new (Ctrl+N)
select Actionscript File and click ok.
Now save this using whatever name you like – I will call it

It is in this file where we will write our code. but first we need to link
it to the .FLA file we made earlier.
click on the tab to open your .FLA file and look near the bottom of your screen, in the
properties tab, for something called Document Class in the text box to the right of it, enter
your .as file name – in this case example and click on the little pencil icon to scan for the file.

now that the files are linked we can compile and run our actionscript when we need to test
out our video.

now for the code – put this in you .as file:

import org.papervision3d.objects.primitives.*;
import org.papervision3d.view.BasicView;
import org.papervision3d.materials.WireframeMaterial;
import org.papervision3d.materials.utils.MaterialsList;
//For importing objects
import org.papervision3d.objects.parsers.DAE;
import org.papervision3d.objects.DisplayObject3D;

 [SWF(width="640", height="320", backgroundColor="#000000", frameRate="60")]

 public class Example extends BasicView {
//private var myMaterials:Object;

     public function Example()
var sphere:Sphere = new Sphere();
sphere.x = 150;
//text output in debuger window to see if code
//is going through loop
trace("DRAW sphere");

var plane:Plane = new Plane();
plane.x = -150;
trace("DRAW plane");

var cylinder:Cylinder = new Cylinder();
trace("DRAW cylinder");


Now to test what we have written, press ctrl+enter key and wait for the results!

For a 3D cube, add the following code, before “startRendering()”

//FOR 3D CUBE   //code for material - more will  be covered on this later
var frontMaterial:WireframeMaterial = new WireframeMaterial();
var backMaterial:WireframeMaterial = new WireframeMaterial();
var leftMaterial:WireframeMaterial = new WireframeMaterial();
var rightMaterial:WireframeMaterial = new WireframeMaterial();
var topMaterial:WireframeMaterial = new WireframeMaterial();
var bottomMaterial:WireframeMaterial = new WireframeMaterial();

var materialsList:MaterialsList = new MaterialsList();

materialsList.addMaterial(frontMaterial, "front");
materialsList.addMaterial(backMaterial, "back");
materialsList.addMaterial(leftMaterial, "left");
materialsList.addMaterial(rightMaterial, "right");
materialsList.addMaterial(topMaterial, "top");
materialsList.addMaterial(bottomMaterial, "bottom");

var cube:Cube = new Cube(materialsList);
//cube.x = 100;
//need to rotate cube, otherwise it will look like a Plane.
cube.rotationY = 45;
cube.rotationX = 45;
//END 3D Cube

A tutorial for loading in 3D objects made in a 3D package such as Max can be found here

subscribe to this blog, and you will be notified as soon as the post is made!

This is soo cool, every PV3D developer should have one!

Follow the link:
Follow me on Twitter
free counters
PayPal Donation
If you like this blog and the help it has given you, why not donate for this good cause? Click on the button below to pay Safely and Securely through PayPal.