.md2 model not animating

Started by gamerfan, November 07, 2011, 01:50:26 PM

Previous topic - Next topic

gamerfan

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.


   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

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.

EgonOlsen

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.

gamerfan

I have taken this model from some other c++ game.Sorry,  I do not have much idea about it.