Return to Snippet

Revision: 12711
at March 25, 2009 16:14 by allnatural


Initial Code
package {
       import flash.events.Event;
       
       import org.papervision3d.lights.PointLight3D;
       import org.papervision3d.materials.shadematerials.GouraudMaterial;
       import org.papervision3d.materials.utils.MaterialsList;
       import org.papervision3d.objects.parsers.Collada;
       import org.papervision3d.view.BasicView;
       
       public class ColladaParser_v1 extends BasicView {
        // create a class-level var for the collada scene
        private var _collada:Collada;
        // create the light
        private var _light:PointLight3D;
       
        public function ColladaParser_v1() {
         lights();
         init3d();
        }
       
        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);
         _light.copyPosition(camera);
        }
       
        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 collada obj and load the knot object
         // apply the material and scale to 0.05
         _collada = new Collada("assets/knot.DAE", knotMaterialsList, 0.05);
         // add the collada file to the scene
         scene.addChild(_collada);
         // start rendering (activated onRenderTick)
         startRendering();
        }
       
        override protected function onRenderTick(event:Event = null):void {
         // rotate the object
         _collada.yaw(2);
         super.onRenderTick();
        }
       }
      }

Initial URL
http://www.destroyyourcomputer.com

Initial Description
Easy little Collada parser I found online somewhere.

Initial Title
Papervision3D Collada Parser Example

Initial Tags

                                

Initial Language
ActionScript 3