Tuesday, August 17, 2010

Flex loading a 3D model as a new type class

The following code can be used to load a 3D model designed from Google sketchup tool, to load in to an ActionScript on Adobe Flex application on Flex builder

var myModelDisplayObject3D :DisplayObject3D = new DisplayObject3D();

[Embed(source="assets/Rack2.dae", mimeType="application/octet-stream")] private var MyModel:Class;


var myModel:MyModel= new MyModel();
var myModeldae:DAE = new DAE();
var myModelMaterialList:MaterialsList = new MaterialsList();
 myModeldae.load(XML( new myModel() ), myModelMaterialList );
 myModelDisplayObject3D = scene.addChild( myModeldae);
light.lookAt(myModelDisplayObject3D );

1 comment:

  1. [Embed(source="assets/Rack2.dae", mimeType="application/octet-stream")] private var MyModel:Class;

    code is to load the model object on /src/assets folder of the source files(/src). Most impotent thing is this will embed the object file in to flash file. so no need to carry the model file with it separately.

    ReplyDelete