Loading .obj file

Software: Away3D 4.x

Monguron, Newbie
Posted: 08 October 2011 01:16 PM   Total Posts: 27

Hello Guys,

the plan is to load an obj. model (with a texture, but this problem comes later smile) into the framework.

This is the code (from a tutorial):

package
{
import away3d.containers.View3D;
import away3d.events.LoaderEvent;
import away3d.loaders.Loader3D;
import away3d.loaders.parsers.Parsers;

import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;

[SWF(width=“400”, height=“300”)]
public class GettingStartedWithAway3D extends Sprite
{
  private var _view : View3D;
  private var _loader : Loader3D;
 
  public function GettingStartedWithAway3D()
  {
  _view = new View3D();
  _view.backgroundColor = 0xd7d7d7;
  _view.antiAlias = 4;
 
  this.addChild(_view);
  this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
 
  Parsers.enableAllBundled();
 
  _loader = new Loader3D();
  _loader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onResourceComplete);
  _loader.addEventListener(LoaderEvent.LOAD_ERROR, onLoadError);
  _loader.load( new URLRequest(‘head.obj’) );
  _loader.scale(10);
  }
 
 
  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();
  }
}
}

The problem is, that neither the Adria.obj file, nor the M4.obj file can be loaded, and I don’t know why.

Any ideas? Thanks!

Thanks!

 

File Attachments
adria.obj  (File Size: 205KB - Downloads: 196)
M4.obj  (File Size: 654KB - Downloads: 187)
   

empend, Member
Posted: 08 October 2011 03:43 PM   Total Posts: 77   [ # 1 ]

They broke the loaders apparently. XD

   

Richard Olsson, Administrator
Posted: 08 October 2011 10:37 PM   Total Posts: 1192   [ # 2 ]

Are you getting any runtime errors (be sure to use the debug player)? Is the onLoadError() handler method being invoked?

   

Monguron, Newbie
Posted: 09 October 2011 07:22 AM   Total Posts: 27   [ # 3 ]

Hi,

the compiler runs well, and the I get the flash in Firefox, but only with a grey background.

I don’t see any warning, or error in the log.

Is this code proper by the way? Or what else should be included?

   

Monguron, Newbie
Posted: 09 October 2011 09:20 AM   Total Posts: 27   [ # 4 ]

There must be a problem with the models ... Maya and 3DS opens them as a big bunch of crap.

(Error msg in Maya: “Wrong vertex normal index 1 in OBJ file line 595”)

   

bcnobel, Newbie
Posted: 10 October 2011 01:24 AM   Total Posts: 1   [ # 5 ]

Nevermind this post, i read wrong…

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X