Selaa lähdekoodia

added load animation with F2

ncannasse 11 vuotta sitten
vanhempi
commit
8f1c4385b6
1 muutettua tiedostoa jossa 18 lisäystä ja 4 poistoa
  1. 18 4
      tools/fbx/Viewer.hx

+ 18 - 4
tools/fbx/Viewer.hx

@@ -80,6 +80,7 @@ class Viewer {
 	var pMouse : flash.geom.Point;
 	var pMouse : flash.geom.Point;
 	var axis : Axis;
 	var axis : Axis;
 	var box : h3d.scene.Object;
 	var box : h3d.scene.Object;
+	var alib : h3d.fbx.Library;
 	
 	
 	function new() {
 	function new() {
 		time = 0;
 		time = 0;
@@ -171,6 +172,8 @@ class Viewer {
 			else if ( c == 52 )		props.view = 4;
 			else if ( c == 52 )		props.view = 4;
 			else if( c == K.F1 )
 			else if( c == K.F1 )
 				askLoad();
 				askLoad();
+			else if( c == K.F2 )
+				askLoad(true);
 			else if( c == K.S && k.ctrlKey ) {
 			else if( c == K.S && k.ctrlKey ) {
 				if( curFbx == null ) return;
 				if( curFbx == null ) return;
 				var data = FbxTree.toXml(curFbx.getRoot());
 				var data = FbxTree.toXml(curFbx.getRoot());
@@ -321,12 +324,22 @@ class Viewer {
 		}
 		}
 	}
 	}
 	
 	
-	function askLoad() {
+	function askLoad( ?anim ) {
 		var f = new flash.net.FileReference();
 		var f = new flash.net.FileReference();
 		f.addEventListener(flash.events.Event.COMPLETE, function(_) {
 		f.addEventListener(flash.events.Event.COMPLETE, function(_) {
 			haxe.Log.clear();
 			haxe.Log.clear();
-			props.curFbxFile = f.name;
-			loadData(f.data.readUTFBytes(f.data.length));
+			var content = f.data.readUTFBytes(f.data.length);
+			if( anim ) {
+				alib = new h3d.fbx.Library();
+				var fbx = h3d.fbx.Parser.parse(content);
+				alib.load(fbx);
+				if( !rightHand )
+					alib.leftHandConvert();
+				setSkin();
+			} else {
+				props.curFbxFile = f.name;
+				loadData(content);
+			}
 		});
 		});
 		f.addEventListener(flash.events.Event.SELECT, function(_) f.load());
 		f.addEventListener(flash.events.Event.SELECT, function(_) f.load());
 		f.browse([new flash.net.FileFilter("FBX File", "*.fbx")]);
 		f.browse([new flash.net.FileFilter("FBX File", "*.fbx")]);
@@ -402,7 +415,7 @@ class Viewer {
 	}
 	}
 	
 	
 	function setSkin() {
 	function setSkin() {
-		var anim = curFbx.loadAnimation(animMode);
+		var anim = curFbx.loadAnimation(animMode, null, null, alib);
 		if( anim != null ) {
 		if( anim != null ) {
 			anim = scene.playAnimation(anim);
 			anim = scene.playAnimation(anim);
 			if( !props.loop ) {
 			if( !props.loop ) {
@@ -499,6 +512,7 @@ class Viewer {
 		
 		
 		tf_keys.text = [
 		tf_keys.text = [
 			"[F1] Load model",
 			"[F1] Load model",
+			"[F2] Load animation",
 			"[A] Animation = " + animMode,
 			"[A] Animation = " + animMode,
 			"[L] Loop = "+props.loop,
 			"[L] Loop = "+props.loop,
 			"[Y] Axis = "+props.showAxis,
 			"[Y] Axis = "+props.showAxis,