This is my first Papervision3D. I am starting to learn papervision3d. Download the source if you want to start with Papervision3D:
Uh! sorry Blogger not allow to upload . so please let view the very summary code as below:
package
{
import flash.display.Bitmap;
import flash.display.GradientType;
import flash.display.Graphics;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Matrix;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.MovieMaterial;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.view.BasicView;
import AssetManager;
/**
* ...
* @author Ratha
*/
public class Main extends BasicView
{
private var plane:Plane;
public function Main():void
{
super(640, 480);
gradBg();
var mc1:MovieClip = new MovieClip;
var imgClass:Class = AssetManager.MyImg;
var img:Bitmap = new imgClass as Bitmap;
img.smoothing = true;
mc1.addChild(img);
var mat:MovieMaterial = new MovieMaterial(mc1, true, true, true);
mat.smooth = true;
mat.doubleSided = true;
plane = new Plane(mat, 351, 487, 4, 4);
scene.addChild(plane);
camera.zoom = 100;
startRendering();
addEventListener(Event.ENTER_FRAME, makeItMove);
}
private function gradBg():void
{
var g:Graphics = this.graphics;
var gMat:Matrix = new Matrix;
gMat.createGradientBox(this.width, this.height, ( -90 * Math.PI/180)) ;
g.beginGradientFill(GradientType.LINEAR, [0x000000, 0xffffff], [100, 100], [0, 255], gMat);
g.drawRect(0, 0, this.width, this.height);
g.endFill();
}
private function makeItMove(evt:Event):void
{
plane.rotationY += 2;
}
private function init(e:Event = null):void
{
}
}
}
Uh! sorry Blogger not allow to upload . so please let view the very summary code as below:
package
{
import flash.display.Bitmap;
import flash.display.GradientType;
import flash.display.Graphics;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Matrix;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.MovieMaterial;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.view.BasicView;
import AssetManager;
/**
* ...
* @author Ratha
*/
public class Main extends BasicView
{
private var plane:Plane;
public function Main():void
{
super(640, 480);
gradBg();
var mc1:MovieClip = new MovieClip;
var imgClass:Class = AssetManager.MyImg;
var img:Bitmap = new imgClass as Bitmap;
img.smoothing = true;
mc1.addChild(img);
var mat:MovieMaterial = new MovieMaterial(mc1, true, true, true);
mat.smooth = true;
mat.doubleSided = true;
plane = new Plane(mat, 351, 487, 4, 4);
scene.addChild(plane);
camera.zoom = 100;
startRendering();
addEventListener(Event.ENTER_FRAME, makeItMove);
}
private function gradBg():void
{
var g:Graphics = this.graphics;
var gMat:Matrix = new Matrix;
gMat.createGradientBox(this.width, this.height, ( -90 * Math.PI/180)) ;
g.beginGradientFill(GradientType.LINEAR, [0x000000, 0xffffff], [100, 100], [0, 255], gMat);
g.drawRect(0, 0, this.width, this.height);
g.endFill();
}
private function makeItMove(evt:Event):void
{
plane.rotationY += 2;
}
private function init(e:Event = null):void
{
}
}
}