Cloning AWD Model to be used hundreds of times in same view.
Software: Away3D 4.x
ddddesigns, Jr. Member Posted: 23 July 2013 06:12 AM Total Posts: 37
I have an AWD model of a tree built exported from AwayBuilder. It has a super low poly count. However, I would like to build a forest on the map. I believe that since the trees are all the same with the exception of their location I can just clone them. Is this possible with an AWD model? I gather my list of tree locations from an XML file loaded externally (for the time being). Here is the function that is called once the XML is loaded. Is this possible to clone an AWD?
public function parseGetTreesXML(e:Event):void { /* SAMPLE OF XML <result> <trees> <tree x="112.44" y="124.58" z="421.57" /> <tree x="148.54" y="842.52" z="148.59" /> <tree x="112.44" y="124.58" z="400.48" /> </trees> </result> */
var xmlData:XML = new XML(e.target.data);
var trees:Object = new Object(); trees = xmlData;
var treeCount:int = trees[0].trees.children().length(); var assetLoaderContext:AssetLoaderContext;
var loader:Loader3D = new Loader3D(); loader.scale(3); loader.loadData(new TreeModel(), assetLoaderContext);
loth, Sr. Member Posted: 23 July 2013 11:20 AM Total Posts: 236
[ # 1 ]
hello
if you want many clone > 60
you may use md2 and vertexAnimator (take less resource)
is simple import your awd model in prefab and export as md2
80prozent, Sr. Member Posted: 23 July 2013 12:18 PM Total Posts: 430
[ # 2 ]
Hi
@loth why should the md2 be better than the awd?
Md2 has bigger filesize than awd. How shoukd using vertexanimations help with this? Vertexanimations would help, if you wanted to have the same tree in differrnt shapes….but i think all that is needed here are clones, not modified clones
..
In awaybuilder you can reuse the same geometry in multiple meshes, so the awd will only contain one geometry, but a lot of meshes using this geometry.
Just cloning the meshes in away3d should work fine too.
I think the Performance might be better, if yoh merge all your cloned meshes into one big mesh.
80prozent, Sr. Member Posted: 23 July 2013 12:19 PM Total Posts: 430
[ # 3 ]
For you question:
You cannot clone a awd file.
You can clone the meshes loaded from the awd file.
ddddesigns, Jr. Member Posted: 23 July 2013 02:59 PM Total Posts: 37
[ # 4 ]
@80Prozent, How do I access the Mesh of an AWD and clone it? I’m new to cloning.
80prozent, Sr. Member Posted: 23 July 2013 03:06 PM Total Posts: 430
[ # 5 ]
hi
when importing the awd, you can listen for the AssetEvent.MESH_COMPLETE.
It will give you access to each mesh that is created by the AWD2Importer.
you can also listen for the more generic AssetEvent.ASSET_COMPLETE. When using this Event, you will have to check if Asset.type == “Mesh”.....
Have a look at the examples on github, to see how AssetEvent are used…
Once you have access mto the mesh, you can just call the yourMesh.clone() function…
Hope that helps
ddddesigns, Jr. Member Posted: 23 July 2013 05:16 PM Total Posts: 37
[ # 6 ]
So many of the examples seem to be broken. :(
80prozent, Sr. Member Posted: 23 July 2013 06:05 PM Total Posts: 430
[ # 7 ]
hm
i did compile all (!) examples not to long ago….
please make shure you are switching to the dev-branch before downloading the zip-file from git.
they should work…...
ddddesigns, Jr. Member Posted: 23 July 2013 06:14 PM Total Posts: 37
[ # 8 ]
Doing it now…
ddddesigns, Jr. Member Posted: 23 July 2013 06:25 PM Total Posts: 37
[ # 9 ]
I can’t seem to get the Intermediate_OnkbaAWDAnimation example to load. It builds but I get an error #2142. Loaded file is an unknown type. I would like to stick with AWD models since they are the most “native” model types for Away3D.
80prozent, Sr. Member Posted: 23 July 2013 07:22 PM Total Posts: 430
[ # 10 ]
hm…strange…cant remember ever seeing this error in away3d….
i just tried the onkba, and for me it works fine…
one thing i have to do to make it work in flashdevelop, is to move the assets-folder found in the “scr”-directory, into the “bin”-directory. Oterwise the assets do not load at all.
other than that, i dont know whats going on there…what IDE are you using ?
ddddesigns, Jr. Member Posted: 23 July 2013 10:17 PM Total Posts: 37
[ # 11 ]
I see… I moved copied the assets folder over to my server so that the swf in my test page can access it. I don’t call these examples in a standalone player.
Now I have run into an error in the AWD2 file
Error: AWD2 body length does not match header integrity field at away3d.loaders::AssetLoader/onParserError()[C:\Program Files\Away3D\Examples\Away3DExamples\src\away3d\loaders\AssetLoader.as:558] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at away3d.loaders.misc::SingleFileLoader/onParseError()[C:\Program Files\Away3D\Examples\Away3DExamples\src\away3d\loaders\misc\SingleFileLoader.as:477] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at away3d.loaders.parsers::ParserBase/dieWithError()[C:\Program Files\Away3D\Examples\Away3DExamples\src\away3d\loaders\parsers\ParserBase.as:534] at away3d.loaders.parsers::AWD2Parser/parseHeader()[C:\Program Files\Away3D\Examples\Away3DExamples\src\away3d\loaders\parsers\AWD2Parser.as:334] at away3d.loaders.parsers::AWD2Parser/proceedParsing()[C:\Program Files\Away3D\Examples\Away3DExamples\src\away3d\loaders\parsers\AWD2Parser.as:265] at away3d.loaders.parsers::ParserBase/onInterval()[C:\Program Files\Away3D\Examples\Away3DExamples\src\away3d\loaders\parsers\ParserBase.as:568] at flash.utils::Timer/_timerDispatch() at flash.utils::Timer/tick()
80prozent, Sr. Member Posted: 24 July 2013 08:41 AM Total Posts: 430
[ # 12 ]
Hi
Why not testing the examples offline first ? You can allways test them online later, but better try getting them compiled offline first.
The error you are getting seams like the awd is not loaded 100% before the perser starts parsing….
This should not be happening….
Maybe the awd-file has been corrupted on upload to your server ?
ddddesigns, Jr. Member Posted: 24 July 2013 01:30 PM Total Posts: 37
[ # 13 ]
I test in a test server environment. This simulates being online while only being accessible to me. Since I plan to use away3d in an online game, I feel it is best to test on a server. Since away3d is designed to be used online would it not make more sense to test on a server if you have access to one?
Anyway, I tried reuploading but that hasn’t fixed the problem either. I guess I’ll keep on trying different things.
80prozent, Sr. Member Posted: 24 July 2013 01:47 PM Total Posts: 430
[ # 14 ]
Hi
Of course you need to test it for the enviroment it will be used in later….
I test on my localhost and on my server too, but i always test in flash-standaloneplayer first. Just so i am shure the stuff is working there, before testing in a different enviroment…...
John Brookes, Moderator Posted: 24 July 2013 05:28 PM Total Posts: 732
[ # 15 ]
Agree with 80. Just get it working locally (filesystem) first.
error #2142
Is the sandbox, your probably trying to load the file from somewhere on your filesystem flash isnt allowed to go.
So open the player manager and add that location to trusted.
As for local server, see if you can actually get the awd file from the server through a browser, see if you get any http errors.
Basically may have to set a mimetype on your local server.