From: eihrul Date: Wed, 21 Apr 2010 08:01:20 +0000 (+0000) Subject: fix IQM format to use relative base pose X-Git-Tag: xonotic-v0.1.0preview~230^2~379 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=721d323833d63e5f5a9aae94c1ffcfe835734e7e;p=xonotic%2Fdarkplaces.git fix IQM format to use relative base pose git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10097 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/model_alias.c b/model_alias.c index be57386d..13ea8bf3 100644 --- a/model_alias.c +++ b/model_alias.c @@ -3256,7 +3256,7 @@ void Mod_INTERQUAKEMODEL_Load(dp_model_t *mod, void *buffer, void *bufferend) joint = (iqmjoint_t *) (pbase + header->ofs_joints); for (i = 0;i < loadmodel->num_bones;i++) { - matrix4x4_t base, invbase; + matrix4x4_t relbase, relinvbase, pinvbase, invbase; joint[i].name = LittleLong(joint[i].name); joint[i].parent = LittleLong(joint[i].parent); for (j = 0;j < 3;j++) @@ -3269,9 +3269,15 @@ void Mod_INTERQUAKEMODEL_Load(dp_model_t *mod, void *buffer, void *bufferend) loadmodel->data_bones[i].parent = joint[i].parent; if (loadmodel->data_bones[i].parent >= i) Host_Error("%s bone[%i].parent >= %i", loadmodel->name, i, i); - Matrix4x4_FromDoom3Joint(&base, joint[i].origin[0], joint[i].origin[1], joint[i].origin[2], joint[i].rotation[0], joint[i].rotation[1], joint[i].rotation[2]); - Matrix4x4_Invert_Simple(&invbase, &base); - Matrix4x4_ToArray12FloatD3D(&invbase, loadmodel->data_baseboneposeinverse + 12*i); + Matrix4x4_FromDoom3Joint(&relbase, joint[i].origin[0], joint[i].origin[1], joint[i].origin[2], joint[i].rotation[0], joint[i].rotation[1], joint[i].rotation[2]); + Matrix4x4_Invert_Simple(&relinvbase, &relbase); + if (loadmodel->data_bones[i].parent >= 0) + { + Matrix4x4_FromArray12FloatD3D(&pinvbase, loadmodel->data_baseboneposeinverse + 12*loadmodel->data_bones[i].parent); + Matrix4x4_Concat(&invbase, &relinvbase, &pinvbase); + Matrix4x4_ToArray12FloatD3D(&invbase, loadmodel->data_baseboneposeinverse + 12*i); + } + else Matrix4x4_ToArray12FloatD3D(&relinvbase, loadmodel->data_baseboneposeinverse + 12*i); } // set up the animscenes based on the anims @@ -3337,6 +3343,10 @@ void Mod_INTERQUAKEMODEL_Load(dp_model_t *mod, void *buffer, void *bufferend) loadmodel->data_poses6s[k*6 + 3] = 32767.0f * (pose[j].channeloffset[3] + (pose[j].channelmask&8 ? (unsigned short)LittleShort(*framedata++) * pose[j].channelscale[3] : 0)); loadmodel->data_poses6s[k*6 + 4] = 32767.0f * (pose[j].channeloffset[4] + (pose[j].channelmask&16 ? (unsigned short)LittleShort(*framedata++) * pose[j].channelscale[4] : 0)); loadmodel->data_poses6s[k*6 + 5] = 32767.0f * (pose[j].channeloffset[5] + (pose[j].channelmask&32 ? (unsigned short)LittleShort(*framedata++) * pose[j].channelscale[5] : 0)); + // skip scale data for now + if(pose[j].channelmask&64) framedata++; + if(pose[j].channelmask&128) framedata++; + if(pose[j].channelmask&256) framedata++; } }