mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 04:07:11 +02:00
Renamed AnimController to AnimManipulator, Removed offsets on IK targets
This commit is contained in:
parent
fae4b08eb0
commit
5aeebba90e
7 changed files with 41 additions and 41 deletions
|
@ -1302,7 +1302,7 @@ void MyAvatar::initAnimGraph() {
|
|||
// or run a local web-server
|
||||
// python -m SimpleHTTPServer&
|
||||
//auto graphUrl = QUrl("http://localhost:8000/avatar.json");
|
||||
auto graphUrl = QUrl("https://gist.githubusercontent.com/hyperlogic/04a02c47eb56d8bfaebb/raw/5f2a4e268d35147c83d44881e268f83a6296e89b/ik-avatar-hands.json");
|
||||
auto graphUrl = QUrl("https://gist.githubusercontent.com/hyperlogic/04a02c47eb56d8bfaebb/raw/72517b231f606b724c5169e02642e401f9af5a54/ik-avatar-hands.json");
|
||||
_rig->initAnimGraph(graphUrl, _skeletonModel.getGeometry()->getFBXGeometry());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// AnimController.cpp
|
||||
// AnimManipulator.cpp
|
||||
//
|
||||
// Created by Anthony J. Thibault on 9/8/15.
|
||||
// Copyright (c) 2015 High Fidelity, Inc. All rights reserved.
|
||||
|
@ -8,25 +8,25 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "AnimController.h"
|
||||
#include "AnimManipulator.h"
|
||||
#include "AnimUtil.h"
|
||||
#include "AnimationLogging.h"
|
||||
|
||||
AnimController::AnimController(const std::string& id, float alpha) :
|
||||
AnimNode(AnimNode::Type::Controller, id),
|
||||
AnimManipulator::AnimManipulator(const std::string& id, float alpha) :
|
||||
AnimNode(AnimNode::Type::Manipulator, id),
|
||||
_alpha(alpha) {
|
||||
|
||||
}
|
||||
|
||||
AnimController::~AnimController() {
|
||||
AnimManipulator::~AnimManipulator() {
|
||||
|
||||
}
|
||||
|
||||
const AnimPoseVec& AnimController::evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) {
|
||||
const AnimPoseVec& AnimManipulator::evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) {
|
||||
return overlay(animVars, dt, triggersOut, _skeleton->getRelativeBindPoses());
|
||||
}
|
||||
|
||||
const AnimPoseVec& AnimController::overlay(const AnimVariantMap& animVars, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) {
|
||||
const AnimPoseVec& AnimManipulator::overlay(const AnimVariantMap& animVars, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) {
|
||||
_alpha = animVars.lookup(_alphaVar, _alpha);
|
||||
|
||||
for (auto& jointVar : _jointVars) {
|
||||
|
@ -34,7 +34,7 @@ const AnimPoseVec& AnimController::overlay(const AnimVariantMap& animVars, float
|
|||
QString qJointName = QString::fromStdString(jointVar.jointName);
|
||||
jointVar.jointIndex = _skeleton->nameToJointIndex(qJointName);
|
||||
if (jointVar.jointIndex < 0) {
|
||||
qCWarning(animation) << "AnimController could not find jointName" << qJointName << "in skeleton";
|
||||
qCWarning(animation) << "AnimManipulator could not find jointName" << qJointName << "in skeleton";
|
||||
}
|
||||
jointVar.hasPerformedJointLookup = true;
|
||||
}
|
||||
|
@ -42,10 +42,12 @@ const AnimPoseVec& AnimController::overlay(const AnimVariantMap& animVars, float
|
|||
if (jointVar.jointIndex >= 0) {
|
||||
|
||||
AnimPose defaultAbsPose;
|
||||
AnimPose defaultRelPose;
|
||||
AnimPose parentAbsPose = AnimPose::identity;
|
||||
if (jointVar.jointIndex <= (int)underPoses.size()) {
|
||||
|
||||
// jointVar is an absolute rotation, if it is not set we will use the underPose as our default value
|
||||
defaultRelPose = underPoses[jointVar.jointIndex];
|
||||
defaultAbsPose = _skeleton->getAbsolutePose(jointVar.jointIndex, underPoses);
|
||||
defaultAbsPose.rot = animVars.lookup(jointVar.var, defaultAbsPose.rot);
|
||||
|
||||
|
@ -58,6 +60,7 @@ const AnimPoseVec& AnimController::overlay(const AnimVariantMap& animVars, float
|
|||
} else {
|
||||
|
||||
// jointVar is an absolute rotation, if it is not set we will use the bindPose as our default value
|
||||
defaultRelPose = AnimPose::identity;
|
||||
defaultAbsPose = _skeleton->getAbsoluteBindPose(jointVar.jointIndex);
|
||||
defaultAbsPose.rot = animVars.lookup(jointVar.var, defaultAbsPose.rot);
|
||||
|
||||
|
@ -73,14 +76,14 @@ const AnimPoseVec& AnimController::overlay(const AnimVariantMap& animVars, float
|
|||
AnimPose relPose = parentAbsPose.inverse() * defaultAbsPose;
|
||||
|
||||
// blend with underPose
|
||||
::blend(1, &underPoses[jointVar.jointIndex], &relPose, _alpha, &_poses[jointVar.jointIndex]);
|
||||
::blend(1, &defaultRelPose, &relPose, _alpha, &_poses[jointVar.jointIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
return _poses;
|
||||
}
|
||||
|
||||
void AnimController::setSkeletonInternal(AnimSkeleton::ConstPointer skeleton) {
|
||||
void AnimManipulator::setSkeletonInternal(AnimSkeleton::ConstPointer skeleton) {
|
||||
AnimNode::setSkeletonInternal(skeleton);
|
||||
|
||||
// invalidate all jointVar indices
|
||||
|
@ -99,10 +102,10 @@ void AnimController::setSkeletonInternal(AnimSkeleton::ConstPointer skeleton) {
|
|||
}
|
||||
|
||||
// for AnimDebugDraw rendering
|
||||
const AnimPoseVec& AnimController::getPosesInternal() const {
|
||||
const AnimPoseVec& AnimManipulator::getPosesInternal() const {
|
||||
return _poses;
|
||||
}
|
||||
|
||||
void AnimController::addJointVar(const JointVar& jointVar) {
|
||||
void AnimManipulator::addJointVar(const JointVar& jointVar) {
|
||||
_jointVars.push_back(jointVar);
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// AnimController.h
|
||||
// AnimManipulator.h
|
||||
//
|
||||
// Created by Anthony J. Thibault on 9/8/15.
|
||||
// Copyright (c) 2015 High Fidelity, Inc. All rights reserved.
|
||||
|
@ -8,19 +8,19 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_AnimController_h
|
||||
#define hifi_AnimController_h
|
||||
#ifndef hifi_AnimManipulator_h
|
||||
#define hifi_AnimManipulator_h
|
||||
|
||||
#include "AnimNode.h"
|
||||
|
||||
// Allows procedural control over a set of joints.
|
||||
|
||||
class AnimController : public AnimNode {
|
||||
class AnimManipulator : public AnimNode {
|
||||
public:
|
||||
friend class AnimTests;
|
||||
|
||||
AnimController(const std::string& id, float alpha);
|
||||
virtual ~AnimController() override;
|
||||
AnimManipulator(const std::string& id, float alpha);
|
||||
virtual ~AnimManipulator() override;
|
||||
|
||||
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) override;
|
||||
virtual const AnimPoseVec& overlay(const AnimVariantMap& animVars, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) override;
|
||||
|
@ -50,9 +50,9 @@ protected:
|
|||
std::vector<JointVar> _jointVars;
|
||||
|
||||
// no copies
|
||||
AnimController(const AnimController&) = delete;
|
||||
AnimController& operator=(const AnimController&) = delete;
|
||||
AnimManipulator(const AnimManipulator&) = delete;
|
||||
AnimManipulator& operator=(const AnimManipulator&) = delete;
|
||||
|
||||
};
|
||||
|
||||
#endif // hifi_AnimController_h
|
||||
#endif // hifi_AnimManipulator_h
|
|
@ -40,7 +40,7 @@ public:
|
|||
BlendLinear,
|
||||
Overlay,
|
||||
StateMachine,
|
||||
Controller,
|
||||
Manipulator,
|
||||
InverseKinematics,
|
||||
NumTypes
|
||||
};
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "AnimOverlay.h"
|
||||
#include "AnimNodeLoader.h"
|
||||
#include "AnimStateMachine.h"
|
||||
#include "AnimController.h"
|
||||
#include "AnimManipulator.h"
|
||||
#include "AnimInverseKinematics.h"
|
||||
|
||||
using NodeLoaderFunc = AnimNode::Pointer (*)(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
||||
|
@ -31,7 +31,7 @@ static AnimNode::Pointer loadClipNode(const QJsonObject& jsonObj, const QString&
|
|||
static AnimNode::Pointer loadBlendLinearNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
||||
static AnimNode::Pointer loadOverlayNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
||||
static AnimNode::Pointer loadStateMachineNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
||||
static AnimNode::Pointer loadControllerNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
||||
static AnimNode::Pointer loadManipulatorNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
||||
static AnimNode::Pointer loadInverseKinematicsNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
||||
|
||||
// called after children have been loaded
|
||||
|
@ -40,7 +40,7 @@ static bool processClipNode(AnimNode::Pointer node, const QJsonObject& jsonObj,
|
|||
static bool processBlendLinearNode(AnimNode::Pointer node, const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) { return true; }
|
||||
static bool processOverlayNode(AnimNode::Pointer node, const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) { return true; }
|
||||
bool processStateMachineNode(AnimNode::Pointer node, const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
||||
static bool processControllerNode(AnimNode::Pointer node, const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) { return true; }
|
||||
static bool processManipulatorNode(AnimNode::Pointer node, const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) { return true; }
|
||||
static bool processInverseKinematicsNode(AnimNode::Pointer node, const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) { return true; }
|
||||
|
||||
static const char* animNodeTypeToString(AnimNode::Type type) {
|
||||
|
@ -49,7 +49,7 @@ static const char* animNodeTypeToString(AnimNode::Type type) {
|
|||
case AnimNode::Type::BlendLinear: return "blendLinear";
|
||||
case AnimNode::Type::Overlay: return "overlay";
|
||||
case AnimNode::Type::StateMachine: return "stateMachine";
|
||||
case AnimNode::Type::Controller: return "controller";
|
||||
case AnimNode::Type::Manipulator: return "manipulator";
|
||||
case AnimNode::Type::InverseKinematics: return "inverseKinematics";
|
||||
case AnimNode::Type::NumTypes: return nullptr;
|
||||
};
|
||||
|
@ -62,7 +62,7 @@ static NodeLoaderFunc animNodeTypeToLoaderFunc(AnimNode::Type type) {
|
|||
case AnimNode::Type::BlendLinear: return loadBlendLinearNode;
|
||||
case AnimNode::Type::Overlay: return loadOverlayNode;
|
||||
case AnimNode::Type::StateMachine: return loadStateMachineNode;
|
||||
case AnimNode::Type::Controller: return loadControllerNode;
|
||||
case AnimNode::Type::Manipulator: return loadManipulatorNode;
|
||||
case AnimNode::Type::InverseKinematics: return loadInverseKinematicsNode;
|
||||
case AnimNode::Type::NumTypes: return nullptr;
|
||||
};
|
||||
|
@ -75,7 +75,7 @@ static NodeProcessFunc animNodeTypeToProcessFunc(AnimNode::Type type) {
|
|||
case AnimNode::Type::BlendLinear: return processBlendLinearNode;
|
||||
case AnimNode::Type::Overlay: return processOverlayNode;
|
||||
case AnimNode::Type::StateMachine: return processStateMachineNode;
|
||||
case AnimNode::Type::Controller: return processControllerNode;
|
||||
case AnimNode::Type::Manipulator: return processManipulatorNode;
|
||||
case AnimNode::Type::InverseKinematics: return processInverseKinematicsNode;
|
||||
case AnimNode::Type::NumTypes: return nullptr;
|
||||
};
|
||||
|
@ -122,7 +122,7 @@ static NodeProcessFunc animNodeTypeToProcessFunc(AnimNode::Type type) {
|
|||
static AnimNode::Type stringToEnum(const QString& str) {
|
||||
// O(n), move to map when number of types becomes large.
|
||||
const int NUM_TYPES = static_cast<int>(AnimNode::Type::NumTypes);
|
||||
for (int i = 0; i < NUM_TYPES; i++ ) {
|
||||
for (int i = 0; i < NUM_TYPES; i++) {
|
||||
AnimNode::Type type = static_cast<AnimNode::Type>(i);
|
||||
if (str == animNodeTypeToString(type)) {
|
||||
return type;
|
||||
|
@ -288,10 +288,10 @@ static AnimNode::Pointer loadStateMachineNode(const QJsonObject& jsonObj, const
|
|||
return node;
|
||||
}
|
||||
|
||||
static AnimNode::Pointer loadControllerNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) {
|
||||
static AnimNode::Pointer loadManipulatorNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) {
|
||||
|
||||
READ_FLOAT(alpha, jsonObj, id, jsonUrl, nullptr);
|
||||
auto node = std::make_shared<AnimController>(id.toStdString(), alpha);
|
||||
auto node = std::make_shared<AnimManipulator>(id.toStdString(), alpha);
|
||||
|
||||
READ_OPTIONAL_STRING(alphaVar, jsonObj);
|
||||
if (!alphaVar.isEmpty()) {
|
||||
|
@ -315,7 +315,7 @@ static AnimNode::Pointer loadControllerNode(const QJsonObject& jsonObj, const QS
|
|||
READ_STRING(var, jointObj, id, jsonUrl, nullptr);
|
||||
READ_STRING(jointName, jointObj, id, jsonUrl, nullptr);
|
||||
|
||||
AnimController::JointVar jointVar(var.toStdString(), jointName.toStdString());
|
||||
AnimManipulator::JointVar jointVar(var.toStdString(), jointName.toStdString());
|
||||
node->addJointVar(jointVar);
|
||||
};
|
||||
|
||||
|
|
|
@ -742,12 +742,10 @@ void Rig::inverseKinematics(int endIndex, glm::vec3 targetPosition, const glm::q
|
|||
|
||||
if (_enableAnimGraph && _animSkeleton) {
|
||||
if (endIndex == _leftHandJointIndex) {
|
||||
auto rootTrans = _animSkeleton->getAbsoluteBindPose(_rootJointIndex).trans;
|
||||
_animVars.set("leftHandPosition", targetPosition + rootTrans);
|
||||
_animVars.set("leftHandPosition", targetPosition);
|
||||
_animVars.set("leftHandRotation", targetRotation);
|
||||
} else if (endIndex == _rightHandJointIndex) {
|
||||
auto rootTrans = _animSkeleton->getAbsoluteBindPose(_rootJointIndex).trans;
|
||||
_animVars.set("rightHandPosition", targetPosition + rootTrans);
|
||||
_animVars.set("rightHandPosition", targetPosition);
|
||||
_animVars.set("rightHandRotation", targetRotation);
|
||||
}
|
||||
return;
|
||||
|
@ -995,10 +993,9 @@ void Rig::updateNeckJoint(int index, const HeadParameters& params) {
|
|||
glm::angleAxis(glm::radians(-params.localHeadPitch), X_AXIS));
|
||||
_animVars.set("headRotation", realLocalHeadOrientation);
|
||||
|
||||
auto rootTrans = _animSkeleton->getAbsoluteBindPose(_rootJointIndex).trans;
|
||||
// There's a theory that when not in hmd, we should _animVars.unset("headPosition").
|
||||
// However, until that works well, let's always request head be positioned where requested by hmd, camera, or default.
|
||||
_animVars.set("headPosition", params.localHeadPosition + rootTrans);
|
||||
_animVars.set("headPosition", params.localHeadPosition);
|
||||
} else if (!_enableAnimGraph) {
|
||||
|
||||
auto& state = _jointStates[index];
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
"children": []
|
||||
},
|
||||
{
|
||||
"id": "controllerOverlay",
|
||||
"id": "manipulatorOverlay",
|
||||
"type": "overlay",
|
||||
"data": {
|
||||
"alpha": 1.0,
|
||||
|
@ -42,7 +42,7 @@
|
|||
"children": [
|
||||
{
|
||||
"id": "spineLean",
|
||||
"type": "controller",
|
||||
"type": "manipulator",
|
||||
"data": {
|
||||
"alpha": 1.0,
|
||||
"joints": [
|
||||
|
|
Loading…
Reference in a new issue