16 bool FBXParser::checkHeader(std::ifstream& input)
18 string signature(
"Kaydara FBX Binary ");
20 buffer.resize(signature.length());
21 input.read(const_cast<char*>(buffer.c_str()), signature.length());
22 if (buffer.compare(signature))
return false;
26 if (c != 0x00)
return false;
28 if (c != 0x1A)
return false;
30 if (c != 0x00)
return false;
37 input.read((
char *)&version,
sizeof(uint32_t));
41 uint32_t FBXParser::readNode(std::ifstream& input, uint32_t offset)
45 uint32_t numProperties;
46 uint32_t propertyListLength;
50 input.read((
char*)&endOffset,
sizeof(uint32_t));
51 input.read((
char*)&numProperties,
sizeof(uint32_t));
52 input.read((
char*)&propertyListLength,
sizeof(uint32_t));
53 input.read((
char*)&nameLength,
sizeof(uint8_t));
54 name.resize(nameLength + 1);
55 name[nameLength + 1] = 0;
56 input.read((
char*)name.c_str(), nameLength);
57 bytes += 13 + nameLength;
64 ifstream file(fileName, ios::binary);
66 if (!file.is_open()) {
67 cerr <<
"Failed to open file." << endl;
70 if (!checkHeader(file)) {
71 cerr <<
"Not a FBX file." << endl;
75 uint32_t maxVersion = 7400;
76 if (m_version > maxVersion) {
77 cerr <<
"Unsupported FBX version " << m_version << endl;
81 uint32_t start_offset = 27;
unsigned long long ulonglong
bool loadFBX(const std::string &fileName, ulonglong &n_points, Vertex **vertices)