mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-08 20:36:54 +02:00
added fake android defines for running the new ik on pc
This commit is contained in:
parent
3f9b761e42
commit
36093926d0
4 changed files with 41 additions and 8 deletions
|
@ -2943,6 +2943,8 @@ void MyAvatar::setAnimGraphUrl(const QUrl& url) {
|
||||||
connect(&(_skeletonModel->getRig()), SIGNAL(onLoadComplete()), this, SLOT(animGraphLoaded()));
|
connect(&(_skeletonModel->getRig()), SIGNAL(onLoadComplete()), this, SLOT(animGraphLoaded()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define FAKE_Q_OS_ANDROID
|
||||||
|
|
||||||
void MyAvatar::initAnimGraph() {
|
void MyAvatar::initAnimGraph() {
|
||||||
QUrl graphUrl;
|
QUrl graphUrl;
|
||||||
if (!_prefOverrideAnimGraphUrl.get().isEmpty()) {
|
if (!_prefOverrideAnimGraphUrl.get().isEmpty()) {
|
||||||
|
@ -2951,6 +2953,7 @@ void MyAvatar::initAnimGraph() {
|
||||||
graphUrl = _fstAnimGraphOverrideUrl;
|
graphUrl = _fstAnimGraphOverrideUrl;
|
||||||
} else {
|
} else {
|
||||||
graphUrl = PathUtils::resourcesUrl("avatar/avatar-animation.json");
|
graphUrl = PathUtils::resourcesUrl("avatar/avatar-animation.json");
|
||||||
|
//#ifdef FAKE_Q_OS_ANDROID
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
graphUrl = PathUtils::resourcesUrl("avatar/avatar-animation_withSplineIKNode.json");
|
graphUrl = PathUtils::resourcesUrl("avatar/avatar-animation_withSplineIKNode.json");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "AnimUtil.h"
|
#include "AnimUtil.h"
|
||||||
#include "GLMHelpers.h"
|
#include "GLMHelpers.h"
|
||||||
|
|
||||||
|
#define FAKE_Q_OS_ANDROID true;
|
||||||
const float FRAMES_PER_SECOND = 30.0f;
|
const float FRAMES_PER_SECOND = 30.0f;
|
||||||
const float INTERP_DURATION = 6.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.
|
// project poleVector on plane formed by axis.
|
||||||
glm::vec3 poleVectorProj = poleVector - glm::dot(poleVector, unitAxis) * unitAxis;
|
glm::vec3 poleVectorProj = poleVector - glm::dot(poleVector, unitAxis) * unitAxis;
|
||||||
float poleVectorProjLength = glm::length(poleVectorProj);
|
float poleVectorProjLength = glm::length(poleVectorProj);
|
||||||
|
|
||||||
|
//#ifdef FAKE_Q_OS_ANDROID
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
|
|
||||||
// get theta set by optimized ik for Quest
|
// get theta set by optimized ik for Quest
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "IKTarget.h"
|
#include "IKTarget.h"
|
||||||
#include "PathUtils.h"
|
#include "PathUtils.h"
|
||||||
|
|
||||||
|
#define FAKE_Q_OS_ANDROID true;
|
||||||
|
|
||||||
static int nextRigId = 1;
|
static int nextRigId = 1;
|
||||||
static std::map<int, Rig*> rigRegistry;
|
static std::map<int, Rig*> rigRegistry;
|
||||||
|
@ -1459,14 +1460,15 @@ void Rig::updateHands(bool leftHandEnabled, bool rightHandEnabled, bool hipsEnab
|
||||||
int elbowJointIndex = _animSkeleton->nameToJointIndex("LeftForeArm");
|
int elbowJointIndex = _animSkeleton->nameToJointIndex("LeftForeArm");
|
||||||
int oppositeArmJointIndex = _animSkeleton->nameToJointIndex("RightArm");
|
int oppositeArmJointIndex = _animSkeleton->nameToJointIndex("RightArm");
|
||||||
if (ENABLE_POLE_VECTORS && handJointIndex >= 0 && armJointIndex >= 0 && elbowJointIndex >= 0 && oppositeArmJointIndex >= 0) {
|
if (ENABLE_POLE_VECTORS && handJointIndex >= 0 && armJointIndex >= 0 && elbowJointIndex >= 0 && oppositeArmJointIndex >= 0) {
|
||||||
|
//#ifdef FAKE_Q_OS_ANDROID
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
float poleTheta;
|
float poleTheta;
|
||||||
bool usePoleTheta = calculateElbowPoleVectorOptimized(handJointIndex, elbowJointIndex, armJointIndex, true, poleTheta);
|
bool usePoleTheta = calculateElbowPoleVectorOptimized(handJointIndex, elbowJointIndex, armJointIndex, true, poleTheta);
|
||||||
if (usePoleTheta) {
|
if (usePoleTheta) {
|
||||||
_animVars.set("leftHandPoleVectorEnabled", true);
|
_animVars.set("leftHandPoleVectorEnabled", true);
|
||||||
_animVars.set("leftHandPoleReferenceVector", Vectors::UNIT_X);
|
_animVars.set("leftHandPoleReferenceVector", Vectors::UNIT_X);
|
||||||
_animVars.set("thetaLeftElbow", transformVectorFast(sensorToRigMatrix, sensorPoleVector));
|
_animVars.set("thetaLeftElbow", poleTheta);
|
||||||
} else {
|
} else {
|
||||||
_animVars.set("leftHandPoleVectorEnabled", false);
|
_animVars.set("leftHandPoleVectorEnabled", false);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -1527,12 +1529,14 @@ void Rig::updateHands(bool leftHandEnabled, bool rightHandEnabled, bool hipsEnab
|
||||||
int oppositeArmJointIndex = _animSkeleton->nameToJointIndex("LeftArm");
|
int oppositeArmJointIndex = _animSkeleton->nameToJointIndex("LeftArm");
|
||||||
|
|
||||||
if (ENABLE_POLE_VECTORS && handJointIndex >= 0 && armJointIndex >= 0 && elbowJointIndex >= 0 && oppositeArmJointIndex >= 0) {
|
if (ENABLE_POLE_VECTORS && handJointIndex >= 0 && armJointIndex >= 0 && elbowJointIndex >= 0 && oppositeArmJointIndex >= 0) {
|
||||||
|
|
||||||
|
//#ifdef FAKE_Q_OS_ANDROID
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
float poleTheta;
|
float poleTheta;
|
||||||
bool usePoleTheta = calculateElbowPoleVectorOptimized(handJointIndex, elbowJointIndex, armJointIndex, true, poleTheta);
|
bool usePoleTheta = calculateElbowPoleVectorOptimized(handJointIndex, elbowJointIndex, armJointIndex, false, poleTheta);
|
||||||
if (usePoleTheta) {
|
if (usePoleTheta) {
|
||||||
_animVars.set("rightHandPoleVectorEnabled", true);
|
_animVars.set("rightHandPoleVectorEnabled", true);
|
||||||
_animVars.set("rightHandPoleReferenceVector", Vectors::UNIT_X);
|
_animVars.set("rightHandPoleReferenceVector", -Vectors::UNIT_X);
|
||||||
_animVars.set("thetaRightElbow", poleTheta);
|
_animVars.set("thetaRightElbow", poleTheta);
|
||||||
} else {
|
} else {
|
||||||
_animVars.set("rightHandPoleVectorEnabled", false);
|
_animVars.set("rightHandPoleVectorEnabled", false);
|
||||||
|
@ -1951,7 +1955,6 @@ bool Rig::calculateElbowPoleVectorOptimized(int handIndex, int elbowIndex, int s
|
||||||
|
|
||||||
// remember direction of travel.
|
// remember direction of travel.
|
||||||
const float TWIST_DEADZONE = (4 * PI) / 9.0f;
|
const float TWIST_DEADZONE = (4 * PI) / 9.0f;
|
||||||
//if (!isLeft) {
|
|
||||||
float twistCorrection = 0.0f;
|
float twistCorrection = 0.0f;
|
||||||
if (left) {
|
if (left) {
|
||||||
if (fabsf(_twistThetaRunningAverageLeft) > TWIST_DEADZONE) {
|
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
|
// convert to radians and make 180 0 to match pole vector theta
|
||||||
float thetaRadians = ((180.0f - _lastThetaLeft) / 180.0f)*PI;
|
float thetaRadians = ((180.0f - _lastThetaLeft) / 180.0f)*PI;
|
||||||
_animVars.set("thetaLeftElbow", thetaRadians);
|
//_animVars.set("thetaLeftElbow", thetaRadians);
|
||||||
|
poleTheta = thetaRadians;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// final global smoothing
|
// 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
|
// convert to radians and make 180 0 to match pole vector theta
|
||||||
float thetaRadians = ((180.0f - _lastThetaRight) / 180.0f)*PI;
|
float thetaRadians = ((180.0f - _lastThetaRight) / 180.0f)*PI;
|
||||||
_animVars.set("thetaRightElbow", thetaRadians);
|
//_animVars.set("thetaRightElbow", thetaRadians);
|
||||||
|
poleTheta = thetaRadians;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
23
tools/unity-avatar-exporter/Assets/README.txt
Normal file
23
tools/unity-avatar-exporter/Assets/README.txt
Normal file
|
@ -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
|
Loading…
Reference in a new issue