Bug fix to AnimNode::setSkeletonModel and AnimNodeLoader.

Also updated avatar.json to test nested graphs under a SM.
This commit is contained in:
Anthony J. Thibault 2015-08-28 17:16:32 -07:00
parent 21c6ba9bdf
commit 9d983e0614
4 changed files with 99 additions and 11 deletions

View file

@ -167,7 +167,7 @@ void MyAvatar::update(float deltaTime) {
static float t = 0.0f;
_animVars.set("sine", 0.5f * sin(t) + 0.5f);
if (glm::length(getVelocity()) > 0.01) {
if (glm::length(getVelocity()) > 0.07f) {
_animVars.set("isMoving", true);
_animVars.set("isNotMoving", false);
} else {
@ -1245,12 +1245,14 @@ void MyAvatar::setupNewAnimationSystem() {
// load the anim graph
// https://gist.github.com/hyperlogic/7d6a0892a7319c69e2b9
auto graphUrl = QUrl("https://gist.githubusercontent.com/hyperlogic/7d6a0892a7319c69e2b9/raw/250ce1f207e23c74694351f04367063cf1269f94/avatar.json");
// python2 -m SimpleHTTPServer&
//auto graphUrl = QUrl("http://localhost:8000/avatar.json");
auto graphUrl = QUrl("https://gist.githubusercontent.com/hyperlogic/7d6a0892a7319c69e2b9/raw/403651948de088ca4dcdda4f873e225b091c779a/avatar.json");
_animLoader.reset(new AnimNodeLoader(graphUrl));
connect(_animLoader.get(), &AnimNodeLoader::success, [this](AnimNode::Pointer nodeIn) {
_animNode = nodeIn;
_animNode->setSkeleton(_animSkeleton);
AnimPose xform(_skeletonModel.getScale(), glm::quat(), _skeletonModel.getOffset() + glm::vec3(0, 0, 1));
AnimPose xform(_skeletonModel.getScale() / 10.0f, glm::quat(), _skeletonModel.getOffset() + glm::vec3(0, 0, 1));
AnimDebugDraw::getInstance().addAnimNode("node", _animNode, xform);
});
connect(_animLoader.get(), &AnimNodeLoader::error, [this, graphUrl](int error, QString str) {

View file

@ -70,7 +70,7 @@ public:
void setSkeleton(const AnimSkeleton::Pointer skeleton) {
setSkeletonInternal(skeleton);
for (auto&& child : _children) {
child->setSkeletonInternal(skeleton);
child->setSkeleton(skeleton);
}
}

View file

@ -418,7 +418,11 @@ AnimNode::Pointer AnimNodeLoader::load(const QByteArray& contents, const QUrl& j
void AnimNodeLoader::onRequestDone(QNetworkReply& request) {
auto node = load(request.readAll(), _url);
emit success(node);
if (node) {
emit success(node);
} else {
emit error(0, "json parse error");
}
}
void AnimNodeLoader::onRequestError(QNetworkReply::NetworkError netError) {

View file

@ -11,11 +11,11 @@
"interpTarget": 6,
"interpDuration": 6,
"transitions": [
{ "var": "isMoving", "state": "walk" }
{ "var": "isMoving", "state": "walk_fwd" }
]
},
{
"id": "walk",
"id": "walk_fwd",
"interpTarget": 6,
"interpDuration": 6,
"transitions": [
@ -27,27 +27,109 @@
"children": [
{
"id": "idle",
"type": "blendLinear",
"data": {
"alpha": 0.5,
"alphaVar": "sine"
},
"children": [
{
"id": "normal_idle",
"type": "clip",
"data": {
"url": "https://hifi-public.s3.amazonaws.com/ozan/anim/standard_anims/idle.fbx",
"startFrame": 0.0,
"endFrame": 90.0,
"timeScale": 1.0,
"loopFlag": true
},
"children": []
},
{
"id": "other_idle",
"type": "clip",
"data": {
"url": "https://hifi-public.s3.amazonaws.com/ozan/anim/standard_anims/idle.fbx",
"startFrame": 20.0,
"endFrame": 90.0,
"timeScale": 1.0,
"loopFlag": true
},
"children": []
}
]
},
{
"id": "walk_fwd",
"type": "clip",
"data": {
"url": "https://hifi-public.s3.amazonaws.com/ozan/support/FightClubBotTest1/Animations/standard_idle.fbx",
"url": "https://hifi-public.s3.amazonaws.com/ozan/anim/standard_anims/walk_fwd.fbx",
"startFrame": 0.0,
"endFrame": 90.0,
"endFrame": 35.0,
"timeScale": 1.0,
"loopFlag": true
},
"children": []
},
{
"id": "walk",
"id": "walk_bwd",
"type": "clip",
"data": {
"url": "https://hifi-public.s3.amazonaws.com/ozan/support/FightClubBotTest1/Animations/standard_walk.fbx",
"url": "https://hifi-public.s3.amazonaws.com/ozan/anim/standard_anims/walk_bwd.fbx",
"startFrame": 0.0,
"endFrame": 37.0,
"timeScale": 1.0,
"loopFlag": true
},
"children": []
},
{
"id": "turn_left",
"type": "clip",
"data": {
"url": "https://hifi-public.s3.amazonaws.com/ozan/anim/standard_anims/turn_left.fbx",
"startFrame": 0.0,
"endFrame": 28.0,
"timeScale": 1.0,
"loopFlag": true
},
"children": []
},
{
"id": "turn_right",
"type": "clip",
"data": {
"url": "https://hifi-public.s3.amazonaws.com/ozan/anim/standard_anims/turn_right.fbx",
"startFrame": 0.0,
"endFrame": 30.0,
"timeScale": 1.0,
"loopFlag": true
},
"children": []
},
{
"id": "strafe_left",
"type": "clip",
"data": {
"url": "https://hifi-public.s3.amazonaws.com/ozan/anim/standard_anims/strafe_left.fbx",
"startFrame": 0.0,
"endFrame": 31.0,
"timeScale": 1.0,
"loopFlag": true
},
"children": []
},
{
"id": "strafe_right",
"type": "clip",
"data": {
"url": "https://hifi-public.s3.amazonaws.com/ozan/anim/standard_anims/strafe_right.fbx",
"startFrame": 0.0,
"endFrame": 31.0,
"timeScale": 1.0,
"loopFlag": true
},
"children": []
}
]
}