浏览代码

adding feedback fixes

/validation-tool
Wesley Mareovich Smith 4 年前
当前提交
cfbc8ebd
共有 4 个文件被更改,包括 66 次插入71 次删除
  1. 20
      com.unity.perception/Editor/Character/CharacterTooling.cs
  2. 11
      com.unity.perception/Editor/Character/CharacterToolingLibrary.cs
  3. 104
      com.unity.perception/Editor/Character/CharacterToolingUI.cs
  4. 2
      com.unity.perception/Tests/Editor/CharacterToolingTests.cs

20
com.unity.perception/Editor/Character/CharacterTooling.cs


using System.Collections.Generic;
using static UnityEngine.Perception.Content.CharacterValidation;
using System.Linq;
using UnityEngine.Perception.GroundTruth;

/// </summary>
/// <param name="selection">target character selected</param>
/// <param name="failed">Dictionary return if of Human Bones that tracks they are prsent or missing</param>
/// <returns></returns>
/// <returns>True if all 15 bones are present, otherwise false</returns>
var result = AvatarRequiredBones(selection);
var result = CharacterValidation.AvatarRequiredBones(selection);
failed = new Dictionary<HumanBone, bool>();
for (int i = 0; i < result.Count; i++)

/// </summary>
/// <param name="gameObject">Target character selected</param>
/// <param name="failedGameObjects">List of game objects that don't have nay pose data</param>
/// <returns></returns>
/// <returns>The count of failed bones</returns>
public bool CharacterPoseData(GameObject gameObject, out List<GameObject> failedGameObjects)
{
failedGameObjects = new List<GameObject>();

/// <param name="selection"></param>
/// <param name="drawRays"></param>
/// <param name="savePath"></param>
/// <returns></returns>
/// <returns>True if the model is created, false and a new game object named Failed if the model wasn't created</returns>
newModel = AvatarCreateNoseEars(selection, keypointTemplate, savePath, drawRays);
newModel = CharacterValidation.AvatarCreateNoseEars(selection, keypointTemplate, savePath, drawRays);
if (newModel.name.Contains("Failed"))
{

else return true;
}
/// <summary>
/// Validates the model to ensure the nose, ear L & R are created
/// </summary>
/// <param name="selection">Game Object selected by tge yser</param>
/// <returns>True if the nose, ear L & R was created, false if the joints are missing</returns>
public bool ValidateNoseAndEars(GameObject selection)
{
var jointLabels = selection.GetComponentsInChildren<JointLabel>();

earLeft = true;
}
if (nose && earRight && earLeft)
return true;
else return false;
return nose && earRight && earLeft;
}
}
}

11
com.unity.perception/Editor/Character/CharacterToolingLibrary.cs


{
public static class CharacterValidation
{
public static string[] RequiredBones =
public static string[] s_RequiredBones =
{
"Head",
"Hips",

"RightUpperLeg",
"RightLowerLeg",
"RightFoot",
};
public static string[] NeededBones =
{
};
/// <summary>

for(int h = 0; h < human.Length; h++)
{
for (int b = 0; b < RequiredBones.Length; b++)
for (int b = 0; b < s_RequiredBones.Length; b++)
if(human[h].humanName == RequiredBones[b])
if(human[h].humanName == s_RequiredBones[b])
{
if (human[h].boneName != null)
{

104
com.unity.perception/Editor/Character/CharacterToolingUI.cs


using UnityEngine.Perception.Content;
using MenuItem = UnityEditor.MenuItem;
using UnityEngine;
using static UnityEngine.Perception.Content.CharacterValidation;
using UnityEngine.UI;
static string[] toolbarNames = null;
static string[] s_ToolbarNames = null;
CharacterTooling m_contentTests = new CharacterTooling();
UnityEngine.Object keypointTemplate;
CharacterTooling m_ContentTests = new CharacterTooling();
UnityEngine.Object m_KeypointTemplate;
GameObject selection = null;
int toolbarSelection = 0;
bool drawFaceRays = false;
bool apiResult = false;
bool checkJoints = false;
bool vaildCharacter = false;
string savePath = "Assets/";
string status = "Unknown";
GameObject m_Selection = null;
int m_ToolbarSelection = 0;
bool m_DrawFaceRays = false;
bool m_ApiResult = false;
bool m_CheckJoints = false;
bool m_VaildCharacter = false;
string m_SavePath = "Assets/";
string m_Status = "Unknown";
selection = Selection.activeGameObject;
m_Selection = Selection.activeGameObject;
if(selection != null)
if(m_Selection != null)
var head = FindBodyPart("head", selection.transform);
var leftEye = FindBodyPart("leftEye", selection.transform);
var rightEye = FindBodyPart("rightEye", selection.transform);
var head = CharacterValidation.FindBodyPart("head", m_Selection.transform);
var leftEye = CharacterValidation.FindBodyPart("leftEye", m_Selection.transform);
var rightEye = CharacterValidation.FindBodyPart("rightEye", m_Selection.transform);
status = "Character ready to add joints";
vaildCharacter = true;
checkJoints = m_contentTests.ValidateNoseAndEars(selection);
m_Status = "Character ready to add joints";
m_VaildCharacter = true;
m_CheckJoints = m_ContentTests.ValidateNoseAndEars(m_Selection);
status = "Missing either the head/left or right eye joint transforms!";
vaildCharacter = false;
m_Status = "Missing either the head/left or right eye joint transforms!";
m_VaildCharacter = false;
}
}
}

Repaint();
selection = Selection.activeGameObject;
m_Selection = Selection.activeGameObject;
toolbarNames = new string[] { "Keypoints", "Validation" };
s_ToolbarNames = new string[] { "Keypoints", "Validation" };
CharacterToolingUI window = (CharacterToolingUI)GetWindow(typeof(CharacterToolingUI));
window.autoRepaintOnSceneChange = true;
window.Show();

{
if (selection != null && selection.GetType() == typeof(GameObject))
if (m_Selection != null && m_Selection.GetType() == typeof(GameObject))
EditorGUILayout.TextField("Selected Character : ", selection.name);
savePath = EditorGUILayout.TextField("Prefab Save Location : ", savePath);
EditorGUILayout.TextField("Selected GameObject : ", m_Selection.name);
m_SavePath = EditorGUILayout.TextField("Prefab Save Location : ", m_SavePath);
keypointTemplate = EditorGUILayout.ObjectField(keypointTemplate, typeof(KeypointTemplate), true, GUILayout.MaxWidth(500));
m_KeypointTemplate = EditorGUILayout.ObjectField(m_KeypointTemplate, typeof(KeypointTemplate), true, GUILayout.MaxWidth(500));
toolbarSelection = GUILayout.Toolbar(toolbarSelection, toolbarNames);
m_ToolbarSelection = GUILayout.Toolbar(m_ToolbarSelection, s_ToolbarNames);
switch (toolbarSelection)
switch (m_ToolbarSelection)
{
case 0:
GUILayout.Label("Character Tools", EditorStyles.whiteLargeLabel);

var failedPose = new List<GameObject>();
GameObject newModel;
drawFaceRays = GUILayout.Toggle(drawFaceRays, "Draw Face Rays");
GUILayout.Label(string.Format("Create Ears and Nose: {0}", apiResult), EditorStyles.boldLabel);
GUILayout.Label(string.Format("Ears and Nose status: {0}", status), EditorStyles.boldLabel);
m_DrawFaceRays = GUILayout.Toggle(m_DrawFaceRays, "Draw Face Rays");
GUILayout.Label(string.Format("Create Ears and Nose: {0}", m_ApiResult), EditorStyles.boldLabel);
GUILayout.Label(string.Format("Ears and Nose status: {0}", m_Status), EditorStyles.boldLabel);
if (checkJoints)
if (m_CheckJoints)
status = "Joints already exist";
m_Status = "Joints already exist";
else if (!checkJoints && vaildCharacter)
else if (!m_CheckJoints && m_VaildCharacter)
status = "Joints don't exist";
m_Status = "Joints don't exist";
if (savePath == "Assets/")
apiResult = m_contentTests.CharacterCreateNose(selection, out newModel, keypointTemplate, drawFaceRays);
if (m_SavePath == "Assets/")
m_ApiResult = m_ContentTests.CharacterCreateNose(m_Selection, out newModel, m_KeypointTemplate, m_DrawFaceRays);
apiResult = m_contentTests.CharacterCreateNose(selection, out newModel, keypointTemplate, drawFaceRays, savePath);
m_ApiResult = m_ContentTests.CharacterCreateNose(m_Selection, out newModel, m_KeypointTemplate, m_DrawFaceRays, m_SavePath);
var modelValidate = m_contentTests.ValidateNoseAndEars(newModel);
var modelValidate = m_ContentTests.ValidateNoseAndEars(newModel);
status = "Ear and Nose joints created";
m_Status = "Ear and Nose joints created";
status = "Failed to create the Ear and Nose joints";
m_Status = "Failed to create the Ear and Nose joints";
}
}

GUILayout.Label("Character Validation", EditorStyles.whiteLargeLabel);
GUILayout.Label(string.Format("Validation for Character : {0}", apiResult), EditorStyles.whiteLabel);
GUILayout.Label(string.Format("Validation for Character : {0}", m_ApiResult), EditorStyles.whiteLabel);
var animator = selection.GetComponentInChildren<Animator>();
var animator = m_Selection.GetComponentInChildren<Animator>();
if (animator != null)
{

if (GUILayout.Button("Validate Bones", GUILayout.Width(160)))
{
apiResult = m_contentTests.CharacterRequiredBones(selection, out failedBones);
m_ApiResult = m_ContentTests.CharacterRequiredBones(m_Selection, out failedBones);
for (int i = 0; i < RequiredBones.Length; i++)
for (int i = 0; i < CharacterValidation.s_RequiredBones.Length; i++)
{
for (int b = 0; b < failedBones.Count; b++)
{

if (RequiredBones[i] == boneKey.humanName)
if (CharacterValidation.s_RequiredBones[i] == boneKey.humanName)
GUILayout.Label(string.Format("Bone {0}: {1}", RequiredBones[i], "Missing"), EditorStyles.boldLabel);
GUILayout.Label(string.Format("Bone {0}: {1}", CharacterValidation.s_RequiredBones[i], "Missing"), EditorStyles.boldLabel);
}
}
}

GUILayout.Label(string.Format("Required Bones Present : {0}", apiResult), EditorStyles.whiteLabel);
GUILayout.Label(string.Format("Required Bones Present : {0}", m_ApiResult), EditorStyles.whiteLabel);
}
}

apiResult = m_contentTests.CharacterPoseData(selection, out failedPose);
m_ApiResult = m_ContentTests.CharacterPoseData(m_Selection, out failedPose);
}
break;

{
GUILayout.Label("The selected assets is invalid, please select a different Game Object.", EditorStyles.boldLabel);
GUILayout.Label("The selected asset(s) is invalid, please select a Game Object.", EditorStyles.boldLabel);
}
}
}

2
com.unity.perception/Tests/Editor/CharacterToolingTests.cs


{
public List<GameObject> selectionLists = new List<GameObject>();
public List<string> assets = new List<string>();
private CharacterTooling contentTests = new CharacterTooling();
CharacterTooling contentTests = new CharacterTooling();
[SetUp]
public void Setup()

正在加载...
取消
保存