Getting an object back from the AssetLibrary

Software: Away3D 4.x

Hector, Sr. Member
Posted: 14 November 2011 03:56 PM   Total Posts: 137

Hi everybody,

I have a 3DS file which contains two meshes. I use AssetLibrary to load it, which loads every mesh and every material inside the 3DS file separately.
I want to use the loaded model from a different class.

How do I get the full model back from AssetLibrary to add it to the scene as a single object?
Maybe is not the correct way to use AssetLibrary, should I make my own objects library?

Thanks in advance.

   

Avatar
Baush, Sr. Member
Posted: 14 November 2011 04:44 PM   Total Posts: 135   [ # 1 ]

If I understand this right, the loader/parser will load and store all geometries, animations, materials contained in your .3ds in seperate objects. After loading the objects, use a debugger and inspect the content of AssetLibrary at runtime and you’ll see what I mean.

Afterwards, you can use the AssetLibrary.getAsset() to fetch the geometry that you need and simply cast it in its type such as:

var houseGeometry:Geometry = AssetLibrary.getAsset(“house_geom”);

then build your mesh this way:

var mesh:Mesh = new Mesh(material, houseGeometry);
scene.addChild(mesh);

this will use a single instance of the geometry, which in turn, uses less memory.

   

Hector, Sr. Member
Posted: 14 November 2011 05:49 PM   Total Posts: 137   [ # 2 ]

Thanks for your reply Baush,
In my case I want all the geometries inside the object.
Let’s say ‘house.3ds’ has two objects: ‘walls’ and ‘roof’.
Do I need to use ‘getAsset()’ twice to make the Mesh?

   

Avatar
Baush, Sr. Member
Posted: 14 November 2011 06:05 PM   Total Posts: 135   [ # 3 ]

Technically, you should have walls and roof keys in your asset library. If not, try a different mesh container such as md5 or collada as 3ds may only represent a single mesh.. I’m not quite sure

   

Hector, Sr. Member
Posted: 14 November 2011 06:14 PM   Total Posts: 137   [ # 4 ]

Yes, I do have both keys. I assume AssetLibrary doesn’t store any relationship between both meshes. If I would need to create the house, do I need to use something like:

houseGeometry.addSubGeometry(wallsGeometry);
houseGeometry.addSubGeometry(roofGeometry);

is that right?

   

Avatar
Baush, Sr. Member
Posted: 14 November 2011 06:19 PM   Total Posts: 135   [ # 5 ]

you would then need to use the “mesh” object from the AssetLibrary. You should technically have a house_mesh or something

   

Hector, Sr. Member
Posted: 20 November 2011 12:03 PM   Total Posts: 137   [ # 6 ]

I see, thanks Baush, now I understand how the AssetLibrary works.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X