Lighting and shading with Papervision 3D
Page 2
Open Flash and create a new Flash File (Actionscript 3.0).
Select frame 1 in the timeline and open the Actions Panel (Window-Actions or F9).
Import the basic Papervision 3D Classes that set up a 3D scene and all the necessary constituent parts.
import org.papervision3d.cameras.Camera3D; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.scenes.Scene3D; import org.papervision3d.view.Viewport3D;
Import the classes for creating primitive shapes.
import org.papervision3d.objects.primitives.*;
Import the classes that deal with materials (textures that cover a 3D model).
import org.papervision3d.materials.*;
import org.papervision3d.materials.special.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.core.proto.MaterialObject3D;
Import the classes for creating a point light (a light emanating from a single point).
import org.papervision3d.lights.PointLight3D;
Import the classes for dealing with shading. Papervision 3D offers different types of shading - you need only import the type you are going to use, but in this case we'll import all of them.
import org.papervision3d.materials.shadematerials.CellMaterial; import org.papervision3d.materials.shadematerials.FlatShadeMaterial; import org.papervision3d.materials.shadematerials.GouraudMaterial; import org.papervision3d.materials.shadematerials.PhongMaterial;
Next, create instances of all the basic elements required for a 3D scene, and set up the stage.
var viewport:Viewport3D=new Viewport3D(stage.stageWidth,stage.stageHeight); var scene:Scene3D = new Scene3D(); var camera:Camera3D = new Camera3D(); var renderer:BasicRenderEngine = new BasicRenderEngine();
stage.scaleMode="showAll";
Now that all the basic components have been set up we can proceed with creating the objects in the scene.
