Using Papervision Object Parsers

DAE Parser

What is a DAE file?

Yes, I know I just explained that Collada uses DAE. Well the DAE parser also loads Collada files. Just a different version (v. 1.4.1). These are good files to use if you would like to import assets that include animations.

DAE Parsing Example

package {
	import org.papervision3d.lights.PointLight3D;
	import org.papervision3d.materials.shadematerials.GouraudMaterial;
	import org.papervision3d.materials.utils.MaterialsList;
	import org.papervision3d.objects.parsers.DAE;
	import org.papervision3d.view.BasicView;

	public class DaeParser_v1 extends BasicView {
		// create a class-level var for the collada scene
		private var _dae:DAE;
		// create the light
		private var _light:PointLight3D;

		public function DaeParser_v1() {

		private function lights():void {
			// create the light to the scene
			_light = new PointLight3D(true, true);
			// place it in the same position as the camera (0, 0, -1000);

		private function init3d():void {
			// create a materials list and add the wireframe material
			var knotMaterialsList:MaterialsList = new MaterialsList();
			// we are now going to use a gouraud material for shading
			var knotMaterial:GouraudMaterial = new GouraudMaterial(_light);
			knotMaterialsList.addMaterial(knotMaterial, "all");
			// instantiate the DAE obj and load the knot object
			// apply the material and scale to 0.05
			_dae = new DAE();
			_dae.load("assets/knot2.dae", knotMaterialsList);
			_dae.scale = 5;
			// add the DAE file to the scene
			// start rendering (activated onRenderTick)

		override protected function onRenderTick(event:Event = null):void {
			// rotate the object

Parsing a DAE file is much like parsing an Collada file. The only real difference is when certain properties have to be set. The constructor for the DAE file allows for different commands because this file is meant more for animated 3d objects (it takes autoplay, name, and loop).

To accommodate for this, I just left the constructor blank and set the scale. I also moved the loading until after the DAE parser object was instantiated.

_dae = new DAE();
_dae.load("assets/knot2.dae", knotMaterialsList);
_dae.scale = 5;

Leave a Reply

Your email address will not be published. Required fields are marked *