Kaynağa Gözat

FBX: Save all animations to HMD. (#464)

Pavel Alexandrov 6 yıl önce
ebeveyn
işleme
1290db576b
2 değiştirilmiş dosya ile 15 ekleme ve 2 silme
  1. 11 0
      hxd/fmt/fbx/BaseLibrary.hx
  2. 4 2
      hxd/fmt/fbx/HMDOut.hx

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

@@ -730,6 +730,17 @@ class BaseLibrary {
 		return hasValue;
 	}
 
+	/**
+		Returns an array of names with all animations present in FBX file.
+	**/
+	public function getAnimationNames() : Array<String> {
+		var names = [];
+		for ( a in this.root.getAll("Objects.AnimationStack") ) {
+			names.push(a.getName());
+		}
+		return names;
+	}
+
 	public function loadAnimation( ?animName : String, ?root : FbxNode, ?lib : BaseLibrary ) : h3d.anim.Animation {
 		if( lib != null ) {
 			lib.defaultModelMatrixes = defaultModelMatrixes;

+ 4 - 2
hxd/fmt/fbx/HMDOut.hx

@@ -805,9 +805,11 @@ class HMDOut extends BaseLibrary {
 
 		addModels(includeGeometry);
 
-		var anim = loadAnimation();
-		if( anim != null )
+		var names = getAnimationNames();
+		for ( animName in names ) {
+			var anim = loadAnimation(animName);
 			d.animations.push(makeAnimation(anim));
+		}
 
 		d.data = dataOut.getBytes();
 		return d;