www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: gamerfan on November 07, 2011, 01:50:26 pm

Title: .md2 model not animating
Post by: gamerfan 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.
Title: Re: .md2 model not animating
Post by: EgonOlsen 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.
Title: Re: .md2 model not animating
Post by: gamerfan 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.