mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 21:36:47 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into arrow-actions
This commit is contained in:
commit
53ff6a239d
1 changed files with 41 additions and 14 deletions
|
@ -140,17 +140,35 @@ QVariant parseBinaryFBXProperty(QDataStream& in, int& position) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FBXNode parseBinaryFBXNode(QDataStream& in, int& position) {
|
FBXNode parseBinaryFBXNode(QDataStream& in, int& position, bool has64BitPositions = false) {
|
||||||
qint32 endOffset;
|
qint64 endOffset;
|
||||||
quint32 propertyCount;
|
quint64 propertyCount;
|
||||||
quint32 propertyListLength;
|
quint64 propertyListLength;
|
||||||
quint8 nameLength;
|
quint8 nameLength;
|
||||||
|
|
||||||
in >> endOffset;
|
// FBX 2016 and beyond uses 64bit positions in the node headers, pre-2016 used 32bit values
|
||||||
in >> propertyCount;
|
// our code generally doesn't care about the size that much, so we will use 64bit values
|
||||||
in >> propertyListLength;
|
// from here on out, but if the file is an older format we read the stream into temp 32bit
|
||||||
|
// values and then assign to our actual 64bit values.
|
||||||
|
if (has64BitPositions) {
|
||||||
|
in >> endOffset;
|
||||||
|
in >> propertyCount;
|
||||||
|
in >> propertyListLength;
|
||||||
|
position += sizeof(quint64) * 3;
|
||||||
|
} else {
|
||||||
|
qint32 tempEndOffset;
|
||||||
|
quint32 tempPropertyCount;
|
||||||
|
quint32 tempPropertyListLength;
|
||||||
|
in >> tempEndOffset;
|
||||||
|
in >> tempPropertyCount;
|
||||||
|
in >> tempPropertyListLength;
|
||||||
|
position += sizeof(quint32) * 3;
|
||||||
|
endOffset = tempEndOffset;
|
||||||
|
propertyCount = tempPropertyCount;
|
||||||
|
propertyListLength = tempPropertyListLength;
|
||||||
|
}
|
||||||
in >> nameLength;
|
in >> nameLength;
|
||||||
position += sizeof(quint32) * 3 + sizeof(quint8);
|
position += sizeof(quint8);
|
||||||
|
|
||||||
FBXNode node;
|
FBXNode node;
|
||||||
const int MIN_VALID_OFFSET = 40;
|
const int MIN_VALID_OFFSET = 40;
|
||||||
|
@ -166,7 +184,7 @@ FBXNode parseBinaryFBXNode(QDataStream& in, int& position) {
|
||||||
}
|
}
|
||||||
|
|
||||||
while (endOffset > position) {
|
while (endOffset > position) {
|
||||||
FBXNode child = parseBinaryFBXNode(in, position);
|
FBXNode child = parseBinaryFBXNode(in, position, has64BitPositions);
|
||||||
if (child.name.isNull()) {
|
if (child.name.isNull()) {
|
||||||
return node;
|
return node;
|
||||||
|
|
||||||
|
@ -327,15 +345,24 @@ FBXNode FBXReader::parseFBX(QIODevice* device) {
|
||||||
// see http://code.blender.org/index.php/2013/08/fbx-binary-file-format-specification/ for an explanation
|
// see http://code.blender.org/index.php/2013/08/fbx-binary-file-format-specification/ for an explanation
|
||||||
// of the FBX binary format
|
// of the FBX binary format
|
||||||
|
|
||||||
// skip the rest of the header
|
// The first 27 bytes contain the header.
|
||||||
const int HEADER_SIZE = 27;
|
// Bytes 0 - 20: Kaydara FBX Binary \x00(file - magic, with 2 spaces at the end, then a NULL terminator).
|
||||||
in.skipRawData(HEADER_SIZE);
|
// Bytes 21 - 22: [0x1A, 0x00](unknown but all observed files show these bytes).
|
||||||
int position = HEADER_SIZE;
|
// Bytes 23 - 26 : unsigned int, the version number. 7300 for version 7.3 for example.
|
||||||
|
const int HEADER_BEFORE_VERSION = 23;
|
||||||
|
const quint32 VERSION_FBX2016 = 7500;
|
||||||
|
in.skipRawData(HEADER_BEFORE_VERSION);
|
||||||
|
int position = HEADER_BEFORE_VERSION;
|
||||||
|
quint32 fileVersion;
|
||||||
|
in >> fileVersion;
|
||||||
|
position += sizeof(fileVersion);
|
||||||
|
qDebug() << "fileVersion:" << fileVersion;
|
||||||
|
bool has64BitPositions = (fileVersion >= VERSION_FBX2016);
|
||||||
|
|
||||||
// parse the top-level node
|
// parse the top-level node
|
||||||
FBXNode top;
|
FBXNode top;
|
||||||
while (device->bytesAvailable()) {
|
while (device->bytesAvailable()) {
|
||||||
FBXNode next = parseBinaryFBXNode(in, position);
|
FBXNode next = parseBinaryFBXNode(in, position, has64BitPositions);
|
||||||
if (next.name.isNull()) {
|
if (next.name.isNull()) {
|
||||||
return top;
|
return top;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue