diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 817c870244..ea5f2163fe 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -2943,6 +2943,8 @@ void MyAvatar::setAnimGraphUrl(const QUrl& url) { connect(&(_skeletonModel->getRig()), SIGNAL(onLoadComplete()), this, SLOT(animGraphLoaded())); } +#define FAKE_Q_OS_ANDROID + void MyAvatar::initAnimGraph() { QUrl graphUrl; if (!_prefOverrideAnimGraphUrl.get().isEmpty()) { @@ -2951,6 +2953,7 @@ void MyAvatar::initAnimGraph() { graphUrl = _fstAnimGraphOverrideUrl; } else { graphUrl = PathUtils::resourcesUrl("avatar/avatar-animation.json"); + //#ifdef FAKE_Q_OS_ANDROID #ifdef Q_OS_ANDROID graphUrl = PathUtils::resourcesUrl("avatar/avatar-animation_withSplineIKNode.json"); #endif diff --git a/libraries/animation/src/AnimPoleVectorConstraint.cpp b/libraries/animation/src/AnimPoleVectorConstraint.cpp index 67fbefdf6f..998368a0c6 100644 --- a/libraries/animation/src/AnimPoleVectorConstraint.cpp +++ b/libraries/animation/src/AnimPoleVectorConstraint.cpp @@ -13,6 +13,7 @@ #include "AnimUtil.h" #include "GLMHelpers.h" +#define FAKE_Q_OS_ANDROID true; const float FRAMES_PER_SECOND = 30.0f; const float INTERP_DURATION = 6.0f; @@ -112,7 +113,8 @@ const AnimPoseVec& AnimPoleVectorConstraint::evaluate(const AnimVariantMap& anim // project poleVector on plane formed by axis. glm::vec3 poleVectorProj = poleVector - glm::dot(poleVector, unitAxis) * unitAxis; float poleVectorProjLength = glm::length(poleVectorProj); - + +//#ifdef FAKE_Q_OS_ANDROID #ifdef Q_OS_ANDROID // get theta set by optimized ik for Quest diff --git a/libraries/animation/src/Rig.cpp b/libraries/animation/src/Rig.cpp index 3cef6e677d..188f2aa790 100644 --- a/libraries/animation/src/Rig.cpp +++ b/libraries/animation/src/Rig.cpp @@ -34,6 +34,7 @@ #include "IKTarget.h" #include "PathUtils.h" +#define FAKE_Q_OS_ANDROID true; static int nextRigId = 1; static std::map rigRegistry; @@ -1459,14 +1460,15 @@ void Rig::updateHands(bool leftHandEnabled, bool rightHandEnabled, bool hipsEnab int elbowJointIndex = _animSkeleton->nameToJointIndex("LeftForeArm"); int oppositeArmJointIndex = _animSkeleton->nameToJointIndex("RightArm"); if (ENABLE_POLE_VECTORS && handJointIndex >= 0 && armJointIndex >= 0 && elbowJointIndex >= 0 && oppositeArmJointIndex >= 0) { + //#ifdef FAKE_Q_OS_ANDROID #ifdef Q_OS_ANDROID float poleTheta; bool usePoleTheta = calculateElbowPoleVectorOptimized(handJointIndex, elbowJointIndex, armJointIndex, true, poleTheta); if (usePoleTheta) { _animVars.set("leftHandPoleVectorEnabled", true); _animVars.set("leftHandPoleReferenceVector", Vectors::UNIT_X); - _animVars.set("thetaLeftElbow", transformVectorFast(sensorToRigMatrix, sensorPoleVector)); - } else { + _animVars.set("thetaLeftElbow", poleTheta); + } else { _animVars.set("leftHandPoleVectorEnabled", false); } #else @@ -1527,12 +1529,14 @@ void Rig::updateHands(bool leftHandEnabled, bool rightHandEnabled, bool hipsEnab int oppositeArmJointIndex = _animSkeleton->nameToJointIndex("LeftArm"); if (ENABLE_POLE_VECTORS && handJointIndex >= 0 && armJointIndex >= 0 && elbowJointIndex >= 0 && oppositeArmJointIndex >= 0) { + + //#ifdef FAKE_Q_OS_ANDROID #ifdef Q_OS_ANDROID float poleTheta; - bool usePoleTheta = calculateElbowPoleVectorOptimized(handJointIndex, elbowJointIndex, armJointIndex, true, poleTheta); + bool usePoleTheta = calculateElbowPoleVectorOptimized(handJointIndex, elbowJointIndex, armJointIndex, false, poleTheta); if (usePoleTheta) { _animVars.set("rightHandPoleVectorEnabled", true); - _animVars.set("rightHandPoleReferenceVector", Vectors::UNIT_X); + _animVars.set("rightHandPoleReferenceVector", -Vectors::UNIT_X); _animVars.set("thetaRightElbow", poleTheta); } else { _animVars.set("rightHandPoleVectorEnabled", false); @@ -1951,7 +1955,6 @@ bool Rig::calculateElbowPoleVectorOptimized(int handIndex, int elbowIndex, int s // remember direction of travel. const float TWIST_DEADZONE = (4 * PI) / 9.0f; - //if (!isLeft) { float twistCorrection = 0.0f; if (left) { if (fabsf(_twistThetaRunningAverageLeft) > TWIST_DEADZONE) { @@ -1985,7 +1988,8 @@ bool Rig::calculateElbowPoleVectorOptimized(int handIndex, int elbowIndex, int s } // convert to radians and make 180 0 to match pole vector theta float thetaRadians = ((180.0f - _lastThetaLeft) / 180.0f)*PI; - _animVars.set("thetaLeftElbow", thetaRadians); + //_animVars.set("thetaLeftElbow", thetaRadians); + poleTheta = thetaRadians; } else { // final global smoothing @@ -2001,7 +2005,8 @@ bool Rig::calculateElbowPoleVectorOptimized(int handIndex, int elbowIndex, int s } // convert to radians and make 180 0 to match pole vector theta float thetaRadians = ((180.0f - _lastThetaRight) / 180.0f)*PI; - _animVars.set("thetaRightElbow", thetaRadians); + //_animVars.set("thetaRightElbow", thetaRadians); + poleTheta = thetaRadians; } return true; diff --git a/tools/unity-avatar-exporter/Assets/README.txt b/tools/unity-avatar-exporter/Assets/README.txt new file mode 100644 index 0000000000..f02bc688ae --- /dev/null +++ b/tools/unity-avatar-exporter/Assets/README.txt @@ -0,0 +1,23 @@ +High Fidelity, Inc. +Avatar Exporter +Version 0.1 + +Note: It is recommended to use Unity versions between 2017.4.17f1 and 2018.2.12f1 for this Avatar Exporter. + +To create a new avatar project: +1. Import your .fbx avatar model into your Unity project's Assets by either dragging and dropping the file into the Assets window or by using Assets menu > Import New Assets. +2. Select the .fbx avatar that you imported in step 1 in the Assets window, and in the Rig section of the Inspector window set the Animation Type to Humanoid and choose Apply. +3. With the .fbx avatar still selected in the Assets window, choose High Fidelity menu > Export New Avatar. +4. Select a name for your avatar project (this will be used to create a directory with that name), as well as the target location for your project folder. +5. Once it is exported, your project directory will open in File Explorer. + +To update an existing avatar project: +1. Select the existing .fbx avatar in the Assets window that you would like to re-export. +2. Choose High Fidelity menu > Update Existing Avatar and browse to the .fst file you would like to update. +3. If the .fbx file in your Unity Assets folder is newer than the existing .fbx file in your selected avatar project or vice-versa, you will be prompted if you wish to replace the older file with the newer file before performing the update. +4. Once it is updated, your project directory will open in File Explorer. + +* WARNING * +If you are using any external textures as part of your .fbx model, be sure they are copied into the textures folder that is created in the project folder after exporting a new avatar. + +For further details including troubleshooting tips, see the full documentation at https://docs.highfidelity.com/create-and-explore/avatars/create-avatars/unity-extension