www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: MrYogi on June 20, 2012, 08:03:08 am

Title: proper tutorial for model animation
Post by: MrYogi on June 20, 2012, 08:03:08 am
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
Title: Re: proper tutorial for model animation
Post by: EgonOlsen on June 20, 2012, 08:57:17 am
"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?
Title: Re: proper tutorial for model animation
Post by: MrYogi on June 20, 2012, 09:13:06 am

hey no result means i'm talking about no animation
here is my code:
Code: [Select]
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++;
}
}
Title: Re: proper tutorial for model animation
Post by: EgonOlsen on June 20, 2012, 09:27:49 am
Looks ok at first glance. Can you post the log output?
Title: Re: proper tutorial for model animation
Post by: MrYogi on June 20, 2012, 10:35:47 am
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]
Title: Re: proper tutorial for model animation
Post by: 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);"
Title: Re: proper tutorial for model animation
Post by: MrYogi on June 20, 2012, 11:16:55 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