Author Topic: .md2 model not animating  (Read 3369 times)

Offline gamerfan

  • int
  • **
  • Posts: 97
    • View Profile
.md2 model not animating
« on: November 07, 2011, 01:50:26 pm »
Hi This is question is inspite of doing all the required steps while loading and animate a .md2 model, it is just displaying it on the screen.But not animating.I have attached the code for loading the model and displaying it on the screen.

Code: [Select]
   private Object3D drawCrabs(){
       Object3D crab = null;
       Resources res = getResources();
       crab = Loader.loadSerializedObject(res.openRawResource(R.raw.crab));
       Bitmap image = BitmapFactory.decodeResource(res, R.drawable.crab1);
       Texture texture = new Texture(image);
       TextureManager.getInstance().addTexture("crabone", texture);
       crab.setTexture("crabone");
       crab.compile(true, false);
       crab.strip();
       crab.build();
       return crab;
   }
Render animation
Code: [Select]
public void onDrawFrame(GL10 gl) {
if (touchTurn != 0) {
touchTurn = 0;
yDelta += 0.02f;
}
if (touchTurnUp != 0) {
    touchTurnUp = 0;
}

                        // animating the model to attack
                        crab1.animate(anim, crab1.getAnimationSequence().getSequence("attack"));
                        anim += 0.1f;
                        if (anim >= 1)
                        anim = 0;
                        // end of animation

fb.clear(back);
world.renderScene(fb);
world.draw(fb);
fb.display();
if (System.currentTimeMillis() - time >= 1000) {
// Logger.log(fps + "fps");
fps = 0;
time = System.currentTimeMillis();
}
fps++;
}
What I am missing here.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: .md2 model not animating
« Reply #1 on: November 07, 2011, 08:31:11 pm »
Looks fine at first glance. Are you sure that "attack" is actually an animation sequence that really changes the mesh? IIRC, most sequences defined in the mesh that you sent to me did nothing at all.

Offline gamerfan

  • int
  • **
  • Posts: 97
    • View Profile
Re: .md2 model not animating
« Reply #2 on: November 08, 2011, 10:28:59 am »
I have taken this model from some other c++ game.Sorry,  I do not have much idea about it.