From 811e2492dff97c1ec437663a44435042e8dbf0b6 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Sat, 11 Aug 2012 04:29:21 +0200 Subject: [PATCH] - fbx: fix object names when reading binary files. --- code/FBXDocument.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/code/FBXDocument.cpp b/code/FBXDocument.cpp index da8841d08..242f52c7a 100644 --- a/code/FBXDocument.cpp +++ b/code/FBXDocument.cpp @@ -95,11 +95,24 @@ const Object* LazyObject::Get(bool dieOnError) } const char* err; - const std::string name = ParseTokenAsString(*tokens[1],err); + std::string name = ParseTokenAsString(*tokens[1],err); if (err) { DOMError(err,&element); } + // small fix for binary reading: binary fbx files don't use + // prefixes such as Model:: in front of their names. The + // loading code expects this at many places, though! + // so convert the binary representation (a 0x0001) to the + // double colon notation. + if(tokens[1]->IsBinary()) { + for (size_t i = 0; i < name.length(); ++i) { + if (name[i] == 0x0 && name[i+1] == 0x1) { + name = name.substr(i+2) + "::" + name.substr(0,i); + } + } + } + const std::string classtag = ParseTokenAsString(*tokens[2],err); if (err) { DOMError(err,&element);