ASE Parser
What is an ASE file?
This file type represents the Autodesk ASCII Scene Export file. It is a text file with scene information from 3ds Max.
Papervision allows you to import geometry and mapping of one mesh with this parser. They recommend not doing anything too complex.
ASE Parser Example
package {
// flash class
import flash.events.Event;
// pv3d class
import org.papervision3d.events.FileLoadEvent;
import org.papervision3d.objects.parsers.Ase;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.shadematerials.GouraudMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.view.BasicView;
public class AseParser_v1 extends BasicView {
// create a class-level var for the collada scene
private var _ase:Ase;
// create the light
private var _light:PointLight3D;
public function AseParser_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 {
// we are now going to use a gouraud material for shading
var knotMaterial:GouraudMaterial = new GouraudMaterial(_light);
// instantiate the ASE obj and load the knot object
// apply the material and scale to 0.1
_ase = new Ase(knotMaterial, "assets/knot.ASE", .1)
// add the ASE file to the scene
scene.addChild(_ase);
// start rendering (activated onRenderTick)
startRendering();
}
override protected function onRenderTick(event:Event = null):void {
// rotate the object
_ase.yaw(1);
super.onRenderTick();
}
}
}
This is a simple class that extends the BasicView class in the Papervision library. The general setup involves a PointLight3D light source that is location in the same position as the camera. Everything else deals with the loading of an ASE file.
To load the file, an instance of the ASE parser is created at the class-level. In the init I created a GouraudMaterial and applied the light to it with default settings (white light, black shading).
var knotMaterial:GouraudMaterial = new GouraudMaterial(_light);
I then instantiated the ASE object and assigned the material, the path to the ASE file and the scaling value to the object in the constructor and added it to the stage
_ase = new Ase(knotMaterial, "assets/knot.ASE", .1);
This class also includes an EnterFrame function to spin the object on the Y axis.
_ase.yaw(1);