Does Bones support pose animation?

Started by kiffa, July 21, 2012, 08:17:20 AM

Previous topic - Next topic

kiffa

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: 

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;
  }


raft

a SkinClip is a skeleton animation clip. if your model doesnt have one, AnimatedGroup.getSkinClipSequence() will return null and hence the exception..

kiffa

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:
   

   // onSurfaceCreated
     for(Animated3D a : masterNinja)     
      {
        a.setTexture("ninja");
        a.scale(0.1f);
      }

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



but when playing animation, nothing was scaled.

raft

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

kiffa

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? 

raft

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: kiffaAnd 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 ;)