B3D littleendian?

BlitzMax Forums/MiniB3D Module/B3D littleendian?

BLaBZ(Posted 2013) [#1]
Why is the b3d format saved in littleendian and not some generic text?

What is littleendian? A format?


BLaBZ(Posted 2013) [#2]
How do I make the b3d format more human readable?


xlsior(Posted 2013) [#3]
'Endian'-ness defines the byte order of multi-byte variables.

There's "little endian" and "big endian"

Intel processors use 'little endian' mode, while PPC (old mac), many mainframes etc. use 'big endian'.
(The name stem from the 1726 novel 'gullivers travels', where two countries are at war over a dispute on which end you should crack open an egg. A standard that's pretty much arbitrary, with no real functional difference)

In computers, all it really specifies is the order that multi-byte variables are stored in the CPU registers and computer memory.
a.g. an integer takes up 4 bytes on memory. those bytes can be stored in either ABCD order or as DCBA.
ABCD = Big Endian
DCBA = Little Endian



Much more thourough description: http://en.wikipedia.org/wiki/Endianness



How do I make the b3d format more human readable?


You don't, unless you convert it to your own format at something, at which point it's no longer B3D.


Yasha(Posted 2013) [#4]
Why is the b3d format saved in littleendian and not some generic text?


xlsior provided the details, but as to why - because text and binary are completely different things. Text is an insanely inefficient way to store data, and is only properly used when the data is intended for humans to read and edit (a "human-readable" format, e.g. XML, program source). Binary is native and takes up only as much space as data actually needs on the machine. Text needs to be "parsed", while binary data can just be loaded straight into memory and work from there.

There is no such thing as "more" human-readable. Formats are either human-readable or machine-readable (human-readable formats are usually also machine-readable, but only for translation to something native, e.g. source -> machine code). B3D is a machine-readable format and is not for humans to read or edit. You can translate the representation of B3D data structures into a human-readable format, but that's not the same thing.

Scroll up to "Specs and Utils" in the toolbar at the top and you'll find links to some utilities for dumping B3D files as lines of text (there's a minor bug in one of them that stops it working with some newer B3D models... I think it's a missing Case, can't remember - you'll find it quickly enough if you know it's there).

Alternatively, just do a "LoadAnimMesh" in miniB3D and navigate the entity hierarchy by hand (since miniB3D exposes all the naughty internals like bones and whatnot). You can extract the data you need just by asking for it and not bother with thinking about the structure of a file format that doesn't quite do what you want, then write out that data to a format that does.


BLaBZ(Posted 2013) [#5]
Fantastic explanation! Thank you


Kryzon(Posted 2013) [#6]
You should read about "serialization".

http://gamedev.stackexchange.com/questions/4202/what-is-serialization


BLaBZ(Posted 2013) [#7]
Thanks for the response!

The problem I'm ultimately having is this -
http://blitzmax.com/Community/posts.php?topic=101238

I made a deal with someone that I would encrypt their models before distributing my software.


Who was John Galt?(Posted 2013) [#8]
One tip- forget Mesh specifics and just write a general encryption routine. Bytes are bytes, it will be easier and you'll be able to encrypt anything you choose.