Author Topic: Object3D.getAnimationSequence(int index) and Animation.getName()  (Read 3570 times)

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
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.
« Last Edit: July 25, 2010, 05:15:27 am by AGP »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #1 on: July 25, 2010, 09:48:26 pm »
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?
« Last Edit: July 25, 2010, 09:52:59 pm by EgonOlsen »

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #2 on: July 26, 2010, 12:04:40 am »
Sure, if I can identify to whose animation (by name) each frame belongs, it will suffice. Thanks a lot.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #3 on: July 26, 2010, 08:39:09 pm »
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.

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #4 on: July 26, 2010, 08:48:53 pm »
Thanks a whole lot, Egon.

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #5 on: July 27, 2010, 08:27:27 pm »
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)?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #6 on: July 27, 2010, 08:49:03 pm »
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.

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #7 on: July 27, 2010, 09:04:46 pm »
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?
« Last Edit: July 27, 2010, 09:07:56 pm by AGP »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #8 on: July 27, 2010, 09:51:23 pm »
I'm not sure about the numbers, but basically yes. Starting at the offset, the size of each frame is the same.

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #9 on: July 29, 2010, 06:26:04 am »
What about a method that gets an animation sequence by name? That might be handy too.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #10 on: July 29, 2010, 05:13:26 pm »
What is that supposed to return? A part of the animation array or just the start and end position in that array?

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #11 on: July 29, 2010, 06:27:29 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #12 on: July 29, 2010, 09:08:08 pm »
I see. I've added it (getSequence(<String>)) and uploaded a new jar. Download location is the same as posted above.

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #13 on: July 30, 2010, 06:49:58 am »
Thanks that will help a lot.

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #14 on: July 31, 2010, 10:19:22 pm »
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.