浏览代码

ModelView: add multi-edit on dynamic bones

lviguier 7 月之前
父节点
当前提交
0b10382ef1
共有 5 个文件被更改,包括 697 次插入677 次删除
  1. 3 0
      bin/style.css
  2. 4 0
      bin/style.less
  3. 20 14
      hide/comp/SceneEditor.hx
  4. 59 61
      hide/comp/SceneTree.hx
  5. 611 602
      hide/view/Model.hx

+ 3 - 0
bin/style.css

@@ -387,6 +387,9 @@ input[type=checkbox]:after {
 input[type=checkbox]:checked:after {
 input[type=checkbox]:checked:after {
   content: '\2714';
   content: '\2714';
 }
 }
+input[type=checkbox].indeterminate:after {
+  content: '-';
+}
 #mainmenu {
 #mainmenu {
   display: none;
   display: none;
 }
 }

+ 4 - 0
bin/style.less

@@ -420,6 +420,10 @@ input[type=checkbox] {
 	&:checked:after {
 	&:checked:after {
 		content:'\2714';
 		content:'\2714';
 	}
 	}
+
+	&.indeterminate:after {
+		content:'-';
+	}
 }
 }
 
 
 #mainmenu { display : none }
 #mainmenu { display : none }

+ 20 - 14
hide/comp/SceneEditor.hx

@@ -2754,33 +2754,39 @@ class SceneEditor {
 
 
 	var jointsGraphics : h3d.scene.Graphics = null;
 	var jointsGraphics : h3d.scene.Graphics = null;
 	@:access(h3d.scene.Skin)
 	@:access(h3d.scene.Skin)
-	public function setJoints(showJoints = true, selectedJoint : String) {
+	public function setJoints(showJoints = true, selectedJoints : Array<String>) {
 		if( showJoints ) {
 		if( showJoints ) {
 			if( jointsGraphics == null ) {
 			if( jointsGraphics == null ) {
 				jointsGraphics = new h3d.scene.Graphics(scene.s3d);
 				jointsGraphics = new h3d.scene.Graphics(scene.s3d);
 				jointsGraphics.material.mainPass.depth(false, Always);
 				jointsGraphics.material.mainPass.depth(false, Always);
 				jointsGraphics.material.mainPass.setPassName("overlay");
 				jointsGraphics.material.mainPass.setPassName("overlay");
 			}
 			}
+
 			jointsGraphics.clear();
 			jointsGraphics.clear();
+
 			for ( m in scene.s3d.getMeshes() ) {
 			for ( m in scene.s3d.getMeshes() ) {
 				var sk = Std.downcast(m,h3d.scene.Skin);
 				var sk = Std.downcast(m,h3d.scene.Skin);
 				if( sk != null ) {
 				if( sk != null ) {
-					if ( selectedJoint != null ) {
-						var topParent : h3d.scene.Object = sk;
-						while( topParent.parent != null )
-							topParent = topParent.parent;
-						jointsGraphics.follow = topParent;
-						var skinData = sk.getSkinData();
-						for( j in skinData.allJoints ) {
-							var m = sk.jointsData[j.index].currentAbsPose;
-							var mp = j.parent == null ? sk.absPos : sk.jointsData[j.parent.index].currentAbsPose;
-							if ( j.name == selectedJoint ) {
-								jointsGraphics.lineStyle(1, 0x00FF00FF);
-								jointsGraphics.moveTo(mp._41, mp._42, mp._43);
-								jointsGraphics.lineTo(m._41, m._42, m._43);
+					var topParent : h3d.scene.Object = sk;
+					while( topParent.parent != null )
+						topParent = topParent.parent;
+					jointsGraphics.follow = topParent;
+
+					if (selectedJoints != null) {
+						for (selectedJoint in selectedJoints) {
+							var skinData = sk.getSkinData();
+							for( j in skinData.allJoints ) {
+								var m = sk.jointsData[j.index].currentAbsPose;
+								var mp = j.parent == null ? sk.absPos : sk.jointsData[j.parent.index].currentAbsPose;
+								if ( j.name == selectedJoint ) {
+									jointsGraphics.lineStyle(1, 0x00FF00FF);
+									jointsGraphics.moveTo(mp._41, mp._42, mp._43);
+									jointsGraphics.lineTo(m._41, m._42, m._43);
+								}
 							}
 							}
 						}
 						}
 					}
 					}
+
 					sk.showJoints = true;
 					sk.showJoints = true;
 				}
 				}
 			}
 			}

+ 59 - 61
hide/comp/SceneTree.hx

@@ -12,68 +12,8 @@ class SceneTree extends IconTree<String> {
 		init();
 		init();
 	}
 	}
 
 
-	function resolvePath(id:String) : Dynamic {
-		var path = id.split("/");
-		var root = showRoot ? obj.parent : obj;
-		while( path.length > 0 ) {
-			var idx = Std.parseInt(path[0]);
-			if( idx == null ) break;
-			path.shift();
-			root = root.getChildAt(idx);
-		}
-		if( path.length == 0 )
-			return root;
-		var prop = path[0];
-		switch( prop.split(":").shift() ) {
-		case "mat":
-			return root.toMesh().getMaterials()[Std.parseInt(prop.substr(4))];
-		case "joint":
-			return root.getObjectByName(path.pop().substr(6));
-		}
-		return null;
-	}
-
 	override function onClick(id:String, evt: Dynamic) {
 	override function onClick(id:String, evt: Dynamic) {
-		var v : Dynamic = resolvePath(id);
-		if( Std.isOfType(v, h3d.scene.Object) )
-			onSelectObject(v);
-		else if( Std.isOfType(v, h3d.mat.Material) )
-			onSelectMaterial(v);
-	}
-
-	public dynamic function onSelectObject( obj : h3d.scene.Object ) {
-	}
-
-	public dynamic function onSelectMaterial( m : h3d.mat.Material ) {
-	}
-
-	override function applyStyle(id: String, el: Element) {
-		var v : Dynamic = resolvePath(id);
-
-		var obj = Std.downcast(v, h3d.scene.Object);
-		if( obj == null || Std.isOfType(obj,h3d.scene.Skin.Joint) ) return;
-
-		if (el.find(".ico-eye").length == 0) {
-			var visibilityToggle = new Element('<i class="ico ico-eye visibility-large-toggle"/>').appendTo(el.find(".jstree-anchor").first());
-			visibilityToggle.click(function (e) {
-				obj.visible = !obj.visible;
-				el.toggleClass("hidden", !obj.visible);
-			});
-		}
-		el.toggleClass("hidden", !obj.visible);
-	}
-
-	function getIcon( c : h3d.scene.Object ) {
-		if( c.isMesh() ) {
-			if( Std.isOfType(c, h3d.scene.Skin) )
-				return "male";
-			if( Std.isOfType(c, h3d.parts.GpuParticles) || Std.isOfType(c, h3d.parts.Particles) )
-				return "snowflake-o";
-			return "cube";
-		}
-		if( Std.isOfType(c, h3d.scene.Light) )
-			return "sun-o";
-		return "circle-o";
+		onSelectionChanged(getSelectedObjects());
 	}
 	}
 
 
 	override function get( id : String ) {
 	override function get( id : String ) {
@@ -137,6 +77,23 @@ class SceneTree extends IconTree<String> {
 		return elements;
 		return elements;
 	}
 	}
 
 
+	override function applyStyle(id: String, el: Element) {
+		var v : Dynamic = resolvePath(id);
+
+		var obj = Std.downcast(v, h3d.scene.Object);
+		if( obj == null || Std.isOfType(obj,h3d.scene.Skin.Joint) ) return;
+
+		if (el.find(".ico-eye").length == 0) {
+			var visibilityToggle = new Element('<i class="ico ico-eye visibility-large-toggle"/>').appendTo(el.find(".jstree-anchor").first());
+			visibilityToggle.click(function (e) {
+				obj.visible = !obj.visible;
+				el.toggleClass("hidden", !obj.visible);
+			});
+		}
+		el.toggleClass("hidden", !obj.visible);
+	}
+
+
 	public function getObjectName( o : h3d.scene.Object ) {
 	public function getObjectName( o : h3d.scene.Object ) {
 		if( o.name != null )
 		if( o.name != null )
 			return o.name;
 			return o.name;
@@ -145,4 +102,45 @@ class SceneTree extends IconTree<String> {
 		return o.toString() + "@" + @:privateAccess o.parent.children.indexOf(o);
 		return o.toString() + "@" + @:privateAccess o.parent.children.indexOf(o);
 	}
 	}
 
 
+
+	function resolvePath(id:String) : Dynamic {
+		var path = id.split("/");
+		var root = showRoot ? obj.parent : obj;
+		while( path.length > 0 ) {
+			var idx = Std.parseInt(path[0]);
+			if( idx == null ) break;
+			path.shift();
+			root = root.getChildAt(idx);
+		}
+		if( path.length == 0 )
+			return root;
+		var prop = path[0];
+		switch( prop.split(":").shift() ) {
+		case "mat":
+			return root.toMesh().getMaterials()[Std.parseInt(prop.substr(4))];
+		case "joint":
+			return root.getObjectByName(path.pop().substr(6));
+		}
+		return null;
+	}
+
+	function getIcon( c : h3d.scene.Object ) {
+		if( c.isMesh() ) {
+			if( Std.isOfType(c, h3d.scene.Skin) )
+				return "male";
+			if( Std.isOfType(c, h3d.parts.GpuParticles) || Std.isOfType(c, h3d.parts.Particles) )
+				return "snowflake-o";
+			return "cube";
+		}
+		if( Std.isOfType(c, h3d.scene.Light) )
+			return "sun-o";
+		return "circle-o";
+	}
+
+	function getSelectedObjects() {
+		return [for (s in getSelection()) resolvePath(s)];
+	}
+
+
+	public dynamic function onSelectionChanged(elts : Array<Dynamic>) {}
 }
 }

文件差异内容过多而无法显示
+ 611 - 602
hide/view/Model.hx


部分文件因为文件数量过多而无法显示