niftools / nifskope

A git repository for nifskope.
http://www.niftools.org
Other
556 stars 237 forks source link

Incorrect handling of big endian files #83

Open ttl269 opened 9 years ago

ttl269 commented 9 years ago

@jonwd7 It seems that Nifskope internally works with loaded nif data in little endian byte order. When I open big endian nif and then save it, I get file where most of data is converted into little endian byte order even if in the header there is still set big endian byte order - that is bad but let's say that Nifskope is not able to save nif files in big endian byte order. So, I open big endian nif file, change its Endian Type to Endian_Little in its header and save it. And here is a problem: Nifskope don't convert some storage types into little endian and leaves them in original byte order. For that time I found two - Matrix33 and Color3. Because Matrix33 is widely used for rotation, Nifskope don't render anything for example any child of NiNode with that bad rotation, any NiTriShape with bad rotation, any NiSkinData with bad rotation in Skin Transform… @jonwd7 Can you look at this issue - why these storage types (and maybe more of them) are not converted from big endian into little endian? For example Quaternion seems to be ok, floats, shorts are ok… It would be great if Niskope could at least successfully open big endian byte order nif and save it in little endian byte order. And maybe Nifskoe could pop some warning message while opening big endian nif file. Here is needed data - two example nifs (original, 20.3.0.9, big endian) and nif.xml to open them successfully in Nifskope. Note: there is also one issue related to Extra Vectors Flags and Num UV Sets. Due to authors of that big endian nif file assumed that these two parameters are one (stored in short - as two-byte), these two bytes are also swapped in their nif file. And saving that nif in little endian order causes loosing Tangents, Bitangents and UV Data - even that this reversed order is covered in nif.xml (by conditions), changing Endian Type to little endian in Nifskope fills them with 0. But it is not Nifskope error. This will have to be solved separately and I am afraid that on Nifskope's side, because there is no support for bit shift operations in conditions in nif.xml.

hexabits commented 9 years ago

Relevant topic about the issue where one of the above files comes from.