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=0; i<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), null, null, objContString);
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETE,myMesh);
AssetLibrary.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onLoadComplete);
}
}
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.CLICK, clickMesh);
}
}
private function onLoadComplete(e:LoaderEvent):void{
trace("OBJ complete");
}
private function clickMesh(e : 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