Author Topic: Does Bones support pose animation?  (Read 22916 times)

Offline kiffa

  • long
  • ***
  • Posts: 199
    • View Profile
Does Bones support pose animation?
« on: July 21, 2012, 08:17:20 am »
I used Maya-blend-shape to make an animation, then used ogreMax to export it(Object-settings: Skeleton+pose), and there were no skeleton-animation-data in .skeleton.xml but some pose-naimation-data in .mesh.xml.  And then i converted .mesh.xml to .bones(can.bones), when i tried to run it with ninja-demo-src, crash happened.

log-cat-info:

07-21 13:55:47.266: E/AndroidRuntime(2978): FATAL EXCEPTION: main
07-21 13:55:47.266: E/AndroidRuntime(2978): java.lang.NullPointerException
07-21 13:55:47.266: E/AndroidRuntime(2978):    at bones.samples.android.NinjaDemoActivity.onCreateOptionsMenu(NinjaDemoActivity.java:350)
07-21 13:55:47.266: E/AndroidRuntime(2978):    at android.app.Activity.onCreatePanelMenu(Activity.java:2158)


And my code in NinjaDemoActivity.java:350: 
Code: [Select]
public boolean onCreateOptionsMenu(Menu menu)                           // line 341
  {
    menu.add(0, MENU_STOP_ANIM, 0, "Stop Animation");

    if(MESH_ANIM_ALLOWED)
      menu.add(0, MENU_USE_MESH_ANIM, 0, "Use Mesh Animation").setCheckable(true);

    SubMenu animMenu = menu.addSubMenu("Animation");
    int menuItem = 101;
    for(SkinClip clip : masterNinja.getSkinClipSequence())               //line 350,   and init code: masterNinja = BonesIO.loadGroup(res.openRawResource(R.raw.can));
    {
      animMenu.add(0, menuItem++, 1, "Anim: " + clip.getName());
    }

    return true;
  }

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Does Bones support pose animation?
« Reply #1 on: July 21, 2012, 08:20:46 am »
a SkinClip is a skeleton animation clip. if your model doesnt have one, AnimatedGroup.getSkinClipSequence() will return null and hence the exception..

Offline kiffa

  • long
  • ***
  • Posts: 199
    • View Profile
Re: Does Bones support pose animation?
« Reply #2 on: July 21, 2012, 09:25:01 am »
Thanks, now it works! Maybe i should  read the api-doc first.

Another question:

  I want to scale an animated-obj, and i write code like this:
   
Code: [Select]
   // onSurfaceCreated
     for(Animated3D a : masterNinja)     
      {
        a.setTexture("ninja");
        a.scale(0.1f);
      }

    // onDrawFrame
   masterNinja.animatePose(index, animation);


but when playing animation, nothing was scaled.

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Does Bones support pose animation?
« Reply #3 on: July 21, 2012, 09:38:16 am »
Quote from: kiffa
..Maybe i should  read the api-doc first.
definitely a good idea ;)

Quote from: kiffa
..but when playing animation, nothing was scaled.
correct, you cant scale an Animated3D that way. applying animation resets scaling effect.

BonesImporter.importXX methods has a scale parameter for this purpose, the model is scaled when it's first imported. similarly you can pass scale parameter to import scripts

Offline kiffa

  • long
  • ***
  • Posts: 199
    • View Profile
Re: Does Bones support pose animation?
« Reply #4 on: July 21, 2012, 11:45:12 am »
I had removed the BonesImporter.class because i just want to use .bones.

So, How can i do this:
  I want to import models once, and then scale the whole world(static objs + animation)  freely.

And another question:
  Animated3D extends Object3D, so can i use Animated3D obj instead of  Object3D obj anywhere? 

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Does Bones support pose animation?
« Reply #5 on: July 21, 2012, 06:42:24 pm »
Quote from: kiffa
So, How can i do this:
  I want to import models once, and then scale the whole world(static objs + animation)  freely.
scale Animated3D's after animation is applied

Quote from: kiffa
And another question:
  Animated3D extends Object3D, so can i use Animated3D obj instead of  Object3D obj anywhere?
yes, that's the main idea of making Animated3D extending Object3D ;)