Object3D.getAnimationSequence(int index) and Animation.getName()

Started by AGP, July 25, 2010, 02:59:46 AM

Previous topic - Next topic

AGP

I'm writing a MD2 fixer (sometimes an animation is short a frame and the next, therefore, has one too many). Since I decided to use jPCT so we can see the changes in real-time, it would be helpful if I could have the above-mentioned methods to work with, lest I be forced to identify the animation names and lengths from the MD2 bytes themselves.

EgonOlsen

I'll see what i can do...but what is Object3D.getAnimationSequence(int index) supposed to return exactly?

Edit: Looking at the Animation class, most of the stuff you want seems to be there already. You can get the complete list of keyframes, the start and end positions in that list for each sequence and each sequence has a name...you just can't get that name back from the Animation. Would it be sufficient to add just that?

AGP

Sure, if I can identify to whose animation (by name) each frame belongs, it will suffice. Thanks a lot.

EgonOlsen

I've uploaded a version with the added method (Animation.getName(<int>)) here: http://www.jpct.net/download/beta/jpct.jar

That, combined with the option to return the animation's meshes and the start and end positions of each sequence should do the trick.


AGP

So here's a question: I take it that the MD2 format has a header of 68 bytes, and each frame, I believe, is 40 bytes plus 4*numberOfVertices. Is that right, and could I safely say that, say, frame 3 of a mesh with 100 vertices starts at byte 469 (array index 468)?

EgonOlsen

I don't think that you can be 100% sure about this. The md2-header contains the offset positions where each type of data can be found in the file. It's better to use that information IMHO.

AGP

I meant 869+80, by the way, in my previous post (forgot to multiply!).

So is the offset an absolute value? Say the offset is 1000, would I just go, again for frame 3 , by 2*4*numberOfVertices+1000 +80?

EgonOlsen

I'm not sure about the numbers, but basically yes. Starting at the offset, the size of each frame is the same.

zammbi

What about a method that gets an animation sequence by name? That might be handy too.

EgonOlsen

What is that supposed to return? A part of the animation array or just the start and end position in that array?

zammbi

Return a int of the sub sequence so can do something like this:

character.animate(0.0, character.getAnimationSequence().getAnimationSubSequence("walk"));

I hope that makes more sense.

EgonOlsen

I see. I've added it (getSequence(<String>)) and uploaded a new jar. Download location is the same as posted above.


AGP

How big is struct vec3_t, do you know? Because the little bastard is set before the frame names, and for the life of me I could not find its declaration by googling it. I need to know it so I can get the proper indentation to the animation's char array.