In previous post I describe easy steps to simply setup Flashdevelop.
Now let’s setup papervision3D in Flashdevelop.
- Download and install TortoiseSVN source control from
http://tortoisesvn.net/downloads.You have to restart your computer after installation.
- Create folder in your hard drive for papervsion3D source, for example “PV3D”, right click to folder >> SVN Checkout.
Go to Papervision3D google code page:
http://code.google.com/p/papervision3d/ >> source.
Copy the SVN checkout address: http://papervision3d.googlecode.com/svn/trunk/.
Back to the SVN checkout window u have opened, paste the address above in top(url of repository), click ok. - Once you finish download, open “PV3D” folder >> branches >> cs4 >> src >> select all files and folders(CTRL+A) >> drag them with right mouse button pressed to your library folder where you keep all external class libraries. If you don’t have one, you can create new folder, mine is: “C:\Library\Flash\pv3d\”. Once you drop them inside your library, from the menu choose: “SVN Export to here”.
- Open FlashDevelop, Project >> new project >> as3 project
Name it pv3dexample, open project properties (right click on project name in project panel >> properties).
Output: choose dimensions: 400x400, background color white, framerate 30.
Classpaths: add Classpath >> choose your library folder where u copy papaervision3D source(In my case it’s C:\Library\Flash\pv3d).
Compiler options: Allow source path overlap >> true
You are ready to use Papervision3D library inside your project.
We attach the library for the specific project, if you want to have in all your projects inside flashdevelop we have to add it in global classpath.
Tools >> global classpaths >> add classpath >> choose your library.
Copy the code to the Main.as Class, save and run the project. You should see red rotating cube .
Actionscript:
-
package
-
{
-
import flash.display.Sprite;
-
import flash.events.Event;
-
import org.papervision3d.materials.special.CompositeMaterial;
-
import org.papervision3d.view.Viewport3D;
-
import org.papervision3d.scenes.Scene3D;
-
import org.papervision3d.cameras.Camera3D;
-
import org.papervision3d.materials.ColorMaterial;
-
import org.papervision3d.materials.WireframeMaterial;
-
import org.papervision3d.materials.utils.MaterialsList;
-
import org.papervision3d.objects.primitives.Cube;
-
import org.papervision3d.render.BasicRenderEngine;
-
/**
-
* ...
-
* @author Armen Abrahamyan
-
*/
-
public class Main extends Sprite
-
{
-
private var viewport: Viewport3D;
-
private var scene: Scene3D;
-
private var camera: Camera3D;
-
private var colmaterial: ColorMaterial;
-
private var wiremateral: WireframeMaterial;
-
private var compmaterial: CompositeMaterial;
-
private var primitive: Cube;
-
private var renderer: BasicRenderEngine;
-
public function Main():void
-
{
-
if (stage) init();
-
else addEventListener(Event.ADDED_TO_STAGE, init);
-
}
-
-
private function init(e:Event = null):void
-
{
-
removeEventListener(Event.ADDED_TO_STAGE, init);
-
// entry point
-
init3D();
-
}
-
private function init3D():void
-
{
-
trace("init3D")
-
viewport = new Viewport3D(400, 400, false, true);
-
addChild(viewport);
-
scene = new Scene3D();
-
camera = new Camera3D();
-
renderer = new BasicRenderEngine();
-
colmaterial = new ColorMaterial(0xff0000);
-
wiremateral = new WireframeMaterial(0xffffff);
-
compmaterial = new CompositeMaterial();
-
compmaterial.addMaterial(colmaterial);
-
compmaterial.addMaterial(wiremateral);
-
var materiallist:MaterialsList = new MaterialsList();
-
materiallist.addMaterial(compmaterial, "front");
-
materiallist.addMaterial(compmaterial, "back");
-
materiallist.addMaterial(compmaterial, "left");
-
materiallist.addMaterial(compmaterial, "right");
-
materiallist.addMaterial(compmaterial, "top");
-
materiallist.addMaterial(compmaterial, "bottom");
-
primitive = new Cube(materiallist, 200, 200, 200, 3, 3, 3);
-
scene.addChild(primitive);
-
addEventListener(Event.ENTER_FRAME, onEnterFrameHandler,false,0,true);
-
}
-
private function onEnterFrameHandler(e:Event):void
-
{
-
primitive.rotationY += 2;
-
primitive.rotationX += 2;
-
primitive.rotationZ += 2;
-
renderer.renderScene(scene, camera, viewport);
-
}
-
}
-
-
}
Hello,
Thank you for this good tutorial!!
great job , keep on…
Thanks a lot, this tutorial was much more straightforward and effective than the others out their.
Isn’t working for me. Not sure what I did wrong.
Hi, can you publish a video about the set up. i follow your instruction, then also it is not working. i do not know where I am doing mistake. please add a video to this blog post.
Thanks.