Index: code/renderer/tr_model_iqm.c =================================================================== --- code/renderer/tr_model_iqm.c (revision 2013) +++ code/renderer/tr_model_iqm.c (working copy) @@ -67,20 +67,17 @@ mat[10] = a[10] * unLerp + b[10] * lerp; mat[11] = a[11] * unLerp + b[11] * lerp; } -static void JointToMatrix( vec3_t rot, vec3_t scale, vec3_t trans, +static void JointToMatrix( vec4_t rot, vec3_t scale, vec3_t trans, float *mat ) { - float rotLen = DotProduct(rot, rot); - float rotW = -SQRTFAST(1.0f - rotLen); - float xx = 2.0f * rot[0] * rot[0]; float yy = 2.0f * rot[1] * rot[1]; float zz = 2.0f * rot[2] * rot[2]; float xy = 2.0f * rot[0] * rot[1]; float xz = 2.0f * rot[0] * rot[2]; float yz = 2.0f * rot[1] * rot[2]; - float wx = 2.0f * rotW * rot[0]; - float wy = 2.0f * rotW * rot[1]; - float wz = 2.0f * rotW * rot[2]; + float wx = 2.0f * rot[3] * rot[0]; + float wy = 2.0f * rot[3] * rot[1]; + float wz = 2.0f * rot[3] * rot[2]; mat[ 0] = scale[0] * (1.0f - (yy + zz)); mat[ 1] = scale[0] * (xy - wz); @@ -95,20 +92,17 @@ mat[10] = scale[2] * (1.0f - (xx + yy)); mat[11] = trans[2]; } -static void JointToMatrixInverse( vec3_t rot, vec3_t scale, vec3_t trans, +static void JointToMatrixInverse( vec4_t rot, vec3_t scale, vec3_t trans, float *mat ) { - float rotLen = DotProduct(rot, rot); - float rotW = -SQRTFAST(1.0f - rotLen); - float xx = 2.0f * rot[0] * rot[0]; float yy = 2.0f * rot[1] * rot[1]; float zz = 2.0f * rot[2] * rot[2]; float xy = 2.0f * rot[0] * rot[1]; float xz = 2.0f * rot[0] * rot[2]; float yz = 2.0f * rot[1] * rot[2]; - float wx = 2.0f * rotW * rot[0]; - float wy = 2.0f * rotW * rot[1]; - float wz = 2.0f * rotW * rot[2]; + float wx = 2.0f * rot[3] * rot[0]; + float wy = 2.0f * rot[3] * rot[1]; + float wz = 2.0f * rot[3] * rot[2]; mat[ 0] = scale[0] * (1.0f - (yy + zz)); mat[ 1] = scale[0] * (xy + wz); @@ -159,6 +153,8 @@ LL( header->version ); if( header->version != IQM_VERSION ) { + ri.Printf(PRINT_WARNING, "R_LoadIQM: %s is a unsupported IQM version (%d), only version %d is supported.\n", + mod_name, header->version, IQM_VERSION); return qfalse; } @@ -355,6 +351,7 @@ LL( joint->rotate[0] ); LL( joint->rotate[1] ); LL( joint->rotate[2] ); + LL( joint->rotate[3] ); LL( joint->scale[0] ); LL( joint->scale[1] ); LL( joint->scale[2] ); @@ -390,6 +387,7 @@ LL( pose->channeloffset[6] ); LL( pose->channeloffset[7] ); LL( pose->channeloffset[8] ); + LL( pose->channeloffset[9] ); LL( pose->channelscale[0] ); LL( pose->channelscale[1] ); LL( pose->channelscale[2] ); @@ -399,6 +397,7 @@ LL( pose->channelscale[6] ); LL( pose->channelscale[7] ); LL( pose->channelscale[8] ); + LL( pose->channelscale[9] ); } // check and swap model bounds @@ -509,7 +508,9 @@ for( i = 0; i < header->num_frames; i++ ) { pose = (iqmPose_t *)((byte *)header + header->ofs_poses); for( j = 0; j < header->num_poses; j++, pose++ ) { - vec3_t translate, rotate, scale; + vec3_t translate; + vec4_t rotate; + vec3_t scale; float mat1[12], mat2[12]; translate[0] = pose->channeloffset[0]; @@ -521,6 +522,7 @@ translate[2] = pose->channeloffset[2]; if( pose->mask & 0x004) translate[2] += *framedata++ * pose->channelscale[2]; + rotate[0] = pose->channeloffset[3]; if( pose->mask & 0x008) rotate[0] += *framedata++ * pose->channelscale[3]; @@ -530,15 +532,19 @@ rotate[2] = pose->channeloffset[5]; if( pose->mask & 0x020) rotate[2] += *framedata++ * pose->channelscale[5]; - scale[0] = pose->channeloffset[6]; + rotate[3] = pose->channeloffset[6]; if( pose->mask & 0x040) - scale[0] += *framedata++ * pose->channelscale[6]; - scale[1] = pose->channeloffset[7]; + rotate[3] += *framedata++ * pose->channelscale[6]; + + scale[0] = pose->channeloffset[7]; if( pose->mask & 0x080) - scale[1] += *framedata++ * pose->channelscale[7]; - scale[2] = pose->channeloffset[8]; + scale[0] += *framedata++ * pose->channelscale[7]; + scale[1] = pose->channeloffset[8]; if( pose->mask & 0x100) - scale[2] += *framedata++ * pose->channelscale[8]; + scale[1] += *framedata++ * pose->channelscale[8]; + scale[2] = pose->channeloffset[9]; + if( pose->mask & 0x200) + scale[2] += *framedata++ * pose->channelscale[9]; // construct transformation matrix JointToMatrix( rotate, scale, translate, mat1 );