mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 05:23:33 +02:00
code to generate pole vector from theta
This commit is contained in:
parent
95530e6ba5
commit
d78f253d24
3 changed files with 27 additions and 15 deletions
|
@ -2943,8 +2943,7 @@ 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
|
#define USE_Q_OS_ANDROID
|
||||||
|
|
||||||
void MyAvatar::initAnimGraph() {
|
void MyAvatar::initAnimGraph() {
|
||||||
QUrl graphUrl;
|
QUrl graphUrl;
|
||||||
if (!_prefOverrideAnimGraphUrl.get().isEmpty()) {
|
if (!_prefOverrideAnimGraphUrl.get().isEmpty()) {
|
||||||
|
@ -2953,8 +2952,8 @@ 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
|
#if defined(Q_OS_ANDROID) || defined(USE_Q_OS_ANDROID)
|
||||||
graphUrl = PathUtils::resourcesUrl("avatar/avatar-animation_withSplineIKNode.json");
|
graphUrl = PathUtils::resourcesUrl("avatar/avatar-animation_withSplineIKNode.json");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include "AnimUtil.h"
|
#include "AnimUtil.h"
|
||||||
#include "GLMHelpers.h"
|
#include "GLMHelpers.h"
|
||||||
|
|
||||||
#define FAKE_Q_OS_ANDROID true;
|
#define USE_Q_OS_ANDROID
|
||||||
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;
|
||||||
|
|
||||||
|
@ -114,8 +114,7 @@ const AnimPoseVec& AnimPoleVectorConstraint::evaluate(const AnimVariantMap& anim
|
||||||
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
|
#if defined(Q_OS_ANDROID) || defined(USE_Q_OS_ANDROID)
|
||||||
#ifdef Q_OS_ANDROID
|
|
||||||
|
|
||||||
// get theta set by optimized ik for Quest
|
// get theta set by optimized ik for Quest
|
||||||
if ((_skeleton->nameToJointIndex("RightHand") == _tipJointIndex) || (_skeleton->nameToJointIndex("LeftHand") == _tipJointIndex)) {
|
if ((_skeleton->nameToJointIndex("RightHand") == _tipJointIndex) || (_skeleton->nameToJointIndex("LeftHand") == _tipJointIndex)) {
|
||||||
|
|
|
@ -34,8 +34,7 @@
|
||||||
#include "IKTarget.h"
|
#include "IKTarget.h"
|
||||||
#include "PathUtils.h"
|
#include "PathUtils.h"
|
||||||
|
|
||||||
#define FAKE_Q_OS_ANDROID true;
|
#define USE_Q_OS_ANDROID
|
||||||
|
|
||||||
static int nextRigId = 1;
|
static int nextRigId = 1;
|
||||||
static std::map<int, Rig*> rigRegistry;
|
static std::map<int, Rig*> rigRegistry;
|
||||||
static std::mutex rigRegistryMutex;
|
static std::mutex rigRegistryMutex;
|
||||||
|
@ -1460,8 +1459,7 @@ 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
|
#if defined(Q_OS_ANDROID) || defined(USE_Q_OS_ANDROID)
|
||||||
#ifdef Q_OS_ANDROID
|
|
||||||
bool isLeft = true;
|
bool isLeft = true;
|
||||||
float poleTheta;
|
float poleTheta;
|
||||||
bool usePoleTheta = calculateElbowPoleVectorOptimized(handJointIndex, elbowJointIndex, armJointIndex, isLeft, poleTheta);
|
bool usePoleTheta = calculateElbowPoleVectorOptimized(handJointIndex, elbowJointIndex, armJointIndex, isLeft, poleTheta);
|
||||||
|
@ -1531,9 +1529,8 @@ void Rig::updateHands(bool leftHandEnabled, bool rightHandEnabled, bool hipsEnab
|
||||||
|
|
||||||
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
|
#if defined(Q_OS_ANDROID) || defined(USE_Q_OS_ANDROID)
|
||||||
#ifdef Q_OS_ANDROID
|
bool isLeft = false;
|
||||||
isLeft = false;
|
|
||||||
float poleTheta;
|
float poleTheta;
|
||||||
bool usePoleTheta = calculateElbowPoleVectorOptimized(handJointIndex, elbowJointIndex, armJointIndex, isLeft, poleTheta);
|
bool usePoleTheta = calculateElbowPoleVectorOptimized(handJointIndex, elbowJointIndex, armJointIndex, isLeft, poleTheta);
|
||||||
if (usePoleTheta) {
|
if (usePoleTheta) {
|
||||||
|
@ -1848,7 +1845,7 @@ bool Rig::calculateElbowPoleVectorOptimized(int handIndex, int elbowIndex, int s
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!left) {
|
if (!left) {
|
||||||
qCDebug(animation) << "flex ave: " << (_flexThetaRunningAverageRight / PI) * 180.0f << " twist ave: " << (_twistThetaRunningAverageRight / PI) * 180.0f << " ulnar deviation ave: " << (_ulnarRadialThetaRunningAverageRight / PI) * 180.0f;
|
//qCDebug(animation) << "flex ave: " << (_flexThetaRunningAverageRight / PI) * 180.0f << " twist ave: " << (_twistThetaRunningAverageRight / PI) * 180.0f << " ulnar deviation ave: " << (_ulnarRadialThetaRunningAverageRight / PI) * 180.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float POWER = 2.0f;
|
const float POWER = 2.0f;
|
||||||
|
@ -1995,6 +1992,23 @@ bool Rig::calculateElbowPoleVectorOptimized(int handIndex, int elbowIndex, int s
|
||||||
poleTheta = thetaRadians;
|
poleTheta = thetaRadians;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float xValue = sin(poleTheta);
|
||||||
|
float yValue = cos(poleTheta);
|
||||||
|
float zValue = 0.0f;
|
||||||
|
glm::vec3 thetaVector(xValue, yValue, zValue);
|
||||||
|
glm::vec3 xAxis = glm::cross(Vectors::UNIT_Y, armToHand);
|
||||||
|
glm::vec3 up = glm::cross(armToHand, xAxis);
|
||||||
|
glm::quat armAxisRotation;
|
||||||
|
glm::vec3 u, v, w;
|
||||||
|
glm::vec3 fwd = armToHand/glm::length(armToHand);
|
||||||
|
|
||||||
|
generateBasisVectors(Vectors::UNIT_Y, fwd, u, v, w);
|
||||||
|
AnimPose armAxisPose(glm::mat4(glm::vec4(w, 0.0f), glm::vec4(u, 0.0f), glm::vec4(v, 0.0f), glm::vec4(glm::vec3(0.0f, 0.0f, 0.0f), 1.0f)));
|
||||||
|
glm::vec3 pole = armAxisPose * thetaVector;
|
||||||
|
|
||||||
|
qCDebug(animation) << "the pole from theta is " << pole;
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue