浏览代码

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

Nicolas Cannasse 9 年之前
父节点
当前提交
da6ee65aa3
共有 2 个文件被更改,包括 11 次插入1 次删除
  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 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
 	**/
@@ -142,6 +147,11 @@ class BaseLibrary {
 	public function load( root : FbxNode ) {
 		reset();
 		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 )
 			init(c);
 

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

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