mirror of
https://github.com/nzp-team/fteqw.git
synced 2025-02-18 09:51:50 +00:00
fix hitmodel with hlmdl, to actually work properly with rotated entities.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5072 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
dadec86338
commit
cb010176a1
4 changed files with 71 additions and 61 deletions
|
@ -2902,6 +2902,8 @@ static void M_ModelViewerDraw(int x, int y, struct menucustom_s *c, struct menu_
|
||||||
|
|
||||||
memset(&ent, 0, sizeof(ent));
|
memset(&ent, 0, sizeof(ent));
|
||||||
ent.scale = 1;
|
ent.scale = 1;
|
||||||
|
// ent.angles[1] = realtime*45;//mods->yaw;
|
||||||
|
// ent.angles[0] = realtime*23.4;//mods->pitch;
|
||||||
ent.model = Mod_ForName(mods->modelname, MLV_WARN);
|
ent.model = Mod_ForName(mods->modelname, MLV_WARN);
|
||||||
if (!ent.model)
|
if (!ent.model)
|
||||||
return; //panic!
|
return; //panic!
|
||||||
|
@ -2933,10 +2935,10 @@ static void M_ModelViewerDraw(int x, int y, struct menucustom_s *c, struct menu_
|
||||||
ent.light_known = 2;
|
ent.light_known = 2;
|
||||||
|
|
||||||
|
|
||||||
// ent.angles[0]*=r_meshpitch.value;
|
ent.angles[0]*=r_meshpitch.value;
|
||||||
AngleVectors(ent.angles, ent.axis[0], ent.axis[1], ent.axis[2]);
|
AngleVectors(ent.angles, ent.axis[0], ent.axis[1], ent.axis[2]);
|
||||||
|
ent.angles[0]*=r_meshpitch.value;
|
||||||
VectorInverse(ent.axis[1]);
|
VectorInverse(ent.axis[1]);
|
||||||
// ent.angles[0]*=r_meshpitch.value;
|
|
||||||
|
|
||||||
if (ent.model->type == mod_dummy)
|
if (ent.model->type == mod_dummy)
|
||||||
{
|
{
|
||||||
|
@ -3042,7 +3044,7 @@ static void M_ModelViewerDraw(int x, int y, struct menucustom_s *c, struct menu_
|
||||||
"}\n"
|
"}\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
|
|
||||||
if (ent.model->funcs.NativeTrace && ent.model->funcs.NativeTrace(ent.model, 0, &ent.framestate, NULL, v1, v2, vec3_origin, vec3_origin, false, ~0, &tr))
|
if (ent.model->funcs.NativeTrace && ent.model->funcs.NativeTrace(ent.model, 0, &ent.framestate, ent.axis, v1, v2, vec3_origin, vec3_origin, false, ~0, &tr))
|
||||||
{
|
{
|
||||||
vec3_t dir;
|
vec3_t dir;
|
||||||
float f;
|
float f;
|
||||||
|
@ -3095,12 +3097,14 @@ static void M_ModelViewerDraw(int x, int y, struct menucustom_s *c, struct menu_
|
||||||
float boneinfo[12];
|
float boneinfo[12];
|
||||||
|
|
||||||
Mod_GetTag(ent.model, b, &ent.framestate, boneinfo);
|
Mod_GetTag(ent.model, b, &ent.framestate, boneinfo);
|
||||||
|
//fixme: no axis transform
|
||||||
VectorSet(start, boneinfo[3], boneinfo[7], boneinfo[11]);
|
VectorSet(start, boneinfo[3], boneinfo[7], boneinfo[11]);
|
||||||
VectorAdd(start, ent.origin, start);
|
VectorAdd(start, ent.origin, start);
|
||||||
|
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
Mod_GetTag(ent.model, p, &ent.framestate, boneinfo);
|
Mod_GetTag(ent.model, p, &ent.framestate, boneinfo);
|
||||||
|
//fixme: no axis transform
|
||||||
VectorSet(end, boneinfo[3], boneinfo[7], boneinfo[11]);
|
VectorSet(end, boneinfo[3], boneinfo[7], boneinfo[11]);
|
||||||
VectorAdd(end, ent.origin, end);
|
VectorAdd(end, ent.origin, end);
|
||||||
CLQ1_DrawLine(lineshader, start, end, 1, (b-1 == mods->boneidx)?0:1, 1, 1);
|
CLQ1_DrawLine(lineshader, start, end, 1, (b-1 == mods->boneidx)?0:1, 1, 1);
|
||||||
|
|
|
@ -2029,7 +2029,11 @@ void Mod_AddSingleSurface(entity_t *ent, int surfaceidx, shader_t *shader)
|
||||||
}
|
}
|
||||||
for (i = 0; i < mod->numverts; i++)
|
for (i = 0; i < mod->numverts; i++)
|
||||||
{
|
{
|
||||||
VectorAdd(ent->origin, posedata[i], cl_strisvertv[t->firstvert+i]);
|
VectorMA(ent->origin, posedata[i][0], ent->axis[0], cl_strisvertv[t->firstvert+i]);
|
||||||
|
VectorMA(cl_strisvertv[t->firstvert+i], posedata[i][1], ent->axis[1], cl_strisvertv[t->firstvert+i]);
|
||||||
|
VectorMA(cl_strisvertv[t->firstvert+i], posedata[i][2], ent->axis[2], cl_strisvertv[t->firstvert+i]);
|
||||||
|
// VectorAdd(ent->origin, posedata[i], cl_strisvertv[t->firstvert+i]);
|
||||||
|
|
||||||
Vector2Set(cl_strisvertt[t->firstvert+i], 0.5, 0.5);
|
Vector2Set(cl_strisvertt[t->firstvert+i], 0.5, 0.5);
|
||||||
Vector4Set(cl_strisvertc[t->firstvert+i], (mod->contents?1:0), 1, 1, 0.1);
|
Vector4Set(cl_strisvertc[t->firstvert+i], (mod->contents?1:0), 1, 1, 0.1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -582,32 +582,32 @@ void QDECL R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]
|
||||||
in1[2][2] * in2[2][3] + in1[2][3];
|
in1[2][2] * in2[2][3] + in1[2][3];
|
||||||
}
|
}
|
||||||
|
|
||||||
//R_ConcatTransforms where there's no offset values
|
//R_ConcatTransforms where there's no offset values, and a transposed axis
|
||||||
void R_ConcatTransformsAxis (float in1[3][3], float in2[3][4], float out[3][4])
|
void R_ConcatTransformsAxis (float in1[3][3], float in2[3][4], float out[3][4])
|
||||||
{
|
{
|
||||||
out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] +
|
out[0][0] = in1[0][0] * in2[0][0] + in1[1][0] * in2[1][0] +
|
||||||
in1[0][2] * in2[2][0];
|
in1[2][0] * in2[2][0];
|
||||||
out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] +
|
out[0][1] = in1[0][0] * in2[0][1] + in1[1][0] * in2[1][1] +
|
||||||
in1[0][2] * in2[2][1];
|
in1[2][0] * in2[2][1];
|
||||||
out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] +
|
out[0][2] = in1[0][0] * in2[0][2] + in1[1][1] * in2[1][2] +
|
||||||
in1[0][2] * in2[2][2];
|
in1[2][0] * in2[2][2];
|
||||||
out[0][3] = in1[0][0] * in2[0][3] + in1[0][1] * in2[1][3] +
|
out[0][3] = in1[0][0] * in2[0][3] + in1[1][1] * in2[1][3] +
|
||||||
in1[0][2] * in2[2][3];
|
in1[2][0] * in2[2][3];
|
||||||
out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] +
|
out[1][0] = in1[0][1] * in2[0][0] + in1[1][1] * in2[1][0] +
|
||||||
in1[1][2] * in2[2][0];
|
in1[2][1] * in2[2][0];
|
||||||
out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] +
|
out[1][1] = in1[0][1] * in2[0][1] + in1[1][1] * in2[1][1] +
|
||||||
in1[1][2] * in2[2][1];
|
in1[2][1] * in2[2][1];
|
||||||
out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] +
|
out[1][2] = in1[0][1] * in2[0][2] + in1[1][1] * in2[1][2] +
|
||||||
in1[1][2] * in2[2][2];
|
in1[2][1] * in2[2][2];
|
||||||
out[1][3] = in1[1][0] * in2[0][3] + in1[1][1] * in2[1][3] +
|
out[1][3] = in1[0][1] * in2[0][3] + in1[1][1] * in2[1][3] +
|
||||||
in1[1][2] * in2[2][3];
|
in1[2][1] * in2[2][3];
|
||||||
out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] +
|
out[2][0] = in1[0][2] * in2[0][0] + in1[1][2] * in2[1][0] +
|
||||||
in1[2][2] * in2[2][0];
|
in1[2][2] * in2[2][0];
|
||||||
out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] +
|
out[2][1] = in1[0][2] * in2[0][1] + in1[1][2] * in2[1][1] +
|
||||||
in1[2][2] * in2[2][1];
|
in1[2][2] * in2[2][1];
|
||||||
out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] +
|
out[2][2] = in1[0][2] * in2[0][2] + in1[1][2] * in2[1][2] +
|
||||||
in1[2][2] * in2[2][2];
|
in1[2][2] * in2[2][2];
|
||||||
out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] +
|
out[2][3] = in1[0][2] * in2[0][3] + in1[1][2] * in2[1][3] +
|
||||||
in1[2][2] * in2[2][3];
|
in1[2][2] * in2[2][3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,40 +30,40 @@ unsigned int HLMDL_Contents (struct model_s *model, int hulloverride, framestate
|
||||||
|
|
||||||
void QuaternionGLMatrix(float x, float y, float z, float w, vec4_t *GLM)
|
void QuaternionGLMatrix(float x, float y, float z, float w, vec4_t *GLM)
|
||||||
{
|
{
|
||||||
GLM[0][0] = 1 - 2 * y * y - 2 * z * z;
|
GLM[0][0] = 1 - 2 * y * y - 2 * z * z;
|
||||||
GLM[1][0] = 2 * x * y + 2 * w * z;
|
GLM[1][0] = 2 * x * y + 2 * w * z;
|
||||||
GLM[2][0] = 2 * x * z - 2 * w * y;
|
GLM[2][0] = 2 * x * z - 2 * w * y;
|
||||||
GLM[0][1] = 2 * x * y - 2 * w * z;
|
GLM[0][1] = 2 * x * y - 2 * w * z;
|
||||||
GLM[1][1] = 1 - 2 * x * x - 2 * z * z;
|
GLM[1][1] = 1 - 2 * x * x - 2 * z * z;
|
||||||
GLM[2][1] = 2 * y * z + 2 * w * x;
|
GLM[2][1] = 2 * y * z + 2 * w * x;
|
||||||
GLM[0][2] = 2 * x * z + 2 * w * y;
|
GLM[0][2] = 2 * x * z + 2 * w * y;
|
||||||
GLM[1][2] = 2 * y * z - 2 * w * x;
|
GLM[1][2] = 2 * y * z - 2 * w * x;
|
||||||
GLM[2][2] = 1 - 2 * x * x - 2 * y * y;
|
GLM[2][2] = 1 - 2 * x * x - 2 * y * y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=======================================================================================================================
|
=======================================================================================================================
|
||||||
QuaternionGLAngle - Convert a GL angle to a quaternion matrix
|
QuaternionGLAngle - Convert a GL angle to a quaternion matrix
|
||||||
=======================================================================================================================
|
=======================================================================================================================
|
||||||
*/
|
*/
|
||||||
void QuaternionGLAngle(const vec3_t angles, vec4_t quaternion)
|
void QuaternionGLAngle(const vec3_t angles, vec4_t quaternion)
|
||||||
{
|
{
|
||||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||||
float yaw = angles[2] * 0.5;
|
float yaw = angles[2] * 0.5;
|
||||||
float pitch = angles[1] * 0.5;
|
float pitch = angles[1] * 0.5;
|
||||||
float roll = angles[0] * 0.5;
|
float roll = angles[0] * 0.5;
|
||||||
float siny = sin(yaw);
|
float siny = sin(yaw);
|
||||||
float cosy = cos(yaw);
|
float cosy = cos(yaw);
|
||||||
float sinp = sin(pitch);
|
float sinp = sin(pitch);
|
||||||
float cosp = cos(pitch);
|
float cosp = cos(pitch);
|
||||||
float sinr = sin(roll);
|
float sinr = sin(roll);
|
||||||
float cosr = cos(roll);
|
float cosr = cos(roll);
|
||||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||||
|
|
||||||
quaternion[0] = sinr * cosp * cosy - cosr * sinp * siny;
|
quaternion[0] = sinr * cosp * cosy - cosr * sinp * siny;
|
||||||
quaternion[1] = cosr * sinp * cosy + sinr * cosp * siny;
|
quaternion[1] = cosr * sinp * cosy + sinr * cosp * siny;
|
||||||
quaternion[2] = cosr * cosp * siny - sinr * sinp * cosy;
|
quaternion[2] = cosr * cosp * siny - sinr * sinp * cosy;
|
||||||
quaternion[3] = cosr * cosp * cosy + sinr * sinp * siny;
|
quaternion[3] = cosr * cosp * cosy + sinr * sinp * siny;
|
||||||
}
|
}
|
||||||
|
|
||||||
matrix3x4 transform_matrix[MAX_BONES]; /* Vertex transformation matrix */
|
matrix3x4 transform_matrix[MAX_BONES]; /* Vertex transformation matrix */
|
||||||
|
@ -231,7 +231,7 @@ static void HLMDL_PrepareVerticies (hlmodel_t *model, hlmdl_submodel_t *amodel,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=======================================================================================================================
|
=======================================================================================================================
|
||||||
Mod_LoadHLModel - read in the model's constituent parts
|
Mod_LoadHLModel - read in the model's constituent parts
|
||||||
=======================================================================================================================
|
=======================================================================================================================
|
||||||
*/
|
*/
|
||||||
qboolean QDECL Mod_LoadHLModel (model_t *mod, void *buffer, size_t fsize)
|
qboolean QDECL Mod_LoadHLModel (model_t *mod, void *buffer, size_t fsize)
|
||||||
|
@ -438,7 +438,7 @@ int HLMDL_BoneForName(model_t *mod, const char *name)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=======================================================================================================================
|
=======================================================================================================================
|
||||||
HL_CalculateBones - calculate bone positions - quaternion+vector in one function
|
HL_CalculateBones - calculate bone positions - quaternion+vector in one function
|
||||||
=======================================================================================================================
|
=======================================================================================================================
|
||||||
*/
|
*/
|
||||||
void HL_CalculateBones
|
void HL_CalculateBones
|
||||||
|
@ -488,7 +488,7 @@ void HL_CalculateBones
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=======================================================================================================================
|
=======================================================================================================================
|
||||||
HL_CalcBoneAdj - Calculate the adjustment values for the programmable controllers
|
HL_CalcBoneAdj - Calculate the adjustment values for the programmable controllers
|
||||||
=======================================================================================================================
|
=======================================================================================================================
|
||||||
*/
|
*/
|
||||||
void HL_CalcBoneAdj(hlmodel_t *model)
|
void HL_CalcBoneAdj(hlmodel_t *model)
|
||||||
|
@ -536,7 +536,7 @@ void HL_CalcBoneAdj(hlmodel_t *model)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=======================================================================================================================
|
=======================================================================================================================
|
||||||
HL_SetupBones - determine where vertex should be using bone movements
|
HL_SetupBones - determine where vertex should be using bone movements
|
||||||
=======================================================================================================================
|
=======================================================================================================================
|
||||||
*/
|
*/
|
||||||
void QuaternionSlerp( const vec4_t p, vec4_t q, float t, vec4_t qt );
|
void QuaternionSlerp( const vec4_t p, vec4_t q, float t, vec4_t qt );
|
||||||
|
@ -843,10 +843,6 @@ qboolean HLMDL_Trace (model_t *model, int hulloverride, framestate_t *framestat
|
||||||
qboolean startout, endout;
|
qboolean startout, endout;
|
||||||
int enterplane;
|
int enterplane;
|
||||||
|
|
||||||
extern cvar_t temp1;
|
|
||||||
p1[2] += temp1.value;
|
|
||||||
p2[2] += temp1.value;
|
|
||||||
|
|
||||||
memset (trace, 0, sizeof(trace_t));
|
memset (trace, 0, sizeof(trace_t));
|
||||||
trace->fraction = trace->truefraction = 1;
|
trace->fraction = trace->truefraction = 1;
|
||||||
if (!(against & FTECONTENTS_BODY))
|
if (!(against & FTECONTENTS_BODY))
|
||||||
|
@ -1288,9 +1284,15 @@ void HLMDL_DrawHitBoxes(entity_t *rent)
|
||||||
int bonecount = HLMDL_GetBoneData(rent->model, 0, MAX_BONES, &rent->framestate, relbones);
|
int bonecount = HLMDL_GetBoneData(rent->model, 0, MAX_BONES, &rent->framestate, relbones);
|
||||||
int b;
|
int b;
|
||||||
|
|
||||||
VectorCopy(rent->axis[0], entitymatrix[0]);
|
entitymatrix[0][0] = rent->axis[0][0];
|
||||||
VectorCopy(rent->axis[1], entitymatrix[1]);
|
entitymatrix[0][1] = rent->axis[1][0];
|
||||||
VectorCopy(rent->axis[2], entitymatrix[2]);
|
entitymatrix[0][2] = rent->axis[2][0];
|
||||||
|
entitymatrix[1][0] = rent->axis[0][1];
|
||||||
|
entitymatrix[1][1] = rent->axis[1][1];
|
||||||
|
entitymatrix[1][2] = rent->axis[2][1];
|
||||||
|
entitymatrix[2][0] = rent->axis[0][2];
|
||||||
|
entitymatrix[2][1] = rent->axis[1][2];
|
||||||
|
entitymatrix[2][2] = rent->axis[2][2];
|
||||||
entitymatrix[0][3] = rent->origin[0];
|
entitymatrix[0][3] = rent->origin[0];
|
||||||
entitymatrix[1][3] = rent->origin[1];
|
entitymatrix[1][3] = rent->origin[1];
|
||||||
entitymatrix[2][3] = rent->origin[2];
|
entitymatrix[2][3] = rent->origin[2];
|
||||||
|
|
Loading…
Reference in a new issue