ARudik / gamekit

Automatically exported from code.google.com/p/gamekit
0 stars 0 forks source link

Skeletal animation (with mesh reparented to animated armature) is not displayed with AnimKit #209

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. In Blender 2.57 create mesh, armature
2. reparent mesh to armature, use automatic weights
3. animate armature, play animation in Blender timeline
4. Use AnimKit AppAnimKitGl to play the file.

Animation is visible in Blender, but not visible with AnimKit - in AnimKit demo 
just mesh is rendered in initial pose, no animation.
Note that in AppAnimKitGl Blue.blend has both armature and mesh animated so it 
gets displayed - in general, with skeletal animation having only armature 
animated, animation is not rendered with AnimKit.

using branched AnimKit on iOS here: 
https://github.com/astojilj/astojilj_animkit/tree/ios but I understand the 
issue is reproducible with upstream code. 
I have reproduced it on iOS and Mac OS X 10.6.8

Patch fixing it:
commit 526c0951c9324a029bfb4713cb0283a50ceb0984
Author: Aleksandar Stojiljkovic <astojilj@gmail.com>
Date:   Wed Jan 18 23:49:57 2012 +0200

    Fixes rendering animation when only armature (not mesh) is having animation assigned

    For common case when mesh is parented to armature and armature is animated. Note that in example Blue.blend both
    armature and mesh are animated so animation is displayed correctly. However, in common case when
    only armature is added to NLA editor or dopesheet this was not OK. Following code checks if object
    has animation, if not checks parent and if armature and if animated, it uses that one. So, this way it works like in Blender.

diff --git a/Samples/BlenderLoader/akAnimationLoader.cpp 
b/Samples/BlenderLoader/akAnimationLoader.cpp
index fdfe667..bad993d 100644
--- a/Samples/BlenderLoader/akAnimationLoader.cpp
+++ b/Samples/BlenderLoader/akAnimationLoader.cpp
@@ -528,7 +528,17 @@ void akAnimationLoader::convertObject(akEntity* obj, 
Blender::Object* bobj, bool
        // 2.5x
        else
        {
-               convert25AnimData(obj, bobj->adt, animfps);
+        /*!
+         astojilj - fixes renderring animation for common case when mesh is 
parented to armature 
+         and armature is animated. Note that in example Blue.blend both 
armature and mesh reference 
+         to armature are animated so animation is displayed correctly. 
However, in common case when
+         only armature is added to NLA editor this was not OK. Following code 
checks if object 
+         has animation, if not checks parent and if armature and if animated, 
it uses that one.
+        */
+        Blender::AnimData* adt = (bobj->adt && bobj->adt->action) 
+            ? bobj->adt 
+            : ((bobj->parent && bobj->parent->type == OB_ARMATURE) ? 
bobj->parent->adt : bobj->adt);
+        convert25AnimData(obj,adt, animfps);
        }

        // object data

Blend file to reproduce it attached (krava.blend).

Original issue reported on code.google.com by astojilj@gmail.com on 21 Jan 2012 at 10:47

Attachments:

GoogleCodeExporter commented 9 years ago
I found out that if you assign the existing armature action to the mesh, using 
the DopeSheet/ActionEditor, it starts working. See attached blend and 
screenshot of DopeSheet.

I think your patch could be helpful, it makes it easier to assign animations.

Original comment by erwin.coumans on 21 Jan 2012 at 3:46

Attachments:

GoogleCodeExporter commented 9 years ago
By the way, the krava.blend model is cute. We should add support for rigid/soft 
body simulation of such tails :)

Original comment by erwin.coumans on 21 Jan 2012 at 5:49

GoogleCodeExporter commented 9 years ago
Cute model indeed.

I fixed this in r1009 now you can assign the animation to the mesh or the 
armature or both in Blender, the AnimKit loader will assign them to the 
corresponding object/entity.

In the case you assign 2 different animations to the mesh and the armature, 
both will load OK, but only one will play by default in AnimKit demo while both 
are played together in Blender.

Original comment by xavier.thomas.1980@gmail.com on 22 Jan 2012 at 2:08