Papervision3D FDT3 Template

After writing about Eclipse/FDT3/Papervision3D and my heavy usage of templates to speed up my workflow, the natural thing to do was to create a Papervision3D template to use in conjunction with FDT3. You can grab the template from the Downloads page at any time (if I update it in the future, the newest version will be there with a note on when it was updated) or by clicking here.

To install, just open up Eclipse and go to Window → Preferences → FDT → Editor → Templates. Click on Import and navigate to the XML file that is extracted. To use, press Ctrl+Space and type in pv3d and hit Enter. The template will show up like magic in your class!

For those that don't use Eclipse/FDT, you can see the class here (although you should really start using those tools):

Actionscript:
  1. /**
  2. * @author Matt Przybylski [http://www.reintroducing.com]
  3. * @version 1.0
  4. */
  5.  
  6. package com.reintroducing
  7. {
  8.     import flash.display.Sprite;
  9.     import flash.events.Event;
  10.    
  11.     import org.papervision3d.cameras.Camera3D;
  12.     import org.papervision3d.render.BasicRenderEngine;
  13.     import org.papervision3d.scenes.Scene3D;
  14.     import org.papervision3d.view.Viewport3D;
  15.    
  16.     public class Papervision extends Sprite
  17.     {
  18. //- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
  19.  
  20.         private var _viewport:Viewport3D;
  21.         private var _scene:Scene3D;
  22.         private var _camera:Camera3D;
  23.         private var _renderer:BasicRenderEngine;
  24.        
  25. //- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
  26.        
  27.        
  28.        
  29. //- CONSTRUCTOR -------------------------------------------------------------------------------------------
  30.    
  31.         public function Papervision():void
  32.         {
  33.             this.init();
  34.         }
  35.        
  36. //- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
  37.        
  38.         /**
  39.          *
  40.          */
  41.         private function init():void
  42.         {
  43.             this.initPapervision();
  44.             this.initObjects();
  45.             this.initListeners();
  46.         }
  47.        
  48.         /**
  49.          *
  50.          */
  51.         private function initPapervision():void
  52.         {
  53.             this._viewport = new Viewport3D();
  54.             this._scene = new Scene3D();
  55.             this._camera = new Camera3D();
  56.             this._renderer = new BasicRenderEngine();
  57.            
  58.             this.addChild(this._viewport);
  59.         }
  60.        
  61.         /**
  62.          *
  63.          */
  64.         private function initObjects():void
  65.         {
  66.             // init scene objects here
  67.         }
  68.        
  69.         /**
  70.          *
  71.          */
  72.         private function initListeners():void
  73.         {
  74.             this.addEventListener(Event.ENTER_FRAME, render);
  75.         }
  76.        
  77.         /**
  78.          *
  79.          */
  80.         private function render($evt:Event):void
  81.         {
  82.             // animation code goes here
  83.            
  84.             this._renderer.renderScene(this._scene, this._camera, this._viewport);
  85.         }
  86.        
  87. //- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
  88.    
  89.        
  90.    
  91. //- EVENT HANDLERS ----------------------------------------------------------------------------------------
  92.    
  93.        
  94.    
  95. //- GETTERS & SETTERS -------------------------------------------------------------------------------------
  96.    
  97.        
  98.    
  99. //- HELPERS -----------------------------------------------------------------------------------------------
  100.    
  101.         override public function toString():String
  102.         {
  103.             return "com.reintroducing.Papervision";
  104.         }
  105.    
  106. //- END CLASS ---------------------------------------------------------------------------------------------
  107.     }
  108. }

Obviously you'll need to edit the package declaration manually (another advantage of using Eclipse/FDT templates) so that you don't get any errors.

If you found this post useful, please consider leaving a comment, subscribing to the feed, or making a small donation.

4 Comments

I'm starting to think you're on the Powerflasher payroll. Just kidding, of course. Which edition of FDT do you use?

haha, they probably should be paying me at this point 😛

I'm using FDT3 Pro.

Just a heads up: pv3d includes a template class, "org.papervision3d.view.BasicView", which we use a lot for training, workshops, etc. Just subclass that puppy and you'll have all of the main functionality ready to roll.

Hey John,
Absolutely, I realized that as well after the fact, but I do like having a template setup in FDT that does this as well. I use templates for a lot of things so this is good to have. Thanks, though.

Leave a comment

(required)

(required)