internal void InitializeProperties() { this.m_ArmTwistProperty = base.serializedObject.FindProperty("m_HumanDescription.m_ArmTwist"); this.m_ForeArmTwistProperty = base.serializedObject.FindProperty("m_HumanDescription.m_ForeArmTwist"); this.m_UpperLegTwistProperty = base.serializedObject.FindProperty("m_HumanDescription.m_UpperLegTwist"); this.m_LegTwistProperty = base.serializedObject.FindProperty("m_HumanDescription.m_LegTwist"); this.m_ArmStretchProperty = base.serializedObject.FindProperty("m_HumanDescription.m_ArmStretch"); this.m_LegStretchProperty = base.serializedObject.FindProperty("m_HumanDescription.m_LegStretch"); this.m_FeetSpacingProperty = base.serializedObject.FindProperty("m_HumanDescription.m_FeetSpacing"); for (int i = 0; i < this.m_Bones.Length; i++) { SerializedProperty serializedProperty = this.m_Bones[i].GetSerializedProperty(base.serializedObject, false); if (serializedProperty != null) { this.m_Modified[i] = serializedProperty.FindPropertyRelative("m_Limit.m_Modified"); int num = HumanTrait.MuscleFromBone(i, 0); int num2 = HumanTrait.MuscleFromBone(i, 1); int num3 = HumanTrait.MuscleFromBone(i, 2); if (num != -1) { this.m_MuscleMin[num] = serializedProperty.FindPropertyRelative("m_Limit.m_Min.x"); this.m_MuscleMax[num] = serializedProperty.FindPropertyRelative("m_Limit.m_Max.x"); } if (num2 != -1) { this.m_MuscleMin[num2] = serializedProperty.FindPropertyRelative("m_Limit.m_Min.y"); this.m_MuscleMax[num2] = serializedProperty.FindPropertyRelative("m_Limit.m_Max.y"); } if (num3 != -1) { this.m_MuscleMin[num3] = serializedProperty.FindPropertyRelative("m_Limit.m_Min.z"); this.m_MuscleMax[num3] = serializedProperty.FindPropertyRelative("m_Limit.m_Max.z"); } } } }
static HumanLimit GetHumanLimit(Avatar avatar, HumanBodyBones humanBone) { var limit = new HumanLimit { useDefaultValues = true }; #if UNITY_EDITOR // this can be improved when avatar.humanDescription is exposed in unity 2019 var importer = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(avatar)) as ModelImporter; var human = (importer?.humanDescription)?.human; if (human != null) { for (int i = 0; i < human.Length; i++) { if (human[i].humanName == HumanTrait.BoneName[(int)humanBone]) { limit = human[i].limit; break; } } } #endif limit.axisLength = (float)GetAxisLength.Invoke(avatar, new object[] { humanBone }); // not in humanDescription if (limit.useDefaultValues) { Vector3 min = new Vector3(), max = new Vector3(); for (int i = 0; i < 3; i++) { var m = HumanTrait.MuscleFromBone((int)humanBone, i); min[i] = m >= 0 ? HumanTrait.GetMuscleDefaultMin(m) : 0; // invalid input will crash max[i] = m >= 0 ? HumanTrait.GetMuscleDefaultMax(m) : 0; } limit.min = min; limit.max = max; } return(limit); }
private static bool MapBipedBones(Transform root, ref Transform[] humanToTransform, List <string> report) { for (int bipedBoneIter = 0; bipedBoneIter < s_BipedBones.Length; bipedBoneIter++) { int boneIndex = s_BipedBones[bipedBoneIter].index; int parentIndex = HumanTrait.GetParentBone(boneIndex); bool required = HumanTrait.RequiredBone(boneIndex); bool parentRequired = parentIndex != -1 ? HumanTrait.RequiredBone(parentIndex) : true; Transform parentTransform = parentIndex != -1 ? humanToTransform[parentIndex] : root; if (parentTransform == null && !parentRequired) { parentIndex = HumanTrait.GetParentBone(parentIndex); parentRequired = parentIndex != -1 ? HumanTrait.RequiredBone(parentIndex) : true; parentTransform = parentIndex != -1 ? humanToTransform[parentIndex] : null; if (parentTransform == null && !parentRequired) { parentIndex = HumanTrait.GetParentBone(parentIndex); parentTransform = parentIndex != -1 ? humanToTransform[parentIndex] : null; } } humanToTransform[boneIndex] = MapBipedBone(bipedBoneIter, parentTransform, parentTransform, report); if (humanToTransform[boneIndex] == null && required) { return(false); } } return(true); }
protected void ResetMuscleToDefault() { Avatar avatar = null; // For live update, update instanciate avatar to adjust pose if (gameObject != null) { Animator animator = gameObject.GetComponent(typeof(Animator)) as Animator; avatar = animator.avatar; } for (int i = 0; i < m_MuscleCount; i++) { float min = HumanTrait.GetMuscleDefaultMin(i); float max = HumanTrait.GetMuscleDefaultMax(i); if (m_MuscleMin[i] != null && m_MuscleMax[i] != null) { m_MuscleMin[i].floatValue = m_MuscleMinEdit[i] = min; m_MuscleMax[i].floatValue = m_MuscleMaxEdit[i] = max; } int humanId = HumanTrait.BoneFromMuscle(i); if (m_Modified[humanId] != null && humanId != -1) { m_Modified[humanId].boolValue = false; } if (avatar != null) { avatar.SetMuscleMinMax(i, min, max); } } WritePose(); }
internal void ResetValuesFromProperties() { this.m_ArmTwistFactor = this.m_ArmTwistProperty.floatValue; this.m_ForeArmTwistFactor = this.m_ForeArmTwistProperty.floatValue; this.m_UpperLegTwistFactor = this.m_UpperLegTwistProperty.floatValue; this.m_LegTwistFactor = this.m_LegTwistProperty.floatValue; this.m_ArmStretchFactor = this.m_ArmStretchProperty.floatValue; this.m_LegStretchFactor = this.m_LegStretchProperty.floatValue; this.m_FeetSpacingFactor = this.m_FeetSpacingProperty.floatValue; this.m_HasTranslationDoF = this.m_HasTranslationDoFProperty.boolValue; for (int i = 0; i < this.m_Bones.Length; i++) { if (this.m_Modified[i] != null) { bool boolValue = this.m_Modified[i].boolValue; int num = HumanTrait.MuscleFromBone(i, 0); int num2 = HumanTrait.MuscleFromBone(i, 1); int num3 = HumanTrait.MuscleFromBone(i, 2); if (num != -1) { this.m_MuscleMinEdit[num] = ((!boolValue) ? HumanTrait.GetMuscleDefaultMin(num) : this.m_MuscleMin[num].floatValue); this.m_MuscleMaxEdit[num] = ((!boolValue) ? HumanTrait.GetMuscleDefaultMax(num) : this.m_MuscleMax[num].floatValue); } if (num2 != -1) { this.m_MuscleMinEdit[num2] = ((!boolValue) ? HumanTrait.GetMuscleDefaultMin(num2) : this.m_MuscleMin[num2].floatValue); this.m_MuscleMaxEdit[num2] = ((!boolValue) ? HumanTrait.GetMuscleDefaultMax(num2) : this.m_MuscleMax[num2].floatValue); } if (num3 != -1) { this.m_MuscleMinEdit[num3] = ((!boolValue) ? HumanTrait.GetMuscleDefaultMin(num3) : this.m_MuscleMin[num3].floatValue); this.m_MuscleMaxEdit[num3] = ((!boolValue) ? HumanTrait.GetMuscleDefaultMax(num3) : this.m_MuscleMax[num3].floatValue); } } } }
public static float GetMuscleDefaultMax(int muscleID) { return(HumanTrait.GetMuscleDefaultMax(muscleID)); }
internal void ResetValuesFromProperties() { m_ArmTwistFactor = m_ArmTwistProperty.floatValue; m_ForeArmTwistFactor = m_ForeArmTwistProperty.floatValue; m_UpperLegTwistFactor = m_UpperLegTwistProperty.floatValue; m_LegTwistFactor = m_LegTwistProperty.floatValue; m_ArmStretchFactor = m_ArmStretchProperty.floatValue; m_LegStretchFactor = m_LegStretchProperty.floatValue; m_FeetSpacingFactor = m_FeetSpacingProperty.floatValue; m_HasTranslationDoF = m_HasTranslationDoFProperty.boolValue; // limit is a special case, because they are added dynamicly by the editor // all the default value are wrong, we must explictly query mecanim to get the default value when // m_Modified is set to false. for (int i = 0; i < m_Bones.Length; i++) { if (m_Modified[i] != null) { bool modified = m_Modified[i].boolValue; int dx = HumanTrait.MuscleFromBone(i, 0); int dy = HumanTrait.MuscleFromBone(i, 1); int dz = HumanTrait.MuscleFromBone(i, 2); if (dx != -1) { m_MuscleMinEdit[dx] = modified ? m_MuscleMin[dx].floatValue : HumanTrait.GetMuscleDefaultMin(dx); m_MuscleMaxEdit[dx] = modified ? m_MuscleMax[dx].floatValue : HumanTrait.GetMuscleDefaultMax(dx); } if (dy != -1) { m_MuscleMinEdit[dy] = modified ? m_MuscleMin[dy].floatValue : HumanTrait.GetMuscleDefaultMin(dy); m_MuscleMaxEdit[dy] = modified ? m_MuscleMax[dy].floatValue : HumanTrait.GetMuscleDefaultMax(dy); } if (dz != -1) { m_MuscleMinEdit[dz] = modified ? m_MuscleMin[dz].floatValue : HumanTrait.GetMuscleDefaultMin(dz); m_MuscleMaxEdit[dz] = modified ? m_MuscleMax[dz].floatValue : HumanTrait.GetMuscleDefaultMax(dz); } } } }
public void DrawMuscleHandle(Transform t, int humanId) { Animator animator = gameObject.GetComponent(typeof(Animator)) as Animator; Avatar avatar = animator.avatar; int mx = HumanTrait.MuscleFromBone(humanId, 0); int my = HumanTrait.MuscleFromBone(humanId, 1); int mz = HumanTrait.MuscleFromBone(humanId, 2); float axisLen = avatar.GetAxisLength(humanId); Quaternion preQ = avatar.GetPreRotation(humanId); Quaternion postQ = avatar.GetPostRotation(humanId); preQ = t.parent.rotation * preQ; postQ = t.rotation * postQ; Vector3 normal; Vector3 from; Color alpha = new Color(1, 1, 1, 0.5f); Quaternion zyRoll = avatar.GetZYRoll(humanId, Vector3.zero); Vector3 sign = avatar.GetLimitSign(humanId); // Draw axis normal = postQ * Vector3.right; Vector3 axisEnd = t.position + (normal * axisLen); Handles.color = Color.white; Handles.DrawLine(t.position, axisEnd); if (mx != -1) { Quaternion zyPostQ = avatar.GetZYPostQ(humanId, t.parent.rotation, t.rotation); float minx = m_MuscleMinEdit[mx]; float maxx = m_MuscleMaxEdit[mx]; normal = postQ * Vector3.right; from = zyPostQ * Vector3.forward; Handles.color = Color.black; //Handles.DrawLine (t.position, t.position + (from * axisLen * 0.75f)); Vector3 xDoF = t.position + (normal * axisLen * 0.75f); normal = postQ * Vector3.right * sign.x; Quaternion q = Quaternion.AngleAxis(minx, normal); from = q * from; Handles.color = Color.yellow; //Handles.DrawLine (t.position, t.position + (from * axisLen * 0.75f)); // Draw Muscle range Handles.color = Handles.xAxisColor * alpha; Handles.DrawSolidArc(xDoF, normal, from, maxx - minx, axisLen * 0.25f); from = postQ * Vector3.forward; Handles.color = Handles.centerColor; Handles.DrawLine(xDoF, xDoF + (from * axisLen * 0.25f)); } if (my != -1) { float miny = m_MuscleMinEdit[my]; float maxy = m_MuscleMaxEdit[my]; normal = preQ * Vector3.up * sign.y; from = preQ * zyRoll * Vector3.right; Handles.color = Color.black; //Handles.DrawLine (t.position, t.position + (from * axisLen * 0.75f)); Quaternion q = Quaternion.AngleAxis(miny, normal); from = q * from; Handles.color = Color.yellow; //Handles.DrawLine (t.position, t.position + (from * axisLen * 0.75f)); // Draw Muscle range Handles.color = Handles.yAxisColor * alpha; Handles.DrawSolidArc(t.position, normal, from, maxy - miny, axisLen * 0.25f); } if (mz != -1) { float minz = m_MuscleMinEdit[mz]; float maxz = m_MuscleMaxEdit[mz]; normal = preQ * Vector3.forward * sign.z; from = preQ * zyRoll * Vector3.right; Handles.color = Color.black; //Handles.DrawLine (t.position, t.position + (from * axisLen * 0.75f)); Quaternion q = Quaternion.AngleAxis(minz, normal); from = q * from; Handles.color = Color.yellow; //Handles.DrawLine (t.position, t.position + (from * axisLen * 0.75f)); // Draw Muscle range Handles.color = Handles.zAxisColor * alpha; Handles.DrawSolidArc(t.position, normal, from, maxz - minz, axisLen * 0.25f); } }
public static string GetBoneName(int muscleId) { string[] boneName = HumanTrait.BoneName; return(boneName [HumanTrait.BoneFromMuscle(muscleId)]); }
/// <summary> /// Draws the GUI for a single bone dot. /// </summary> /// <returns>Returns true if this is being hovered</returns> public bool BoneDotGUI(Rect rect, Rect selectRect, Rect tooltipRect, int boneIndex, bool hasHover = false) { bool hover = false; Event current = Event.current; Color color = GUI.color; if (!hasHover) { if (selectRect.Contains(current.mousePosition)) { if (state == BoneState.Valid) { if (current.type == EventType.MouseDown) { if (bone == null) { state = BoneState.None; } else { Selection.activeTransform = bone; if (bone != null) { EditorGUIUtility.PingObject(bone); } } current.Use(); } else { GUI.color = kBoneSelected; GUI.DrawTexture(rect, DotSelection.image); } } GUI.color = color; GUI.Box(tooltipRect, boneName, EditorStyles.whiteMiniLabel); hover = true; } } switch (state) { case BoneState.Valid: GUI.color = kBoneValid; break; case BoneState.None: GUI.color = kBoneInactive; break; default: GUI.color = kBoneInvalid; break; } Texture image = HumanTrait.RequiredBone(boneIndex) ? DotFrame.image : DotFrameDotted.image; GUI.DrawTexture(rect, image); if (bone != null) { GUI.DrawTexture(rect, DotFill.image); } GUI.color = color; return(hover); }
protected AvatarControl.BodyPartColor IsValidBodyPart(BodyPart bodyPart) { AvatarControl.BodyPartColor bodyPartColor = AvatarControl.BodyPartColor.Off; bool flag = false; AvatarControl.BodyPartColor result; if (bodyPart != BodyPart.LeftFingers && bodyPart != BodyPart.RightFingers) { for (int i = 0; i < this.m_BodyPartHumanBone[(int)bodyPart].Length; i++) { if (this.m_BodyPartHumanBone[(int)bodyPart][i] != -1) { BoneState state = this.m_Bones[this.m_BodyPartHumanBone[(int)bodyPart][i]].state; flag |= (state == BoneState.Valid); if (HumanTrait.RequiredBone(this.m_BodyPartHumanBone[(int)bodyPart][i]) && state == BoneState.None) { result = AvatarControl.BodyPartColor.Red; return(result); } if (state != BoneState.Valid && state != BoneState.None) { result = AvatarControl.BodyPartColor.Red; return(result); } } } } else { bool flag2 = true; int num = 3; for (int j = 0; j < this.m_BodyPartHumanBone[(int)bodyPart].Length / num; j++) { bool flag3 = false; int num2 = j * num; for (int k = num - 1; k >= 0; k--) { bool flag4 = this.m_Bones[this.m_BodyPartHumanBone[(int)bodyPart][num2 + k]].state == BoneState.Valid; flag2 &= flag4; if (flag3) { if (!flag4) { result = (AvatarControl.BodyPartColor) 10; return(result); } } else { flag |= (flag3 = (!flag3 && flag4)); } } } bodyPartColor = ((!flag2) ? AvatarControl.BodyPartColor.IKRed : AvatarControl.BodyPartColor.IKGreen); } if (!flag) { result = AvatarControl.BodyPartColor.IKRed; } else { result = (AvatarControl.BodyPartColor.Green | bodyPartColor); } return(result); }
protected AvatarControl.BodyPartColor IsValidBodyPart(BodyPart bodyPart) { AvatarControl.BodyPartColor ik = AvatarControl.BodyPartColor.Off; bool hasAnyBone = false; int idx = (int)bodyPart; if (bodyPart != BodyPart.LeftFingers && bodyPart != BodyPart.RightFingers) { int i; for (i = 0; i < m_BodyPartHumanBone[idx].Length; i++) { if (m_BodyPartHumanBone[idx][i] != -1) { BoneState state = m_Bones[m_BodyPartHumanBone[idx][i]].state; hasAnyBone |= state == BoneState.Valid; // if it a required bone and no bone is set this body part is not valid if (HumanTrait.RequiredBone(m_BodyPartHumanBone[idx][i]) == true && state == BoneState.None) { return(AvatarControl.BodyPartColor.Red); } else if (state != BoneState.Valid && state != BoneState.None) { return(AvatarControl.BodyPartColor.Red); } } } } else { bool hasAllFinger = true; int i; int phalangeCount = 3; for (i = 0; i < m_BodyPartHumanBone[idx].Length / phalangeCount; i++) { bool hasFinger = false; int fingerIndex = i * phalangeCount; int j; for (j = phalangeCount - 1; j >= 0; j--) { bool hasBone = m_Bones[m_BodyPartHumanBone[idx][fingerIndex + j]].state == BoneState.Valid; hasAllFinger &= hasBone; if (hasFinger) { if (!hasBone) { return(AvatarControl.BodyPartColor.Red | AvatarControl.BodyPartColor.IKRed); } } else { hasAnyBone |= hasFinger = !hasFinger && hasBone; } } } ik = hasAllFinger ? AvatarControl.BodyPartColor.IKGreen : AvatarControl.BodyPartColor.IKRed; } if (!hasAnyBone) { return(AvatarControl.BodyPartColor.Off | AvatarControl.BodyPartColor.IKRed); } return(AvatarControl.BodyPartColor.Green | ik); }
public void DrawMuscleHandle(Transform t, int humanId) { Animator animator = base.gameObject.GetComponent(typeof(Animator)) as Animator; Avatar avatar = animator.avatar; int num = HumanTrait.MuscleFromBone(humanId, 0); int num2 = HumanTrait.MuscleFromBone(humanId, 1); int num3 = HumanTrait.MuscleFromBone(humanId, 2); float axisLength = avatar.GetAxisLength(humanId); Quaternion quaternion = avatar.GetPreRotation(humanId); Quaternion quaternion2 = avatar.GetPostRotation(humanId); quaternion = t.parent.rotation * quaternion; quaternion2 = t.rotation * quaternion2; Color b = new Color(1f, 1f, 1f, 0.5f); Quaternion zYRoll = avatar.GetZYRoll(humanId, Vector3.zero); Vector3 limitSign = avatar.GetLimitSign(humanId); Vector3 vector = quaternion2 * Vector3.right; Vector3 p = t.position + vector * axisLength; Handles.color = Color.white; Handles.DrawLine(t.position, p); if (num != -1) { Quaternion zYPostQ = avatar.GetZYPostQ(humanId, t.parent.rotation, t.rotation); float num4 = this.m_MuscleMinEdit[num]; float num5 = this.m_MuscleMaxEdit[num]; vector = quaternion2 * Vector3.right; Vector3 vector2 = zYPostQ * Vector3.forward; Handles.color = Color.black; Vector3 vector3 = t.position + vector * axisLength * 0.75f; vector = quaternion2 * Vector3.right * limitSign.x; Quaternion rotation = Quaternion.AngleAxis(num4, vector); vector2 = rotation * vector2; Handles.color = Color.yellow; Handles.color = Handles.xAxisColor * b; Handles.DrawSolidArc(vector3, vector, vector2, num5 - num4, axisLength * 0.25f); vector2 = quaternion2 * Vector3.forward; Handles.color = Handles.centerColor; Handles.DrawLine(vector3, vector3 + vector2 * axisLength * 0.25f); } if (num2 != -1) { float num6 = this.m_MuscleMinEdit[num2]; float num7 = this.m_MuscleMaxEdit[num2]; vector = quaternion * Vector3.up * limitSign.y; Vector3 vector2 = quaternion * zYRoll * Vector3.right; Handles.color = Color.black; Quaternion rotation2 = Quaternion.AngleAxis(num6, vector); vector2 = rotation2 * vector2; Handles.color = Color.yellow; Handles.color = Handles.yAxisColor * b; Handles.DrawSolidArc(t.position, vector, vector2, num7 - num6, axisLength * 0.25f); } if (num3 != -1) { float num8 = this.m_MuscleMinEdit[num3]; float num9 = this.m_MuscleMaxEdit[num3]; vector = quaternion * Vector3.forward * limitSign.z; Vector3 vector2 = quaternion * zYRoll * Vector3.right; Handles.color = Color.black; Quaternion rotation3 = Quaternion.AngleAxis(num8, vector); vector2 = rotation3 * vector2; Handles.color = Color.yellow; Handles.color = Handles.zAxisColor * b; Handles.DrawSolidArc(t.position, vector, vector2, num9 - num8, axisLength * 0.25f); } }
public static float GetBoneDefaultHierarchyMass(int boneID) { return(HumanTrait.GetBoneDefaultHierarchyMass(boneID)); }
public static HumanBodyBones GetBoneFromMuscle(int muscleID) { return((HumanBodyBones)HumanTrait.BoneFromMuscle(muscleID)); }
public static int GetMuscleFromBone(HumanBodyBones boneID, int dofID) { return(HumanTrait.MuscleFromBone((int)boneID, dofID)); }
private static bool IsBoneOptional(HumanBodyBones humanBodyBones) { return(!HumanTrait.RequiredBone((int)humanBodyBones)); }
protected override void RowGUI(RowGUIArgs args) { var muscleTreeViewItem = args.item as MuscleTreeItem; if (muscleTreeViewItem != null) { for (var i = 0; i < args.GetNumVisibleColumns(); i++) { var rect = args.GetCellRect(i); var column = (MuscleTreeColumn)args.GetColumn(i); var labelStyle = args.selected ? EditorStyles.whiteLabel : EditorStyles.label; var element = muscleTreeViewItem.MuscleElement; var index = muscleTreeViewItem.MuscleElement.MuscleId; switch (column) { case MuscleTreeColumn.InternalId: break; case MuscleTreeColumn.Id: rect.x += 15; EditorGUI.LabelField(rect, (index + 1).ToString(), labelStyle); break; case MuscleTreeColumn.CheckBox: rect.x += 25; element.IsExport = EditorGUI.Toggle(rect, element.IsExport); break; case MuscleTreeColumn.Name: rect.x += 35; EditorGUI.LabelField(rect, element.MuscleName, labelStyle); break; case MuscleTreeColumn.FloatValue: var value = EditorGUI.Slider(rect, element.MuscleValue, HumanTrait.GetMuscleDefaultMin(index), HumanTrait.GetMuscleDefaultMax(index)); element.MuscleValue = value; this.humanPose.muscles[index] = value; this.humanPoseHandler.SetHumanPose(ref this.humanPose); break; case MuscleTreeColumn.ResetButton: if (GUI.Button(rect, "Reset")) { element.MuscleValue = this.initialHumanPoseValues[index]; this.humanPose.muscles[index] = element.MuscleValue; this.humanPoseHandler.SetHumanPose(ref this.humanPose); } break; default: throw new ArgumentOutOfRangeException(Utility.NameOf(() => column), column, null); } } } else { for (var i = 0; i < args.GetNumVisibleColumns(); i++) { var rect = args.GetCellRect(i); var column = (MuscleTreeColumn)args.GetColumn(i); var boldLabelStyle = args.selected ? EditorStyles.whiteBoldLabel : EditorStyles.boldLabel; var labelStyle = args.selected ? EditorStyles.whiteLabel : EditorStyles.label; var itemID = args.item.id; var value = this.muscleRootFoldToggleTable[args.item.displayName + ":" + itemID]; switch (column) { case MuscleTreeColumn.InternalId: break; case MuscleTreeColumn.Id: rect.x += 5; EditorGUI.LabelField(rect, args.item.id.ToString(), labelStyle); break; case MuscleTreeColumn.CheckBox: rect.x += 15; rect.xMax = rect.x + 15; var toggle = EditorGUI.Toggle(rect, value); if (value != toggle) { foreach (var treeViewItem in this.rootItem.children .First(x => x.displayName == args.item.displayName).children .Cast <MuscleTreeItem>()) { treeViewItem.MuscleElement.IsExport = toggle; } this.muscleRootFoldToggleTable[args.item.displayName + ":" + itemID] = toggle; } break; case MuscleTreeColumn.Name: this.columnIndexForTreeFoldouts = 3; rect.x += this.foldoutWidth + 2; EditorGUI.LabelField(rect, args.item.displayName, boldLabelStyle); break; case MuscleTreeColumn.FloatValue: break; case MuscleTreeColumn.ResetButton: break; default: throw new ArgumentOutOfRangeException(Utility.NameOf(() => column), column, null); } } } }
public void DrawMuscleHandle(Transform t, int humanId) { Avatar avatar = (this.gameObject.GetComponent(typeof(Animator)) as Animator).avatar; int index1 = HumanTrait.MuscleFromBone(humanId, 0); int index2 = HumanTrait.MuscleFromBone(humanId, 1); int index3 = HumanTrait.MuscleFromBone(humanId, 2); float axisLength = avatar.GetAxisLength(humanId); Quaternion preRotation = avatar.GetPreRotation(humanId); Quaternion postRotation = avatar.GetPostRotation(humanId); Quaternion quaternion1 = t.parent.rotation * preRotation; Quaternion quaternion2 = t.rotation * postRotation; Color color = new Color(1f, 1f, 1f, 0.5f); Quaternion zyRoll = avatar.GetZYRoll(humanId, Vector3.zero); Vector3 limitSign = avatar.GetLimitSign(humanId); Vector3 vector3_1 = quaternion2 * Vector3.right; Vector3 p2 = t.position + vector3_1 * axisLength; Handles.color = Color.white; Handles.DrawLine(t.position, p2); if (index1 != -1) { Quaternion zyPostQ = avatar.GetZYPostQ(humanId, t.parent.rotation, t.rotation); float angle = this.m_MuscleMinEdit[index1]; float num = this.m_MuscleMaxEdit[index1]; Vector3 vector3_2 = quaternion2 * Vector3.right; Vector3 vector3_3 = zyPostQ * Vector3.forward; Handles.color = Color.black; Vector3 vector3_4 = t.position + vector3_2 * axisLength * 0.75f; Vector3 vector3_5 = quaternion2 * Vector3.right * limitSign.x; Vector3 from = Quaternion.AngleAxis(angle, vector3_5) * vector3_3; Handles.color = Color.yellow; Handles.color = Handles.xAxisColor * color; Handles.DrawSolidArc(vector3_4, vector3_5, from, num - angle, axisLength * 0.25f); Vector3 vector3_6 = quaternion2 * Vector3.forward; Handles.color = Handles.centerColor; Handles.DrawLine(vector3_4, vector3_4 + vector3_6 * axisLength * 0.25f); } if (index2 != -1) { float angle = this.m_MuscleMinEdit[index2]; float num = this.m_MuscleMaxEdit[index2]; Vector3 vector3_2 = quaternion1 * Vector3.up * limitSign.y; Vector3 vector3_3 = quaternion1 * zyRoll * Vector3.right; Handles.color = Color.black; Vector3 from = Quaternion.AngleAxis(angle, vector3_2) * vector3_3; Handles.color = Color.yellow; Handles.color = Handles.yAxisColor * color; Handles.DrawSolidArc(t.position, vector3_2, from, num - angle, axisLength * 0.25f); } if (index3 == -1) { return; } float angle1 = this.m_MuscleMinEdit[index3]; float num1 = this.m_MuscleMaxEdit[index3]; Vector3 vector3_7 = quaternion1 * Vector3.forward * limitSign.z; Vector3 vector3_8 = quaternion1 * zyRoll * Vector3.right; Handles.color = Color.black; Vector3 from1 = Quaternion.AngleAxis(angle1, vector3_7) * vector3_8; Handles.color = Color.yellow; Handles.color = Handles.zAxisColor * color; Handles.DrawSolidArc(t.position, vector3_7, from1, num1 - angle1, axisLength * 0.25f); }
public static int GetParentBone(int boneID) { return(HumanTrait.GetParentBone(boneID)); }
public void DrawMuscleHandle(Transform t, int humanId) { Vector3 vector2; Animator component = base.gameObject.GetComponent(typeof(Animator)) as Animator; Avatar avatar = component.avatar; int index = HumanTrait.MuscleFromBone(humanId, 0); int num2 = HumanTrait.MuscleFromBone(humanId, 1); int num3 = HumanTrait.MuscleFromBone(humanId, 2); float axisLength = avatar.GetAxisLength(humanId); Quaternion preRotation = avatar.GetPreRotation(humanId); Quaternion postRotation = avatar.GetPostRotation(humanId); preRotation = t.parent.rotation * preRotation; postRotation = t.rotation * postRotation; Color color = new Color(1f, 1f, 1f, 0.5f); Quaternion zYRoll = avatar.GetZYRoll(humanId, Vector3.zero); Vector3 limitSign = avatar.GetLimitSign(humanId); Vector3 axis = (Vector3)(postRotation * Vector3.right); Vector3 vector4 = t.position + ((Vector3)(axis * axisLength)); Handles.color = Color.white; Handles.DrawLine(t.position, vector4); if (index != -1) { Quaternion quaternion4 = avatar.GetZYPostQ(humanId, t.parent.rotation, t.rotation); float angle = this.m_MuscleMinEdit[index]; float num6 = this.m_MuscleMaxEdit[index]; axis = (Vector3)(postRotation * Vector3.right); vector2 = (Vector3)(quaternion4 * Vector3.forward); Handles.color = Color.black; Vector3 center = t.position + ((Vector3)((axis * axisLength) * 0.75f)); axis = (Vector3)((postRotation * Vector3.right) * limitSign.x); vector2 = (Vector3)(Quaternion.AngleAxis(angle, axis) * vector2); Handles.color = Color.yellow; Handles.color = Handles.xAxisColor * color; Handles.DrawSolidArc(center, axis, vector2, num6 - angle, axisLength * 0.25f); vector2 = (Vector3)(postRotation * Vector3.forward); Handles.color = Handles.centerColor; Handles.DrawLine(center, center + ((Vector3)((vector2 * axisLength) * 0.25f))); } if (num2 != -1) { float num7 = this.m_MuscleMinEdit[num2]; float num8 = this.m_MuscleMaxEdit[num2]; axis = (Vector3)((preRotation * Vector3.up) * limitSign.y); vector2 = (Vector3)((preRotation * zYRoll) * Vector3.right); Handles.color = Color.black; vector2 = (Vector3)(Quaternion.AngleAxis(num7, axis) * vector2); Handles.color = Color.yellow; Handles.color = Handles.yAxisColor * color; Handles.DrawSolidArc(t.position, axis, vector2, num8 - num7, axisLength * 0.25f); } if (num3 != -1) { float num9 = this.m_MuscleMinEdit[num3]; float num10 = this.m_MuscleMaxEdit[num3]; axis = (Vector3)((preRotation * Vector3.forward) * limitSign.z); vector2 = (Vector3)((preRotation * zYRoll) * Vector3.right); Handles.color = Color.black; vector2 = (Vector3)(Quaternion.AngleAxis(num9, axis) * vector2); Handles.color = Color.yellow; Handles.color = Handles.zAxisColor * color; Handles.DrawSolidArc(t.position, axis, vector2, num10 - num9, axisLength * 0.25f); } }
public static bool IsRequiredBone(int boneID) { return(HumanTrait.RequiredBone(boneID)); }