Help with loading OBJ and AWD2 Files.

Software: Away3D 4.x

Drewbaka, Newbie
Posted: 17 August 2012 06:21 PM   Total Posts: 11

Hey I have a problem…When I load a .3Ds file it loads perfectly. However when I change the parser to .obj or .awd I get an error with No parser….I have enabled all parsers and it still does not work… Please help. Also if you could suggest a good tutorial for AWD 4.0 for loading files and do not suggest the one on adobe forum because that does not load…Thanks smile


Here is the code I am trying to get to work for other files (besides 3DS):

package
{
 import away3d
.deep.*;
 
import away3d.cameras.lenses.PerspectiveLens;
 
import away3d.containers.ObjectContainer3D;
 
import away3d.containers.View3D;
 
import away3d.entities.Mesh;
 
import away3d.events.LoaderEvent;
 
import away3d.loaders.Loader3D;
 
//import away3d.loaders.parsers.Max3DSParser;
 
import away3d.loaders.parsers.*;
 
import away3d.loaders.parsers.Parsers;
 
import away3d.*;
 
import away3d.materials.ColorMaterial;
 
import away3d.materials.TextureMaterial;
 
import away3d.textures.BitmapTexture;
 
import flash.display.Bitmap;
 
import flash.display.MovieClip;
 
import flash.display.Shape;
 
import flash.display.SimpleButton;
 
import flash.display.Sprite;
 
import flash.events.Event;
 
import flash.events.IOErrorEvent;
 
import flash.events.MouseEvent;
 
import flash.events.SecurityErrorEvent;
 
import flash.geom.Vector3D;
 
import flash.net.FileFilter;
 
import flash.net.FileReference;
 
import flash.net.URLRequest;
 
import flash.system.Security;
 
import flash.text.TextField;

 
 
// 3DS Model Viewer Tutorial
 // by Vu Hoang Minh - www.3dgameflash.com
 // Created for active.tutsplus.com
 
 
public class Main extends Sprite
 {  
  
private var file:FileReference;
  private var 
view3d:View3D;
  private var 
loader:Loader3D;
  private var 
labelDebug:TextField;
  private var 
object3d:Mesh

  
  
  public function 
Main():void
  {
   
if (stage)
    
init();
   else
    
addEventListener(Event.ADDED_TO_STAGEinit);
  
}
  
  
private function init(e:Event null):void
  {
   
//allow all domain for load local file
   
Security.allowDomain("*");
   
   
removeEventListener(Event.ADDED_TO_STAGEinit);
   
//3d engine
   
view3d = new View3D();
   
view3d.camera.lens = new PerspectiveLens();
   
view3d.camera.100;
   
addChild(view3d);
      
   
//init 3d loader
   
initLoader();
   
   
//mcBrowse
   
var mcBrowse:MovieClip = new MovieClip();
   
mcBrowse.graphics.beginFill(0xeeeeee);
   
mcBrowse.graphics.drawRoundRect(121002577);
   
mcBrowse.graphics.endFill();
   var 
labelBrowse:TextField = new TextField();
   
labelBrowse.text "Browse";
   
mcBrowse.addChild(labelBrowse);
   
mcBrowse.mouseChildren false;
   
mcBrowse.buttonMode true;
   
labelBrowse.25;
   
mcBrowse.addEventListener(MouseEvent.CLICKonClick_mcBrowse);
   
addChild(mcBrowse);
   
   
//debug label
   
labelDebug = new TextField();
   
labelDebug.text "...";
   
labelDebug.textColor 0xff0000;
   
labelDebug.selectable false;
   
labelDebug.mcBrowse.height 2;
   
labelDebug.width 600;
   
addChild(labelDebug);
   
   
//file
   
file = new FileReference();
  
}
  
  
private function initLoader():void
  {
   
//clear
   
removeEventListener(Event.ENTER_FRAMEonEnterFrame);   
   
   while (
view3d.scene.numChildren 0)
   
{
    view3d
.scene.removeChild(view3d.scene.getChildAt(0));
   
}
   
   
//init new Loader
   
Parsers.enableAllBundled();
   
Loader3D.enableParsers(Parsers.ALL_BUNDLED);
   
//Loader3D.enableParser(Max3DSParser);
   
loader = new Loader3D();
   
loader.addEventListener(LoaderEvent.RESOURCE_COMPLETEonComplete_loader);
   
//Loader3D.parse( data, null,  new AssetLoaderContext(false));
   
loader.addEventListener(LoaderEvent.LOAD_ERRORonError_loader);
   
view3d.scene.addChild(loader);
   
view3d.camera.lookAt(loader.position);
  
}
 
  
private function onClick_mcBrowse(e:MouseEvent):void
  {
   trace
("on click");
   
file.browse();//[new FileFilter("3DS", "*.3ds")]
   
file.addEventListener(Event.SELECTonFileSelected);
   
file.addEventListener(SecurityErrorEvent.SECURITY_ERRORonSecurityError);
   
file.addEventListener(IOErrorEvent.IO_ERRORonIOError);
  
}
  
  
private function onSecurityError(e:Event):void 
  {
   trace
("security Error");
   
labelDebug.text += ".Security Error!";
  
}
  
  
private function onIOError(e:IOErrorEvent):void 
  {
   trace
("IO ERROR");
   
labelDebug.text += ".File not found Error!";
  
}
  
  
private function onFileSelected(e:Event):void
  {
   trace
("On File Selected");
   
labelDebug.text "File :" file.name;
   
file.removeEventListener(Event.SELECTonFileSelected);
   
file.addEventListener(Event.COMPLETEonFileLoaded);
   
file.load();
  
}
  
  
private function onFileLoaded(e:Event):void
  {
   trace
("on file loaded");
   
file.removeEventListener(Event.COMPLETEonFileLoaded);
   
initLoader();
   
loader.loadData(e.target.data);
  
}
  
  
private function onError_loader(e:LoaderEvent):void
  {
   trace
("Error loading File...");
   
labelDebug.text += " .Loading Error";
  
}
  
  
private function onComplete_loader(e:LoaderEvent):void
  {   
   trace
("3D File loaded");
   
labelDebug.text += " .Complete.Rendering...";
   
loader.removeEventListener(LoaderEvent.RESOURCE_COMPLETEonComplete_loader);
   
loader.removeEventListener(LoaderEvent.LOAD_ERRORonError_loader);
   
object3d Mesh(loader.getChildAt(0));
   
view3d.scene.addChild(object3d);
   
loader.dispose();
   
loader null;
   
   
addEventListener(Event.ENTER_FRAMEonEnterFrame);
  
}
  
  
private function onEnterFrame(e:Event):void
  {
   object3d
.yaw(1);
   
view3d.render();
  
}
 }

Thanks for help!!!

When I load .obj file I get this:
Error #3671: Buffer has zero size


When I load .awd file I get this:
Error: No parser defined. To enable all parsers for auto-detection, use Parsers.enableAllBundled()

Also can someone link me to a tutorial for asset library??
“// To load
AssetLibrary.load(new URLRequest(‘path/to/my/file.awd’));
// Once load has finished
var mesh : Mesh = Mesh(AssetLibrary.getAsset(‘nameOfMyMesh’));”

 

File Attachments
kill.obj  (File Size: 2KB - Downloads: 197)
kill.mtl  (File Size: 1KB - Downloads: 178)
   

Richard Olsson, Administrator
Posted: 18 August 2012 10:12 AM   Total Posts: 1192   [ # 1 ]

What version of the engine are you using? What are the values of the static constants on the away3d.Away3D class?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X