Tag Archive for 'Papervision'

Papervision3D, FlashDevelop template

Flashdevelop Here’s a simple FlashDevelop template to speed up the creation of a 3D render in Papervision3D 2.0. Download the template from here or copy the code below and save it as View3D.as.fdt.

In FlashDevelop go to Tools –> Application files. This will open your Explorer: Now go into the folder Templates > ProjectFiles > AS3Project and drop the template in there.

You will now if you left click on your src package and go to Add > see the option ‘BasicView’ in the menu that pops up.

The custom arguments available for template creation are listed at http://www.flashdevelop.org/community/viewtopic.php?t=1521

Here’s the template:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package $(Package) $(CSLB){

   import flash.events.Event;
   import org.papervision3d.view.BasicView;

   public class $(FileName) extends BasicView {
      $(EntryPoint)
      /**
      * $(FileName)
      */

     
      public function $(FileName)():void {
         init();
         startRendering();
      }

      private function init():void {
      }
     
      override protected function onRenderTick(e:Event=null):void{
         super.onRenderTick();
      }
   
   }
}

Lastly, a good set of templates can be found over at http://www.actionscriptdeveloper.co.uk/puremvc-first-thoughts-flashdevelop-templates/

Papervision3D, interactive material

With the aid of the Papervision3D class org.papervision3d.events.InteractiveScene3DEvent it’s easy to create an interactive papervision 3D primitive such as this Cube (click on it’s sides):


Get Adobe Flash player

The cube uses the BitmapMaterial class (the sides are embedded jpg’s) and all we need to do to make them interactive is to remember to set interactive to true:

1
2
bitmapMaterial6.name = "6";
bitmapMaterial6.interactive = true;

Once we created our cube the last bit is just to add the event listener to the InteractiveScene3DEvent which is dispatched by the Cube. And we can use the event property evt.face3d.material.name of the current material side clicked to retrieve the name of the same:

1
2
3
4
5
6
7
// create a cube based on the list
primitive = new Cube(materiallist, 400, 400, 400, 3, 3, 3);
primitive.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, handleClick);
//.../
private function handleClick (evt:InteractiveScene3DEvent) :void {
testText.text = "__side clicked : " +evt.face3d.material.name;
}

The InteractiveScene3DEvent is not limited to click events however, the documentation at http://papervision3d.googlecode.com/svn/trunk/as3/trunk/docs/org/papervision3d/events/InteractiveScene3DEvent.html – shows that we can also listen for MOVE, OVER, OUT, etc. Nice.

If you would like to get hold of the full code for this example then you can download it here (Flashdevelop project).

Theres some great Papervision tutorials over at http://www.madvertices.com where I’ve taken several myself!