hi devs, I've been searching lots of ways to do this, and after 3 lts
of coffe I finally solved it, soy I'll post the answer just in case
someone else have also this problem and just can't get to fix it.

also I would like to ask if this is sort of bug in away3d or in my md2
exporter (I believe is both).

so this is the explanation:
I wanted to have a single md2 model, with all the animations, and
label each animation of the model:
idle
walk
dance

I used qtip, it exports the md2 the best way I could found (uvmaps
works perfect), but qtip doesnt names animations, so then I used
milkshape with no luck, then like another 3 or 4 3d modeling software
'till I found the best option 'till now:
frag motion.

fragMotion lets you import md2, rename, split and duplicate your
animations, and export it again.
yet, after doing this, I just could get the animation in away3d (im
using away3d 3.5).

I used the md2 Viewer 1.4 and my animations were shown just perfect.
so I had to go to the away3dsource, and I realized when I printed all
animations contained in the model, that away3d was adding it some
trash at the end of the name:

idle¨Y%\
walk?=

and so on

so the answer is in the md2 class, wich is the parser, so far I've
found there is a set of lines that reads the name of the animations,
and as I can see, the name is a 16 bytes name, so if the name of my
animation is lower than 16bytes, it compleats the name with the next
bytes (the trash). thats why I think its both awy3d and fragMotion
bugs: fragmotions add trash at the end of the animation names, and
away3d does not cleans it.

solution:

I went to the Md2 class, on the method parseFrames(), line 201 there
is:

  for (var j:int = 0; j < 16; j++)
                {
                    var char:int = md2.readUnsignedByte();
                    if (char != 0) {
                        var str:String = String.fromCharCode(char);
                        if (isNaN(Number(str)))
                                name += str;
                    }
}

--- at this point we have the 16 bytes name in "name" var. but it
contains all the garbage, so I add this line just after the for cycle:

name = name.substr(0, name.search("_"));

it searches in the name for a "magic" character, in this case "_", and
makes a substring from 0 to that character.

and, back in fragMotion, I name all my animatinos this way:
walk_
idle_
dance_

so when it comes to the parser, my animations are like : idle_¨Y%\,
walk_?=, and after the sbustr() cleanup, the name is: idle, walk,
dance. and thats it, trouble solved.

are you thinking on adding some kind of patch for this in next
realeases? or is there a better solution for fixin this?

Reply via email to