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):
-
/**
-
* @author Matt Przybylski [http://www.reintroducing.com]
-
* @version 1.0
-
*/
-
-
package com.reintroducing
-
{
-
import flash.display.Sprite;
-
import flash.events.Event;
-
-
import org.papervision3d.cameras.Camera3D;
-
import org.papervision3d.render.BasicRenderEngine;
-
import org.papervision3d.scenes.Scene3D;
-
import org.papervision3d.view.Viewport3D;
-
-
public class Papervision extends Sprite
-
{
-
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
-
-
private var _viewport:Viewport3D;
-
private var _scene:Scene3D;
-
private var _camera:Camera3D;
-
private var _renderer:BasicRenderEngine;
-
-
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
-
-
-
-
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
-
-
public function Papervision():void
-
{
-
this.init();
-
}
-
-
//- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
-
-
/**
-
*
-
*/
-
private function init():void
-
{
-
this.initPapervision();
-
this.initObjects();
-
this.initListeners();
-
}
-
-
/**
-
*
-
*/
-
private function initPapervision():void
-
{
-
this._viewport = new Viewport3D();
-
this._scene = new Scene3D();
-
this._camera = new Camera3D();
-
this._renderer = new BasicRenderEngine();
-
-
this.addChild(this._viewport);
-
}
-
-
/**
-
*
-
*/
-
private function initObjects():void
-
{
-
// init scene objects here
-
}
-
-
/**
-
*
-
*/
-
private function initListeners():void
-
{
-
this.addEventListener(Event.ENTER_FRAME, render);
-
}
-
-
/**
-
*
-
*/
-
private function render($evt:Event):void
-
{
-
// animation code goes here
-
-
this._renderer.renderScene(this._scene, this._camera, this._viewport);
-
}
-
-
//- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
-
-
-
-
//- EVENT HANDLERS ----------------------------------------------------------------------------------------
-
-
-
-
//- GETTERS & SETTERS -------------------------------------------------------------------------------------
-
-
-
-
//- HELPERS -----------------------------------------------------------------------------------------------
-
-
override public function toString():String
-
{
-
return "com.reintroducing.Papervision";
-
}
-
-
//- END CLASS ---------------------------------------------------------------------------------------------
-
}
-
}
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
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.











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