md2 frame list

In the md2 export window there is a feild to enter a frame list. I think this is a text file used to describe animation names and how many frames in each. But nowhere is this described or explained so I am only guessing. Can someone show me an example frame list please?

I look at the exporter source and figured it needs a structure like this:

# MD2 Frame Name List
"stand"      1
"run"       41
"attack"    47
"pain1"     55
"pain2"     59
"pain3"     63
"jump"      67
"flip"      73
"salute"    85
"taunt"     96
"wave"     113
"point"    124
"crstnd"   136
"crwalk"   155
"crattack" 161
"crpain"   170
"crdeath"  174
"death1"   179
"death2"   185
"death3"   191

These are the default values if you do not supply your own list of actions. I suppose it’s the order and length Quake 2 expects the animations to be in. The number means the frame the animation starts.

Note, that the first line must look exactly like this. The exporter insist on it and won’t work else.

I haven’t tested it though, so write back if it works.

I take it back, I was wrong. The number you should supply is the length of the animation. So the default values written as a frame file should look like this

# MD2 Frame Name List
"stand"         39
"run"           5
"attack"        7
"pain1"         3
"pain2"         3
"pain3"         3
"jump"          5
"flip"          11
"salute"        10
"taunt"         16
"wave"          10
"point"         11
"crstnd"        18
"crwalk"        5
"crattack"      8
"crpain"        3
"crdeath"       4
"death1"        5
"death2"        5
"death3"        7

Hi ondrew thanks for the reply. What format should the file be? I tried using your layout as a text file, but it reports…
“This is not a valid frame definition file-using default”

Does the first line of your file look like this:

# MD2 Frame Name List

yes
I will try different combinations of frame numbers, maybe each name needs a beginning and ending frame number?

This is the part of the script that checks if the file is valid. You can see on the line 14, that it checks the first line equals the “# MD2 Frame Name List”.

Than every consequent line is parsed, if it contains # as the first string (line 23) is a comment and is ignored.

Noncomment lines are splitted (python split splits by whitespace like space, tab etc) in two parts. The first part acts as the name of the action and the second part means the duration.

Other than that I can’t help


     1  t_frame_list():
     2          global g_frame_filename
     3          frame_list=[]
       
     4          if g_frame_filename.val=="default":
     5                  return MD2_FRAME_NAME_LIST
       
     6          else:
     7          #check for file
     8                  if (Blender.sys.exists(g_frame_filename.val)==1):
     9                          #open file and read it in
    10                          file=open(g_frame_filename.val,"r")
    11                          lines=file.readlines()
    12                          file.close()
       
    13                          #check header (first line)
    14                          if lines[0]<>"# MD2 Frame Name List":
    15                                  print "its not a valid file"
    16                                  result=Blender.Draw.PupMenu("This is not a valid frame definition file-using default%t|OK")
    17                                  return MD2_FRAME_NAME_LIST
    18                          else:
    19                                  #read in the data
    20                                  num_frames=0
    21                                  for counter in range(1, len(lines)):
    22                                          current_line=lines[counter]
    23                                          if current_line[0]=="#":
    24                                                  #found a comment
    25                                                  pass
    26                                          else:
    27                                                  data=current_line.split()
    28                                                  frame_list.append([data[0],num_frames+1, num_frames+int(data[1])])
    29                                                  num_frames+=int(data[1])
    30                                  return frame_list

Well I have tried several differnt combinations. Ive tried adding
#60 frames
at the end of the file, ive tried different numbers (length, location,beginning and end)
If anyone has a working example of a frame list please upload it for me so I can have a look? I would be very grateful.

I physically copied the line from the .py file and pasted it is my first line in the text file and i am still recieving the “not a valid frame list” error.
Does file.readlines() read a text file? If so then I dont know what else to do. The only place in the .py file i see the error to be printed is at the beginning. So it isnt getting past the beginning line for some reason.
Another note, it displays the error twice when I am exporting. It displayes it the first time, I click OK, then a couple seconds later it displays the error again, I click ok again, then the bodel exports using the default frame list.

Hey I found the problem!
There is a bug in the script, reported a few months ago, that I didn’t know about and was overlooking.
the line

if lines[0]<>"# MD2 Frame Name List":

always returns false. I added .strip() to lines[0] and now it works
Here is the link to the bug report

If you ask me, the line is pretty stupid anyway, but it works for me. I suppose it’s because I’m on linux, where the line endings are
.

Whereas you’re on windows and have line endings
.

So what’s probably happening is that python detects end a a line by the
. So your string looks like
“# MD2 Frame Name List\r”.

fixed in CVS

I imported an md2 animation with textures, just to export it again
(I need to make some md2 animations for a game I am making at school)

When exporting I specify a framelist containing this:

MD2 Frame Name List

“move” 60

I get the folowing error

Traceback (most recent call last):
File “<string>”, line 151, in bevent
File “<string>”, line 1230, in save_md2
File “<string>”, line 707, in validation
File “<string>”, line 957, in get_frame_list
AttributeError: ‘str’ object has no attribute ‘stip’

Thanks for any help

It happens because the python md2 exporter script has a error on line 957:

where you read “stip()” changes to “strip()”