lsalzman / iqm

Inter-Quake Model format development kit
MIT License
239 stars 73 forks source link

Wrong text string indices for joint names (out of bounds) #35

Closed ghost closed 5 years ago

ghost commented 5 years ago

Looks like a bug. I'm using Blender 2.80. Steps to reproduce:

  1. Run Blender and import the attached FBX model Knight.zip
  2. Export to IQM (I've uploaded what I got after export)

There are 38 text strings in the file (correct) but joint name indices are incorrect (and mostly out of bounds)

lsalzman commented 5 years ago

I just loaded the iqm file you included in the zip with the demo loader, modified to print out all the joint names. All of the joint names look correct to me. The problem is more likely in your own loading code somewhere? Are you using the old v1 joint structure that has only 3 rotation components instead of 4, or are you not indexing the string table correctly somehow?

ghost commented 5 years ago

Thanks for your quick response! No, I'm using v2 joint structure and all joint data looks OK except name indices. Let's look at the file. The joints data starts at 0x5E398, so the first joint name index is 0x1A (which means "Bip01 R Toe02" - looks wrong, but OK), and the second joint name index (at 0x5E3C8) is 0x27

I'm considering that text strings are separated by "\0".

lsalzman commented 5 years ago

I doubled checked again with the knight.iqm you included, and here is the printed output from the hacked demo:

string table: 516 bytes joint 0: "Bip01 Pelvis" (26..38) joint 1: "Bip01 Spine" (39..50) joint 2: "Bip01 Spine1" (51..63) joint 3: "Bip01 L Thigh" (64..77) joint 4: "Bip01 R Thigh" (78..91) joint 5: "Bip01 Spine2" (92..104) joint 6: "Bip01 L Calf" (105..117) joint 7: "Bip01 R Calf" (118..130) joint 8: "Bip01 Spine3" (131..143) joint 9: "Bip01 L Foot" (144..156) joint 10: "Bip01 R Foot" (157..169) joint 11: "Bip01 Neck" (170..180) joint 12: "Bip01 L Toe0" (181..193) joint 13: "Bip01 R Toe0" (194..206) joint 14: "Bip01 L Clavicle" (207..223) joint 15: "Bip01 R Clavicle" (224..240) joint 16: "Bip01 Head" (241..251) joint 17: "Bip01 L Toe01" (252..265) joint 18: "Bip01 R Toe01" (266..279) joint 19: "Bip01 L UpperArm" (280..296) joint 20: "Bip01 R UpperArm" (297..313) joint 21: "Bip01 HeadNub" (314..327) joint 22: "Bip01 L Toe02" (328..341) joint 23: "Bip01 R Toe02" (342..355) joint 24: "Bip01 L Forearm" (356..371) joint 25: "Bip01 R Forearm" (372..387) joint 26: "Bip01 L Toe0Nub" (388..403) joint 27: "Bip01 R Toe0Nub" (404..419) joint 28: "Bip01 L Hand" (420..432) joint 29: "Bip01 R Hand" (433..445) joint 30: "Bip01 L Finger0" (446..461) joint 31: "Bip01 R Finger0" (462..477) joint 32: "Bip01 L Finger0Nub" (478..496) joint 33: "Bip01 R Finger0Nub" (497..515)

All the joint indexes look fine, and the string table is 516 bytes. Everything looks kosher in the file.

ghost commented 5 years ago

Oh, thanks! Now I see what's wrong with my loader code: that name indices are byte offset values, instead of string array indices. Thanks again for clarification!