Hi all,
I am pretty new to Away3D and I wonder how to load the AWD file that I exported from 3dsMax 2012 using the Away3d Exporter Plug-In. I found a tutorial doing exactly what I want and I downloaded the code to try it out.
http://www.adobe.com/devnet/flashplayer/articles/creating-games-away3d.html
However, it doesn’t work. After a few hours of trail and error, I finally got the code working. The solution is to change the Away3D library from 4.0.9 Gold to 4.0.110915 Alpha, then the 3d model finally showed up!
However, when I changed to the my awd file, it doesn’t work! DAMN!!!!
Anyone knows what is going on? Bugs in 4.0? Or they just changed the way to load awd in the new release?
Many thanks!!!
package
{
import away3d.containers.View3D;
import away3d.events.LoaderEvent;
import away3d.loaders.Loader3D;
import away3d.loaders.parsers.Parsers;
import away3d.primitives.WireframeCube;
import away3d.library.AssetLibrary;
import away3d.events.AssetEvent;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
[SWF(width="800", height="600")]
public class GettingStartedWithAway3D extends Sprite
{
private var _view : View3D;
private var _loader : Loader3D;
private var cube:WireframeCube;
public function GettingStartedWithAway3D()
{
_view = new View3D();
_view.backgroundColor = 0x666666;
_view.antiAlias = 4;
this.addChild(_view);
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
//I draw a cube to see know the code is still run well when the awd object doesn't appear
cube = new WireframeCube(200, 200, 200, 0xFF0000, 1);
_view.scene.addChild(cube);
Parsers.enableAllBundled();
trace("init loader");
_loader = new Loader3D(false, null);
//awd object provide by the tutorial, works only in Away3D 4.0.110915 Alpha
//_loader.load(new URLRequest('vase.awd'));
//my awd object, doesn't work!
_loader.load(new URLRequest('building_v3.AWD') );
_loader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onResourceComplete);
_loader.addEventListener(LoaderEvent.LOAD_ERROR, onLoadError);
}
private function onResourceComplete(ev : LoaderEvent) : void
{
_loader.removeEventListener(LoaderEvent.RESOURCE_COMPLETE, onResourceComplete);
_loader.removeEventListener(LoaderEvent.LOAD_ERROR, onLoadError);
_view.scene.addChild(_loader);
}
private function onLoadError(ev : LoaderEvent) : void
{
trace('Could not find', ev.url);
_loader.removeEventListener(LoaderEvent.RESOURCE_COMPLETE, onResourceComplete);
_loader.removeEventListener(LoaderEvent.LOAD_ERROR, onLoadError);
_loader = null;
}
private function onEnterFrame(ev : Event) : void
{
_loader.rotationY = stage.mouseX - stage.stageWidth/2;
_view.camera.y = 3 * (stage.mouseY - stage.stageHeight/2);
_view.camera.lookAt(_loader.position);
_view.render();
}
}
}