help with loading a .OBJ in away 3d 3.6

Software: Away3D 3.x

Mr Margaret Scratcher, Sr. Member
Posted: 20 August 2011 05:15 AM   Total Posts: 344

Hi there, frustration time again, I can load an OBJ easy enough in the broomstick build, but need to get it running in 3.6 until flashplayer 11 is rolled out officially at the moment I have this in away3d 4:

private function loadBlock() : void
  {
   
   trace 
("loading block")
   
   
//away3d 4
   
blockLoader = new Loader3D;
   
Loader3D.enableParser(OBJParser);
   
blockLoader.load(new URLRequest("models/2x4/2x4.obj"));
   
//blockLoader.load(new URLRequest("models/arrow/arrow.obj"));
   
   
blockLoader.addEventListener(LoaderEvent.RESOURCE_COMPLETEblockComplete); 
   
view.scene.addChild(blockLoader); 
  

and then

private function blockComplete(event LoaderEvent) : void
  {
   
var mesh Mesh;
   for (var 
int 0blockLoader.numChildren; ++i
   
{
    mesh 
Mesh(blockLoader.getChildAt(i));
    
mesh.geometry.scale(100);
    
//mesh.y = -700
    //_loader.x = 300
    //_loader.z = -500
    
var blockMaterials DefaultMaterialBase = new ColorMaterial(0xff0000);
    
blockMaterials.ambientColor 0x111111;
    
blockMaterials.gloss 1;
    
blockMaterials.specular .8;
    
blockMaterials.lights [_light];
    
mesh.material.lights  [_light];
    
mesh.material blockMaterials
    
   }
  } 

I’m wondering if anyone has a tutorial that does the same thing in away3d 3.6 ?

Thanks in advance..

 

   

Avatar
oladitan, Member
Posted: 24 August 2011 01:48 AM   Total Posts: 71   [ # 1 ]

here is an example I got from the Away3d Essentials book. I adjusted it a little:

public class LoadOBJ extends Away3DTemplate
 {
  [Embed
(source "demoobj.obj"mimeType "application/octet-stream")
  
protected var DemoObj:Class;
  
[Embed(source "objtexture.jpg")
  
protected var OBJTexture:Class;
  
  public function 
LoadOBJ ()
  
{
   super
();
  
}
  
  
protected override function initScene():void
  {
   super
.initScene();   
   var 
modelMaterial:BitmapMaterial 
    new 
BitmapMaterial(Cast.bitmap(OBJTexture));
   var 
OBJMesh:Mesh 
    
Obj.parse(Cast.bytearray(DemoObj),
    
{
     z
200,
     
useMtlfalse
    }
   
) as Mesh;
   for 
each (var face:Face in OBJMesh.faces)
    
face.material modelMaterial
   
scene.addChild(OBJMesh);
  
}  
 }
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X