Ver código fonte

detect fbx version, fix bug in parser (close #121)

Nicolas Cannasse 9 anos atrás
pai
commit
da6ee65aa3
2 arquivos alterados com 11 adições e 1 exclusões
  1. 10 0
      hxd/fmt/fbx/BaseLibrary.hx
  2. 1 1
      hxd/fmt/fbx/Parser.hx

+ 10 - 0
hxd/fmt/fbx/BaseLibrary.hx

@@ -93,6 +93,11 @@ class BaseLibrary {
 	var uvAnims : Map<String, Array<{ t : Float, u : Float, v : Float }>>;
 	var uvAnims : Map<String, Array<{ t : Float, u : Float, v : Float }>>;
 	var animationEvents : Array<{ frame : Int, data : String }>;
 	var animationEvents : Array<{ frame : Int, data : String }>;
 
 
+	/**
+		The FBX version that was decoded
+	**/
+	public var version : Float = 0.;
+
 	/**
 	/**
 		Allows to prevent some terminal unskinned joints to be removed, for instance if we want to track their position
 		Allows to prevent some terminal unskinned joints to be removed, for instance if we want to track their position
 	**/
 	**/
@@ -142,6 +147,11 @@ class BaseLibrary {
 	public function load( root : FbxNode ) {
 	public function load( root : FbxNode ) {
 		reset();
 		reset();
 		this.root = root;
 		this.root = root;
+
+		version = root.get("FBXHeaderExtension.FBXVersion").props[0].toInt() / 1000;
+		if( Std.int(version) != 7 )
+			throw "FBX Version 7.x required : use FBX 2010 export";
+
 		for( c in root.childs )
 		for( c in root.childs )
 			init(c);
 			init(c);
 
 

+ 1 - 1
hxd/fmt/fbx/Parser.hx

@@ -67,7 +67,7 @@ class Parser {
 				props.push(PString(s));
 				props.push(PString(s));
 			case TIdent(s):
 			case TIdent(s):
 				props.push(PIdent(s));
 				props.push(PIdent(s));
-			case TBraceOpen, TBraceClose:
+			case TBraceOpen, TBraceClose, TNode(_):
 				token = t;
 				token = t;
 			case TLength(v):
 			case TLength(v):
 				except(TBraceOpen);
 				except(TBraceOpen);