QBImporter endianness inconsistencies.
winsock opened this issue ยท 1 comments
I was looking at your code for reference when writing an implementation in a program of mine in C++. I noticed that there was some inconsistencies in your endianness handling since Java is big endian only. (If you have already tested the functionality, it is possible that I'm wrong since I haven't tested my implementation fully yet.)
Line 700
This should be for more accuracy and avoiding an endianness issue with converting all 4 bytes to an int.:
byte major = din.readByte();
byte minor = din.readByte();
byte release = din.readByte();
byte version = din.readByte();
Not that it matters much, However it might in the future for checking if the binary model is made with a new version that is unsupported.
Line 701-704
This needs to be flipped like the number of matrices just for completness, you could just use your existing readTni method.
colorFormat = readTni(din);
m.rightHanded = readTni(din) != 0;
boolean compressed = readTni(din) != 0;
boolean visEncoded = readTni(din) != 0;
Also for the data, unless for some reason it works as is. These lines need to be corrected for endianness.
convertBGRAtoRGBA might need to be changed after correcting for endianness. I didn't implement this in my program.