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

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

Previous topic - Next topic

AGP

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.

EgonOlsen

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.

AGP

Are you sure it's just 3 floats per vec3_t (6 total)? If so, there's something wrong with what I'm doing...

EgonOlsen

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.

AGP

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 */
};

zammbi

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.

zammbi

Think I got it right, here's the code if anyone wants it.



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.