Wings 3D Development Forum
Wings file format specification - Printable Version

+- Wings 3D Development Forum (https://www.wings3d.com/forum)
+-- Forum: Wings 3D (https://www.wings3d.com/forum/forumdisplay.php?fid=1)
+--- Forum: Programming (https://www.wings3d.com/forum/forumdisplay.php?fid=7)
+--- Thread: Wings file format specification (/showthread.php?tid=874)

Pages: 1 2


Wings file format specification - scindix - 09-08-2014

Hi,
I hope I've chosen the right forum for this issue.
I want to add support for the *.wing file format in my c++ program. So I'd like to know how to do that.
I already found out that they begin with the header "#!WINGS-1.0 0D 0A 1A 04 [4 bytes that are probably matching the file size] 83 50"

The last two bytes could be the header of zlib compressed data.
My first attempt was simply trying to uncompress it with gzip -dc (with prepended gzip header). But it returns with "invalid compressed data--format violated". Also a simple php script gave me " zlib_decode() [function.zlib-decode]: data error". So am I wrong with this assumption?

Is there a complete documentation for this file type anywhere? I assume the file type is based on some specific erlang "stuff". Generally i'd like to avoid any extra dependency on a library or any other type of interface, but if there is really no other way I would accept that.

Thanks in advance for your help.


RE: Wings file format specification - ggaliens - 09-09-2014

I would advise against this trying to parse Wings file with c/c++.

Good luck, just the same.


RE: Wings file format specification - micheus - 09-09-2014

(09-08-2014, 09:46 PM)scindix Wrote: I already found out that they begin with the header "#!WINGS-1.0 0D 0A 1A 04 [4 bytes that are probably matching the file size] 83 50"
Almost. The four bytes are reference to the data size - that exclude the header string:
wings_ff_wings.erl Wrote:-define(WINGS_HEADER, "#!WINGS-1.0\r\n\032\04")
\r = #13 = 0D
\n = #10 = 0A
\032 = #32 = 20 (??)
\04 = #4 = 04
* The red one is not matching with your value.

If you are able to read the Erlang files you can find all information checking this file: wings_ff_wings.erl


RE: Wings file format specification - scindix - 09-09-2014

Quote:\032 = #32 = 20 (??)
I first wondered if I made a typo, but I didn't. I think "1A" is correct.
I'm not an expert in erlang, but I guess "\032" refers to one byte, which means that this is octal notation (3 digits). Therefore "\032 = #26 = 1A".

Also I found out that I got the erlang documentation wrong: the "real" encoded data section starts after the second header which also includes 4 bytes of data size:

wings header
#!WINGS-1.0 0D 0A 1A 04 [4 bytes (compressed size + erlang header (but without wing3d header))]
erlang header
83 50 [4 bytes (uncompressed size)]

[the "real" data section starts here !]

Now if I replace the wings header and the erlang header with a gzip header and decode it I can get a way more readable format as you can see here:

https://plus.google.com/photos/+CedricWehrum/albums/6057084545730130321/6057084549315819458?authkey=CP_84vCus_LuEQ&pid=6057084549315819458&oid=104335438816377178597

I still get an error from gzip "unexpected end of file" though. I guess I've forgotten a footer. But the output data is 5808 Bytes long which exactly matches the big endian integer from the erlang header, so everything seems fine.

Thanks for your your link. This will defenitively help me. With the erlang file specification (http://www.erlang.org/doc/apps/erts/erl_ext_dist.html ) I will now try to reverse engineer that file. Shouldn't be too hard (I hope). If I succeed I will post it here.


RE: Wings file format specification - dgud - 09-12-2014

The format have not been documented because it's made to be easy parseable from erlang and not from other languages.
We thought it was better to let the user export it another format instead of making a easily parse-able format.
What do you want to do?
There is a convert_script included in the src that can convert .wings to various output formats :-)
It need erlang and wings binary files.


RE: Wings file format specification - bigben - 06-26-2018

Hi there and sorry for jumping on an old thread...
I've run into the same question and was wondering if there is any more direct information than to read through the code (in a language I'm not familiar with).
Just to give a reason for why this is of interest, what I would like to do is to use the Wings3D application as an external CAD program so that my application can write the data it currently has to a .wing file in a temporary location, open the file using its default application (Wings3D hopefully) and then -once the user clicks save (rather than save-as for which I don't know what file name/location they may enter), have the calling application re-read the updated file back in (keeping an eye on when the file becomes updated or the newly created process being closed). There might be a way to do this by modifying the code - but that would mean I would need to support a separate fork, not at all what I want to get into.
So... has anyone got some ideas on how I should approach this? I'm using .NET so some of the compression/decompression should already be provided (assuming I'm correctly understanding this that the wings format is a compressed file with a header slapped onto the beginning {why?})

Thanks in advance for any feedback.

B


RE: Wings file format specification - dgud - 06-28-2018

Wings uses erlang serialization format for storing on disc, if I remember correctly with the exception of floats which
are stored in the standard format.

Which is described in the link posted above: http://erlang.org/doc/apps/erts/erl_ext_dist.html


RE: Wings file format specification - micheus - 06-28-2018

(09-12-2014, 12:42 PM)dgud Wrote: There is a convert_script included in the src that can convert .wings to various output formats :-)
It need erlang and wings binary files.
I couldn't find and instructions about how to use it. Is there any documentation somewhere?

It seems like - by using appropriated parameters - bigben would to fire it from his program.


RE: Wings file format specification - bigben - 06-29-2018

That might be a somewhat interesting approach, but perhaps a bit complicated. Having the option to perform the .wings -> STL/OBJ/ETC format is one part of the problem, but then I would also require the other side so that I could write to a OBJ format, for example, run the script to convert to WINGS, then call the wings application, attach a file-change-notification to that wings file and hold the main application in a wait state until the wings application-process is closed and then run the reverse (convert the temporary wings file to OBJ and read that back into my app). Seems complicated, but could be sufficiently glued together to work...
So I guess the next step for me will be to take a closer look at the convert_script file to figure out if it makes sense... so far not too clear, but perhaps more eyeball-on-screen time will change that. If anyone has used this script, it would be great to post a beginners guide to using it...


RE: Wings file format specification - dgud - 07-03-2018

Only wings_convert prints some usage.

Example: src/wings_convert -f wings --subdiv 2 ../test/glTF-Sample-Models-master/2.0/SciFiHelmet/glTF/SciFiHelmet.gltf

You will need escript in your Path and I guess (don't remember) ERL_LIBS set so it can find wings*.beam files.