Is it possible to iterate through every mesh loaded in a single awd file?

Software: Away3D 4.x

blumersolutions, Newbie
Posted: 09 May 2012 04:37 AM   Total Posts: 13

Hi all,
I’m loading an awd file created on prefab (started as an .obj, then exported to awd) cointaining several independent meshes inside (let’s say cubes). What I’m trying to do is once loaded, identify each mesh/cube and then assign a specific texture for each (or the same texture actually, since I’m trying to implement an atlas texture). Is it possible? how? Could you point me to some code?

Thanks in advance.

   

Paul Schlichter, Newbie
Posted: 09 May 2012 05:39 PM   Total Posts: 13   [ # 1 ]

Assuming the awd parser adds all found objects directly to scene root ( dont know, I didnt use it yet ), try this:

for ( var int 0view.scenei++ )
{
   
if ( view.scene.getChildAtis Mesh )
   
{
      mesh 
Meshview.scene.getChildAt) );

      switch( 
mesh.name )
      
{
         
case "myMeshName_1":
            
// do something with your mesh
         
break;

         case 
"myMeshName_2":
            
// do something with your mesh
         
break;
      
}
   }


Best regards smile
Paul

   

Avatar
Fabrice Closier, Administrator
Posted: 09 May 2012 08:41 PM   Total Posts: 1265   [ # 2 ]

Almost good wink  awd1 are often having a first child as ObjectContainer3D, which is where the meshes are. Your snippet would miss them. It can also be way more nested than that. Use instead a recursive loop to make sure you do not miss anyone in there. Take a look at some Tools classes, several are having a recursive “parse” method or similar.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X