AssetLibrary and Materials..

Software: Away3D 4.x

eclectrik, Newbie
Posted: 21 October 2011 01:47 AM   Total Posts: 19

I`m using AssetLibrary to load my model, and the relevant textures.

My model has 5 meshes, and 5 jpg`s for diffuse.

What i`d like to know if after the AssetLibrary has loaded all of it - how do i then create materials with the correct diffuse texture for each mesh?

I know how to create the material and apply it as each mesh asset is loaded, it`s targetting the correct texture to the correct mesh that i`m struggling with if that makes sense.

 

   

Richard Olsson, Administrator
Posted: 21 October 2011 07:09 AM   Total Posts: 1192   [ # 1 ]

It’s completely up to your application logic to decide which bitmap belongs with which mesh, but once you know you just have to do:

bmp = BitmapDataAsset(AssetLibrary.getAsset(‘bmp1’)).bitmapData;
mesh = Mesh(AssetLibrary.getAsset(‘mesh1’));
mesh.material = new BitmapMaterial(bmp);

   

eclectrik, Newbie
Posted: 21 October 2011 10:59 AM   Total Posts: 19   [ # 2 ]

Thanks Richard - that looks nice and straight-forward.

There must be some id/tags within the 3d file itself which links objects to materials is there any way to access this info so materials/bitmaps could be loaded/applied dynamically when loading a lot of different models?  Or does it have to be hand-coded for each mesh/subMesh?

   

Richard Olsson, Administrator
Posted: 21 October 2011 12:09 PM   Total Posts: 1192   [ # 3 ]

If the object has a bitmap material assigned to it in the file, then it will in Away3D as well. You do not have to assign materials manually if you are parsing a file that contains both meshes, materials and the relationship between these.

If there is no such connection in the file, you have to build the logic to sort it out, because that’s application specific and cannot be solved reliable using a general approach by a general-purpose library like Away3D.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X