Jelajahi Sumber

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

Nicolas Cannasse 9 tahun lalu
induk
melakukan
da6ee65aa3
2 mengubah file dengan 11 tambahan dan 1 penghapusan
  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);