in short
Binary file format between 3dsmax and Flash AS3 to eleminate parsing times and dramaticly decrease loading times

Demo (for the ones who lazy bones)

(left buttons to load 3d files [yes they are not compiled arrays but external files]- the UV map is displayed in the upper right corner)
online demo


so I was playing again with maxscript and discovered how to write binary files directly out of 3dsmax to my harddrive.

(3dsmax mascript interface I wrote to write the binary files)
And of course the next logical step for me was to read the binary files with AS3- and I got it working.
Since then I started writing a simplified 3d format wich I can load into AS3 really fast. The format is intended to be smal and simple stuctured (easy to read in AS3- not much re- sorting in new arrays) and should hold the following:
- vertex positions
- face(triangle) vertex id´s
- uv-map vertex positions (x,y)
- uv-map face uv-vertex id´s
- texture map URL string (e.g enemyX.png)
and yes it should only hold 1 object, the engine later should then load multiple 3d object files to compose them into 1 scene. And just in case you haven´t noticed before Binary files are very smal.

For a comparison regarding the filesize I saved the 3dsmax default teapod with 4 Segments

(the one in the demo at the top of this post has only 3) in various formats:

Code:
*.3d		my format, just hit the "write file"
18.2 KB

*.obj 	alias wavefront Object file: triangles + uv coordinates 6 digits (default)
66.7 KB

*.3ds 	3d studio export format: preserve UV checked
31.5 KB

*.ASE 	ASCI scene export: mesh defenition, 4 decimals. Used in the past (perhaps still now) for UT engines
396 KB

*.DXF 	Autocad exchange format (not sure if that thingy even supports UV data)
368 KB
so why is my file so smal?
Most of the other formats save additional data like filename, material,... I tried to exclude as much as possible but I think alot is still stored as additional data. Also some of the file formats are stored as ASCI data wich means that a single Number is stored as a string wich results as a biger file and just like XML they are intended to be easily readable for the human eye so they contain alot of structural elements like returns, operator signs, ect.


As for my file I have to admit that I cheated a little bit:

- no floating values for the vertex coordinates (so no digits) instead only Short values (2^16 = range of 65536 or inAS3 = -32768 to 32767, a floating value goes beyond that). But for the engine I am aiming for this is perfect as I dont need tiny details to be zoomed into with big scales.

- the UV coordinates (x,y) are within a limited range wich can be defined in a variable like 512- so all floating values are interpreted into mapsize ranges. I did this because 99% of the UV vertex coordinates are values above 0 and below 1 so you get a lot of values such as 0.3546111231 wich would become then for example 182 (out of 512), that way I dont have to store them as floating values.

the advantages?
- smal loading times
- no parsing of string or xml objects,- just load the ByteArray in AS3 and directly access the values
- flexible workflow with maxscript,- no need for standard procedures like file>export>filetype>options>hit Save, instead create a custom interface for additional options or reduced ones, select object and hit "write".

disadvantages
- not readable in text editors (such as notepad)
- AS3 required
- needs a tool that writes the binary (e.g 3dsmax with maxscript, php, compiled EXE tool,..)


in near future I plan to write another thread about the how to do behind this,- I already made a table for myself with the byte write and reading functions in comparison with maxscript and AS3- and their range, limits,ect. It might be usefull for anyone else who wants to start with something similar to this.
When I started again learning AS3 (3rd time) I did not find any resources on reading (not writing in a variable) ByteArray data except some source code of the sandy project- and only because google suggested me it. Even the Adobe CS3 help says "advanced stuff" and doesn´t come with much explaination and examples, neither does colin moock´s essential AS 3.0. So more stuff about byteArray wouldn´t hurt