new jointRotationOffset field

This commit is contained in:
David Back 2019-03-06 13:55:20 -08:00
parent a54171d60c
commit cea17985ff
3 changed files with 5 additions and 10 deletions

View file

@ -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.2";
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;
@ -551,13 +551,10 @@ class AvatarExporter : MonoBehaviour {
// generate joint rotation offsets for both humanoid-mapped bones as well as extra unmapped bones // generate joint rotation offsets for both humanoid-mapped bones as well as extra unmapped bones
Quaternion jointOffset = new Quaternion(); Quaternion jointOffset = new Quaternion();
string outputJointName = "";
if (userBoneInfo.HasHumanMapping()) { if (userBoneInfo.HasHumanMapping()) {
outputJointName = HUMANOID_TO_HIFI_JOINT_NAME[userBoneInfo.humanName];
Quaternion rotation = REFERENCE_ROTATIONS[userBoneInfo.humanName]; Quaternion rotation = REFERENCE_ROTATIONS[userBoneInfo.humanName];
jointOffset = Quaternion.Inverse(userBoneInfo.rotation) * rotation; jointOffset = Quaternion.Inverse(userBoneInfo.rotation) * rotation;
} else { } else {
outputJointName = userBoneName;
jointOffset = Quaternion.Inverse(userBoneInfo.rotation); jointOffset = Quaternion.Inverse(userBoneInfo.rotation);
string lastRequiredParent = FindLastRequiredAncestorBone(userBoneName); string lastRequiredParent = FindLastRequiredAncestorBone(userBoneName);
if (lastRequiredParent != "root") { if (lastRequiredParent != "root") {
@ -569,11 +566,9 @@ class AvatarExporter : MonoBehaviour {
} }
// swap from left-handed (Unity) to right-handed (HiFi) coordinates and write out joint rotation offset to fst // swap from left-handed (Unity) to right-handed (HiFi) coordinates and write out joint rotation offset to fst
if (!string.IsNullOrEmpty(outputJointName)) { jointOffset = new Quaternion(-jointOffset.x, jointOffset.y, jointOffset.z, -jointOffset.w);
jointOffset = new Quaternion(-jointOffset.x, jointOffset.y, jointOffset.z, -jointOffset.w); File.AppendAllText(exportFstPath, "jointRotationOffset2 = " + userBoneName + " = (" + jointOffset.x + ", " +
File.AppendAllText(exportFstPath, "jointRotationOffset = " + outputJointName + " = (" + jointOffset.x + ", " + jointOffset.y + ", " + jointOffset.z + ", " + jointOffset.w + ")\n");
jointOffset.y + ", " + jointOffset.z + ", " + jointOffset.w + ")\n");
}
} }
// open File Explorer to the project directory once finished // open File Explorer to the project directory once finished

View file

@ -1,6 +1,6 @@
High Fidelity, Inc. High Fidelity, Inc.
Avatar Exporter Avatar Exporter
Version 0.2 Version 0.3.2
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.