proper tutorial for model animation

Started by MrYogi, June 20, 2012, 08:03:08 AM

Previous topic - Next topic

MrYogi

hi all,
I gone through forum and wiki for finding how can I animate my models specially md2 with in build animation but finally got bit confused.
I used  model.animate() but no result. can anyone simply suggest how to use in build multiple animations of md2.
and another question ,my md2 models are not fully rendering some small portions are transparent ,what could be reason for that?
thanks in advance

EgonOlsen

"no result" is a bit vague...please be more specific or all i can say is "do stuff right" in response... ;)

About the rendering: Do you have a screen shot of this?

MrYogi

#2

hey no result means i'm talking about no animation
here is my code:

public void onSurfaceChanged(GL10 gl, int w, int h) {
if (fb != null) {
fb.dispose();
}
fb = new FrameBuffer(gl, w, h);
world = new World();
world.setAmbientLight(20, 20, 20);

sun = new Light(world);
sun.setIntensity(250, 250, 250);
Resources res = ImageTargets.getImageTarget().getResources();
TextureManager tm = TextureManager.getInstance();

Texture ogro1 = new Texture(res.openRawResource(R.drawable.ogrobase));
tm.addTexture("ogro", ogro1);
ogro = Loader.loadMD2(res.openRawResource(R.raw.ogro), 1f);
ogro.setTexture("ogro");
// ogro.rotateY(-20);
// ogro.rotateZ(110);
ogro.rotateX(90);
world.buildAllObjects();
world.addObject(ogro);
Camera cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
cam.lookAt(ogro.getTransformedCenter());
SimpleVector sv = new SimpleVector();
sv.set(ogro.getTransformedCenter());
sv.x -= 300;
sv.z -= 0;
sun.setPosition(sv);
MemoryHelper.compact();
}
public void onDrawFrame(GL10 gl) {
ogro.animate(anim, 0);
if (anim>1) {
anim=0;
} else {
anim+=0.1f;
}
fb.clear();
world.renderScene(fb);
world.draw(fb);
fb.display();

if (System.currentTimeMillis() - time >= 1000) {
Logger.log(fps + "fps");
fps = 0;
time = System.currentTimeMillis();
}
fps++;
}
}

EgonOlsen

Looks ok at first glance. Can you post the log output?

MrYogi

hey i can't guess where was  the problem but now it's animating,
i'm attaching screen shot,in which you can see that some portion are transparent,every model facing the same problem.

[attachment deleted by admin]

EgonOlsen

That's because the model textures contain black parts, which jPCT will default to zero alpha. This doesn't matter if you render into an opaque buffer, but in your case, it does. Solution should be simple: create the textures with "new Texture(..., true);"

MrYogi

Quote from: EgonOlsen on June 20, 2012, 11:08:24 AM
That's because the model textures contain black parts, which jPCT will default to zero alpha. This doesn't matter if you render into an opaque buffer, but in your case, it does. Solution should be simple: create the textures with "new Texture(..., true);"
ya that was the problem ,thanx a lot