mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
Made Enable Anim Graph menu option dynamic.
It will load the anim graph when enabled and destroy the anim graph when disabled.
This commit is contained in:
parent
30264e9c3d
commit
85cb503152
4 changed files with 32 additions and 17 deletions
|
@ -714,8 +714,12 @@ void MyAvatar::setEnableRigAnimations(bool isEnabled) {
|
|||
|
||||
void MyAvatar::setEnableAnimGraph(bool isEnabled) {
|
||||
_rig->setEnableAnimGraph(isEnabled);
|
||||
if (!isEnabled) {
|
||||
// AJT: TODO: FIXME: currently setEnableAnimGraph menu item only works on startup
|
||||
if (isEnabled) {
|
||||
if (_skeletonModel.readyToAddToScene()) {
|
||||
initAnimGraph();
|
||||
}
|
||||
} else {
|
||||
destroyAnimGraph();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1234,6 +1238,20 @@ void MyAvatar::initHeadBones() {
|
|||
}
|
||||
}
|
||||
|
||||
void MyAvatar::initAnimGraph() {
|
||||
// https://gist.github.com/hyperlogic/7d6a0892a7319c69e2b9
|
||||
// python2 -m SimpleHTTPServer&
|
||||
//auto graphUrl = QUrl("http://localhost:8000/avatar.json");
|
||||
auto graphUrl = QUrl("https://gist.githubusercontent.com/hyperlogic/7d6a0892a7319c69e2b9/raw/e2cb37aee601b6fba31d60eac3f6ae3ef72d4a66/avatar.json");
|
||||
_skeletonModel.initAnimGraph(graphUrl, _skeletonModel.getGeometry()->getFBXGeometry());
|
||||
}
|
||||
|
||||
void MyAvatar::destroyAnimGraph() {
|
||||
_rig->destroyAnimGraph();
|
||||
AnimDebugDraw::getInstance().removeSkeleton("myAvatar");
|
||||
AnimDebugDraw::getInstance().removeAnimNode("myAvatar");
|
||||
}
|
||||
|
||||
void MyAvatar::preRender(RenderArgs* renderArgs) {
|
||||
|
||||
render::ScenePointer scene = Application::getInstance()->getMain3DScene();
|
||||
|
@ -1241,15 +1259,8 @@ void MyAvatar::preRender(RenderArgs* renderArgs) {
|
|||
|
||||
if (_skeletonModel.initWhenReady(scene)) {
|
||||
initHeadBones();
|
||||
|
||||
_skeletonModel.setCauterizeBoneSet(_headBoneSet);
|
||||
|
||||
// https://gist.github.com/hyperlogic/7d6a0892a7319c69e2b9
|
||||
// python2 -m SimpleHTTPServer&
|
||||
//auto graphUrl = QUrl("http://localhost:8000/avatar.json");
|
||||
auto graphUrl = QUrl("https://gist.githubusercontent.com/hyperlogic/7d6a0892a7319c69e2b9/raw/e2cb37aee601b6fba31d60eac3f6ae3ef72d4a66/avatar.json");
|
||||
|
||||
_skeletonModel.initAnimGraph(graphUrl, _skeletonModel.getGeometry()->getFBXGeometry());
|
||||
initAnimGraph();
|
||||
}
|
||||
|
||||
if (_enableDebugDrawBindPose || _enableDebugDrawAnimPose) {
|
||||
|
|
|
@ -291,6 +291,8 @@ private:
|
|||
void updateCollisionSound(const glm::vec3& penetration, float deltaTime, float frequency);
|
||||
void maybeUpdateBillboard();
|
||||
void initHeadBones();
|
||||
void initAnimGraph();
|
||||
void destroyAnimGraph();
|
||||
|
||||
// Avatar Preferences
|
||||
QUrl _fullAvatarURLFromPreferences;
|
||||
|
|
|
@ -187,12 +187,13 @@ void Rig::deleteAnimations() {
|
|||
removeAnimationHandle(animation);
|
||||
}
|
||||
_animationHandles.clear();
|
||||
destroyAnimGraph();
|
||||
}
|
||||
|
||||
if (_enableAnimGraph) {
|
||||
_animSkeleton = nullptr;
|
||||
_animLoader = nullptr;
|
||||
_animNode = nullptr;
|
||||
}
|
||||
void Rig::destroyAnimGraph() {
|
||||
_animSkeleton = nullptr;
|
||||
_animLoader = nullptr;
|
||||
_animNode = nullptr;
|
||||
}
|
||||
|
||||
void Rig::initJointStates(QVector<JointState> states, glm::mat4 rootTransform,
|
||||
|
|
|
@ -83,6 +83,7 @@ public:
|
|||
bool isRunningRole(const QString& role); // There can be multiple animations per role, so this is more general than isRunningAnimation.
|
||||
const QList<AnimationHandlePointer>& getRunningAnimations() const { return _runningAnimations; }
|
||||
void deleteAnimations();
|
||||
void destroyAnimGraph();
|
||||
const QList<AnimationHandlePointer>& getAnimationHandles() const { return _animationHandles; }
|
||||
void startAnimation(const QString& url, float fps = 30.0f, float priority = 1.0f, bool loop = false,
|
||||
bool hold = false, float firstFrame = 0.0f, float lastFrame = FLT_MAX, const QStringList& maskedJoints = QStringList());
|
||||
|
@ -193,8 +194,8 @@ public:
|
|||
QList<AnimationHandlePointer> _animationHandles;
|
||||
QList<AnimationHandlePointer> _runningAnimations;
|
||||
|
||||
bool _enableRig;
|
||||
bool _enableAnimGraph;
|
||||
bool _enableRig = false;
|
||||
bool _enableAnimGraph = false;
|
||||
glm::vec3 _lastFront;
|
||||
glm::vec3 _lastPosition;
|
||||
|
||||
|
|
Loading…
Reference in a new issue