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

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #15 on: July 31, 2010, 11:12:06 pm »
By the way, I tried 6, 12, and 24 (for 1 byte per axis, 2, and 4 in two ve3_ts), but it seems that vec3_t has more data than that.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #16 on: July 31, 2010, 11:26:36 pm »
If we are talking about the 6 floats that come right before the actual name, then that's...well...6 floats, i.e. 24 bytes.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #17 on: July 31, 2010, 11:42:54 pm »
Are you sure it's just 3 floats per vec3_t (6 total)? If so, there's something wrong with what I'm doing...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #18 on: July 31, 2010, 11:53:39 pm »
No, i'm not sure because i'm not sure if we are talking about the same thing here. I'm talking about the section whose offset is stored at position 56 in the header. That one contains 6 floats (scaling and translation), the name of the frame and the actual vertex data for each frame.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #19 on: August 01, 2010, 03:16:26 am »
Yes, we're talking about the same thing, which makes something I'm doing wrong and my question answered.

So anyway, here's the only definition of frame that I got:
struct md2_frame_t
{
  vec3_t scale;               /* scale factor */
  vec3_t translate;           /* translation vector */
  char name[16];              /* frame name */
  struct md2_vertex_t *verts; /* list of frame's vertices */
};

Offline zammbi

  • float
  • ****
  • Posts: 361
    • View Profile
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #20 on: August 15, 2010, 05:27:27 am »
Question... I have a model which has broken up its walking animation into many animations. I know how to get all the walking animations sequences, but how do I merge these into 1 animation sequence? Or a helpful method could be
animate(float index,int[] seq) which temp merges(and caches) all those sub sequences in order to animate.

Offline zammbi

  • float
  • ****
  • Posts: 361
    • View Profile
Re: Object3D.getAnimationSequence(int index) and Animation.getName()
« Reply #21 on: August 16, 2010, 01:38:38 pm »
Think I got it right, here's the code if anyone wants it.


Code: [Select]
public static void mergeAnimation(Object3D model){

ArrayList<Integer> sub = new ArrayList<Integer>();
       
        Animation anim = model.getAnimationSequence();
        int count = anim.getSequenceCount();
       
        int s=0;
        boolean firstFrame = false;
        for(int i = 1; i <= count; i++){ //0 is all animations.
        if(anim.getName(i).toLowerCase().startsWith("wb")){
        if(!firstFrame){
        s = anim.getSequenceBorders(i)[0];
        firstFrame = true;
        }
        sub.add(anim.getSequenceBorders(i)[1]);
        }
        }
               
        Mesh[] meshs=anim.getKeyFrames();
       
        Animation re=new Animation(sub.get(sub.size()-1));
       
       
        re.createSubSequence("walk");
        for (int i=0; i<sub.size(); i++){
        for (int p=s; p<=sub.get(i); p++) {
        re.addKeyFrame(meshs[p]);
        }
        s=sub.get(i)+1;
        }
        model.setAnimationSequence(re);
}

Edit: Fixed a bug.
« Last Edit: August 16, 2010, 02:35:09 pm by zammbi »