RESOLVED: ObjectContainer3D and AssetLoader

Software: Away3D 4.x

Jokembe, Newbie
Posted: 19 September 2011 02:24 PM   Total Posts: 3

Hi Guys,
I’m loading several obj-Files via AssetLoader and XML. Now I want to set the Models to different ObjectContainer3D to place via XML.

private function initMesh() : void
  { 
   
   
   
for (var i:uint=0i<xml_dokument.container.length(); i++)
   
{
    
    objContString 
xml_dokument.container[i].@name.toString();    
    var 
myModelSrc:String "../embeds/head/"+xml_dokument.container[i].@src;
    
    
AssetLibrary.enableParser(OBJParser);
    
    
AssetLibrary.load(new URLRequest(myModelSrc), nullnullobjContString);
    
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETE,myMesh);
   
    
AssetLibrary.addEventListener(LoaderEvent.RESOURCE_COMPLETEonLoadComplete);
 
}
   
   
}

private function myMesh(e:AssetEvent):void{
 
if (e.asset.assetType ==AssetType.BITMAP
 

  e
.asset.name "myBitmapName";
 
}
 
if (e.asset.assetType == AssetType.MESH)
 
{   
  
var mesh2:Mesh e.asset as Mesh;
  
_view.scene.addChild(mesh2);
  
mesh2.mouseEnabled true
  
mesh2.name e.assetPrevName"_"+e.asset.assetNamespace;
  
mesh2.addEventListener(MouseEvent3D.CLICKclickMesh);
 
}
 
}

private function onLoadComplete(e:LoaderEvent):void{
 trace
("OBJ complete");
   
}

private function clickMesh(MouseEvent3D) : void
  {   
   trace
(e.currentTarget.name);
  

The XML:

<?xml version="1.0" encoding="utf-8"?>
<root
 <
container name="building1" src="building1.obj" xPos="39.9" yPos="0" zPos="40.4"/> 
 <
container name="building2" src="building2.obj" xPos="75.9" yPos="0" zPos="80.4"/> 
 <
container name="building3" src="building3.obj" xPos="9" yPos="0" zPos="200"/> 
</
root

I need for every Obj_File an extra ObjectContainer3D. This container should have the same name as the “assetNamespace” from XML (Atrribut “name”).

The loading event works, and the models were displayed with the “assetNamespace” from XML. But i can’t place the meshes in different containers.

Thank you in advance,
Joe

   

Avatar
Alejandro Santander, Administrator
Posted: 20 September 2011 02:00 AM   Total Posts: 414   [ # 1 ]

I’m not sure if I understand your problem, but if I do then your solution is very simple:

When you retrieve each mesh (which you call mesh2), create a new ObjectContainer3D, add it to the scene and add mesh2 to the container you created.

Perhaps the solution is too simple, and that’s why I am probably misinterpreting you… Let me know if that helps.

   

Jokembe, Newbie
Posted: 20 September 2011 08:41 AM   Total Posts: 3   [ # 2 ]

I’ve fixed it.

Thank you

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X