mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-29 11:59:54 +02:00
use root bone name from skeleton list
This commit is contained in:
parent
07d084d086
commit
d7c2231f33
3 changed files with 19 additions and 9 deletions
|
@ -14,7 +14,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
class AvatarExporter : MonoBehaviour {
|
class AvatarExporter : MonoBehaviour {
|
||||||
// update version number for every PR that changes this file, also set updated version in README file
|
// update version number for every PR that changes this file, also set updated version in README file
|
||||||
static readonly string AVATAR_EXPORTER_VERSION = "0.2";
|
static readonly string AVATAR_EXPORTER_VERSION = "0.3";
|
||||||
|
|
||||||
static readonly float HIPS_GROUND_MIN_Y = 0.01f;
|
static readonly float HIPS_GROUND_MIN_Y = 0.01f;
|
||||||
static readonly float HIPS_SPINE_CHEST_MIN_SEPARATION = 0.001f;
|
static readonly float HIPS_SPINE_CHEST_MIN_SEPARATION = 0.001f;
|
||||||
|
@ -264,7 +264,7 @@ class AvatarExporter : MonoBehaviour {
|
||||||
static string assetName = "";
|
static string assetName = "";
|
||||||
static HumanDescription humanDescription;
|
static HumanDescription humanDescription;
|
||||||
static Dictionary<string, string> dependencyTextures = new Dictionary<string, string>();
|
static Dictionary<string, string> dependencyTextures = new Dictionary<string, string>();
|
||||||
|
|
||||||
[MenuItem("High Fidelity/Export New Avatar")]
|
[MenuItem("High Fidelity/Export New Avatar")]
|
||||||
static void ExportNewAvatar() {
|
static void ExportNewAvatar() {
|
||||||
ExportSelectedAvatar(false);
|
ExportSelectedAvatar(false);
|
||||||
|
@ -302,11 +302,11 @@ class AvatarExporter : MonoBehaviour {
|
||||||
" the Rig section of it's Inspector window.", "Ok");
|
" the Rig section of it's Inspector window.", "Ok");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
humanDescription = modelImporter.humanDescription;
|
humanDescription = modelImporter.humanDescription;
|
||||||
SetUserBoneInformation();
|
SetUserBoneInformation();
|
||||||
string textureWarnings = SetTextureDependencies();
|
string textureWarnings = SetTextureDependencies();
|
||||||
|
|
||||||
// check if we should be substituting a bone for a missing UpperChest mapping
|
// check if we should be substituting a bone for a missing UpperChest mapping
|
||||||
AdjustUpperChestMapping();
|
AdjustUpperChestMapping();
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ class AvatarExporter : MonoBehaviour {
|
||||||
EditorUtility.DisplayDialog("Error", boneErrors, "Ok");
|
EditorUtility.DisplayDialog("Error", boneErrors, "Ok");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string documentsFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
|
string documentsFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
|
||||||
string hifiFolder = documentsFolder + "\\High Fidelity Projects";
|
string hifiFolder = documentsFolder + "\\High Fidelity Projects";
|
||||||
if (updateAvatar) { // Update Existing Avatar menu option
|
if (updateAvatar) { // Update Existing Avatar menu option
|
||||||
|
@ -630,12 +630,14 @@ class AvatarExporter : MonoBehaviour {
|
||||||
string boneName = modelBone.name;
|
string boneName = modelBone.name;
|
||||||
if (modelBone.parent == null) {
|
if (modelBone.parent == null) {
|
||||||
// if no parent then this is actual root bone node of the user avatar, so consider it's parent as "root"
|
// if no parent then this is actual root bone node of the user avatar, so consider it's parent as "root"
|
||||||
|
boneName = GetRootBoneName(); // ensure we use the root bone name from the skeleton list for consistency
|
||||||
userBoneTree = new BoneTreeNode(boneName); // initialize root of tree
|
userBoneTree = new BoneTreeNode(boneName); // initialize root of tree
|
||||||
userBoneInfo.parentName = "root";
|
userBoneInfo.parentName = "root";
|
||||||
userBoneInfo.boneTreeNode = userBoneTree;
|
userBoneInfo.boneTreeNode = userBoneTree;
|
||||||
} else {
|
} else {
|
||||||
// otherwise add this bone node as a child to it's parent's children list
|
// otherwise add this bone node as a child to it's parent's children list
|
||||||
string parentName = modelBone.parent.name;
|
// if its a child of the root bone, use the root bone name from the skeleton list as the parent for consistency
|
||||||
|
string parentName = modelBone.parent.parent == null ? GetRootBoneName() : modelBone.parent.name;
|
||||||
BoneTreeNode boneTreeNode = new BoneTreeNode(boneName);
|
BoneTreeNode boneTreeNode = new BoneTreeNode(boneName);
|
||||||
userBoneInfos[parentName].boneTreeNode.children.Add(boneTreeNode);
|
userBoneInfos[parentName].boneTreeNode.children.Add(boneTreeNode);
|
||||||
userBoneInfo.parentName = parentName;
|
userBoneInfo.parentName = parentName;
|
||||||
|
@ -658,7 +660,7 @@ class AvatarExporter : MonoBehaviour {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AdjustUpperChestMapping() {
|
static void AdjustUpperChestMapping() {
|
||||||
if (!humanoidToUserBoneMappings.ContainsKey("UpperChest")) {
|
if (!humanoidToUserBoneMappings.ContainsKey("UpperChest")) {
|
||||||
// if parent of Neck is not Chest then map the parent to UpperChest
|
// if parent of Neck is not Chest then map the parent to UpperChest
|
||||||
|
@ -682,6 +684,14 @@ class AvatarExporter : MonoBehaviour {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static string GetRootBoneName() {
|
||||||
|
// the "root" bone is the first element in the human skeleton bone list
|
||||||
|
if (humanDescription.skeleton.Length > 0) {
|
||||||
|
return humanDescription.skeleton[0].name;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
static void SetFailedBoneRules() {
|
static void SetFailedBoneRules() {
|
||||||
failedBoneRules.Clear();
|
failedBoneRules.Clear();
|
||||||
|
|
||||||
|
@ -901,7 +911,7 @@ class AvatarExporter : MonoBehaviour {
|
||||||
textureDirectory = textureDirectory.Replace("\\\\", "\\");
|
textureDirectory = textureDirectory.Replace("\\\\", "\\");
|
||||||
return textureDirectory;
|
return textureDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
static string SetTextureDependencies() {
|
static string SetTextureDependencies() {
|
||||||
string textureWarnings = "";
|
string textureWarnings = "";
|
||||||
dependencyTextures.Clear();
|
dependencyTextures.Clear();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
High Fidelity, Inc.
|
High Fidelity, Inc.
|
||||||
Avatar Exporter
|
Avatar Exporter
|
||||||
Version 0.2
|
Version 0.3
|
||||||
|
|
||||||
Note: It is recommended to use Unity versions between 2017.4.17f1 and 2018.2.12f1 for this Avatar Exporter.
|
Note: It is recommended to use Unity versions between 2017.4.17f1 and 2018.2.12f1 for this Avatar Exporter.
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue