Hi there, I’m currently converting aload of .objs to AWD2 format, but before I carry on plowing through, I thought I’d better just check that it is worth doing.
All of the models are quite small, about 5k each, so I’m wondering what gains (if any) I make by converting to AWD2 in prefab?
The size seems to be the same after converting, but will I notice a speedup due to faster parsing?
Is AWD the way to go or should I use a different format?
Alexander Seifert, Moderator Posted: 29 July 2012 08:48 AM Total Posts: 129
[ # 1 ]
Hi,
in our project (Delta Strike) we originally used plain OBJs only. No materials no dependencies, uni-body meshes only, so to say. We used Prefab to convert all our models to ASD format and had 20x speed-gain in loading these. Not because file size was so much smaller (we compress everything anyway using Joa Ebert’s Reducer) but because ASD (like AWD, I presume) serializes to a binary file and therefore when deserializing only needs to read through a ByteArray instead of actually performing String parsing and conversion as is the case with OBJ files. Hence the speed gain.
Are your models uni-body mesh-only as well? If so, my guess would be that ASD is just fine as you don’t need any of the extra features of AWD
Cheers!
Alex
Richard Olsson, Administrator Posted: 29 July 2012 09:24 AM Total Posts: 1192
[ # 2 ]
I’m surprised that you’re getting the same size files with both AWD2 and OBJ. Is the AWD file not compressed?
Anyway, Alexander is right that the simpler serialization of “ASD” (which is basically just a flat vector in a byte array, parsed at runtime by an ActionScript class, that is included with the export) will be both faster and possibly smaller than AWD2, which is a general purpose format.
Note that ASD could potentially change with engine upgrades though, which is something that AWD2 has promised not to do (being forwards and backwards compatible) as long as there are no bugs in the encoder or decoder, of course.
The best approach though, if applicable to your particular situation, might be to try to get all the models into a single (or smaller number of) AWD files. Just make sure to name the meshes/geometries before exporting, and you can load them into your app in a single go, and access them through the AssetLibrary after doing so.
The benefit of this approach is that with larger files, the compression algorithm can be more efficient, and thus result in a smaller total size. There would also be less overhead in terms of data (file headers), traffic (HTTP) and computation (loader/parser start-up et c.)
Alexander Seifert, Moderator Posted: 29 July 2012 09:53 AM Total Posts: 129
[ # 3 ]
Richard,
yes, AWD is compressed =) However, we’re using Joa Ebert’s Reducer, which compresses the SWF files we embeded our OBJ files into quite nicely. You may want to look into that, especially since it also handles PNG and other formats as well =)
Richard Olsson, Administrator Posted: 29 July 2012 09:59 AM Total Posts: 1192
[ # 4 ]
Alex, my questions were directed to the original poster. Sorry if I was being unclear. The OP said that they were seeing the same file size from OBJ and AWD2.
When I asked whether the AWD file was compressed, I wasn’t wondering whether AWD supports compression (which obviously I know that it does, having designed the format) but I was rather wondering whether the original poster had enabled compression when creating the files. I’m unsure whether Prefab makes that optional, or supports compression at all.
I know Reducer, but that’s only relevant if the files are embedded. The original poster seemed to suggest that OBJ files and AWD2 files were about the same in size on their own. I’d be interested to know if (and why) that is so.
Alexander Seifert, Moderator Posted: 29 July 2012 11:44 AM Total Posts: 129
[ # 5 ]
:D
Actually my bad!
But always incredible how well you cover the forum, Richard. Kudos =)
Not sure if compression is enabled or not by default - there is an option called ‘collapse’ but not sure what that does. I think that with the meshes being quite simple, there’s not much compression that could be done..
As for putting all the meshes into a single .awd, that would be a good idea but I’m leaving this project modular - it runs from an .xml, so at the moment to include another mesh is just a case of saving it with the appropriate name and putting it in the xml.
I’ve finished coverting everything to .awd, and enabled the AWDparser, but now I’m getting errors such as:
[Fault] exception, information=Error: Error #2030: End of file was encountered.
and I’m getting this trying to read from the xml which I’ve stripped to only reference one of the .awd files. When I tried it with the full xml I got the same thing, until I re-exported the seemingly troublesome awd (the last one) and then I had ancoercion error about trying to assign a container to a mesh…
I’m using the Loader3D method…
Richard Olsson, Administrator Posted: 30 July 2012 07:00 AM Total Posts: 1192
[ # 7 ]
What version of Away3D and Prefab are you using?
Please include full stack traces for all errors you’re getting, including the coercion error.
Fabrice Closier, Administrator Posted: 30 July 2012 09:09 AM Total Posts: 1265
[ # 8 ]
@Margaret Scratcher:
There is no compression option yet (tho it’s already implemented into the awd exporter.I haven’t got time to test it properlly yet).
The collapse has nothing to do with compression. It’s in a way, the invert process of Merge.
Imagine you have 3 meshes, 2 having a red material, 1 a green material.
If you merge them you end up with 2 subMeshes: a multiple material mesh. Using collapse, you would end up having 2 meshes. 1 with red material, one with green.
I’m using Prefab 2.118 and Away3d that I pulled from github on the 27th July..
The error I get is either:
[Fault] exception, information=TypeError: Error #1034: Type Coercion failed: cannot convert away3d.containers::ObjectContainer3D@14c3add1 to away3d.entities.Mesh.
^^ If i use the xml with all the various awds loading.
part of my code is
for (var i : int = 0; i < OBJloader.numChildren; ++i) { var mesh : Mesh; mesh = Mesh(OBJloader.getChildAt(i)) as Mesh; mesh.geometry.scale (0.02); {mesh.material = Material;} }
(OBJloader is the AWD loader)
I’m guessing there’s something different about the awd format what means that not all the children of the loader will be meshes?
And if I try with the xml which only has one awd to import I get
[Fault] exception, informati Error #2030: End of file was encountered.
Which I guess is problem with the awd itself, and if I rectify the problem above in my code, this error will crop up again once it gets to that particular object..