Thank you for the information, and for getting back to me so quickly.

Larry Van Wave
Cell number 623-326-0824

On Dec 30, 2009, at 1:26 PM, "Joshua Granick" <[email protected]> wrote:

You can also use the Embed tag if you are using Flex Builder or FlashDevelop (which I highly recommend!)

The following example is for a Collada (*.dae) file, but you can probably load an obj the same way by swapping out the Collada class with the Obj class.

If you are using FlashDevelop, you can right-click files in the Project panel and select "Insert Into Document" to insert an Embed tag with the correct path.



package com.myexample {


   import away3d.core.utils.Cast;
   import away3d.loaders.Collada;
   import away3d.materials.BitmapMaterial;
   import flash.display.Sprite;


   /**
    * @author Joshua Granick
    */
   public class Example extends Sprite {


[Embed(source='../../Assets/Model.dae', mimeType='application/ octet-stream')]
       private var Mesh:Class;

[Embed(source='../../Assets/Texture.png', mimeType='image/ png')]
       private var Texture:Class;


       public function Example () {

var material:BitmapMaterial = new BitmapMaterial (Cast.bitmap (Texture), { smooth: true } ); var model:ObjectContainer3D = Collada.parse (Mesh, { material: material } );

       }


   }


}



On Wed, 30 Dec 2009 12:15:09 -0800, Paweł Stanisławczuk <[email protected] om> wrote:

Hi!

Someone can call this method "old school" but it works for me

First I load material, then obj. Import required classes. It's a copy
paste of 2 different classes, but it should work.

private var _materialLoader:Loader;
private var _materialObject3D:BitmapMaterial;
private var _objLoader:Object3DLoader;
private var _mesh:Mesh;

public function loadMaterial():void {
   _materialLoader = new Loader();
   _materialLoader.contentLoaderInfo.addEventListener(Event.INIT,
onComplete);
   _materialLoader.contentLoaderInfo.addEventListener
(IOErrorEvent.IO_ERROR, onMaterialLoaderError);//create this function
   _materialLoader.load(new URLRequest(_materialURL));
}

private function onComplete(event:Event):void {

   _materialLoader.contentLoaderInfo.removeEventListener(Event.INIT,
onComplete);
   _materialLoader.contentLoaderInfo.removeEventListener
(IOErrorEvent.IO_ERROR, onMaterialLoaderError);

   var bitmap:Bitmap = materialLoader.content as Bitmap;
   bitmap.smoothing = true;

   _materialObject3D = new BitmapMaterial(bitmap.bitmapData);
   _materialObject3D.smooth = true;

   loadOBJ();

}

private function loadOBJ():void {
   _objLoader = Obj.load(_objURL, {material:_materialObject3D,
name:"OBJ", scaling:10}); //adjust the scaling as needed
   _objLoader.addOnSuccess(onLoaderSuccess);
   _objLoader.addOnError(onLoaderError); //create this function
}

private function onLoaderSuccess(event:LoaderEvent):void {
   var obj:ObjectContainer3D = (event.target.handle as
ObjectContainer3D);
_mesh = obj.children[0] as Mesh; // I need this trick, I export OBJ
using LightWave

   scene.addChild(_mesh);
}

Good Luck!
Paweł


On Dec 30, 7:07 pm, Wave3d <[email protected]> wrote:
I am a rookie at using away3d, but I like the ability to have a 3d
engine using flash. I have tried to load in .obj files, and have
looked online for tutorials, yet I haven't found one that will work
yet. Do you have any information on the basic code for loading a .obj file into flash using away3d, I'm looking for the bare bones code just
so I can understand what elements of code have to be in the
actionscript to load the model.

Reply via email to