void skeleton_loadinfo(entity e)
{
+ float i;
if(e.skeleton_info_modelindex == e.modelindex && e.skeleton_info_skin == e.skin)
return;
e.bone_upperbody = 0;
e.bone_weapon = gettagindex(e, "tag_weapon");
if(!e.bone_weapon)
e.bone_weapon = gettagindex(e, "bip01 r hand");
- e.bone_aim1 = 0;
- e.bone_aim2 = 0;
- e.bone_aim1weight = 0;
- e.bone_aim2weight = 0;
+ for(i = 0; i < MAX_AIM_BONES; ++i)
+ {
+ e.bone_aim[i] = 0;
+ e.bone_aimweight[i] = 0;
+ }
e.fixbone = 0;
if(get_model_parameters(e.model, e.skin))
{
e.fixbone = get_model_parameters_fixbone;
if(get_model_parameters_bone_weapon)
e.bone_weapon = gettagindex(e, get_model_parameters_bone_weapon);
- if(get_model_parameters_bone_aim1)
- e.bone_aim1 = gettagindex(e, get_model_parameters_bone_aim1);
- if(e.bone_aim1)
- e.bone_aim1weight = get_model_parameters_bone_aim1weight;
- if(get_model_parameters_bone_aim2)
- e.bone_aim2 = gettagindex(e, get_model_parameters_bone_aim2);
- if(e.bone_aim2)
- e.bone_aim2weight = get_model_parameters_bone_aim2weight;
+ for(i = 0; i < MAX_AIM_BONES; ++i)
+ {
+ if(get_model_parameters_bone_aim[i])
+ e.bone_aim[i] = gettagindex(e, get_model_parameters_bone_aim[i]);
+ if(e.bone_aim[i])
+ e.bone_aimweight[i] = get_model_parameters_bone_aimweight[i];
+ }
}
else
dprint("No model parameters for ", e.model, "\n");
void skeleton_from_frames(entity e)
{
+ float i;
float m = e.modelindex;
if(!e.skeletonindex)
{
skel_set_boneabs(s, e.bone_upperbody, org);
}
- if(e.bone_aim1)
+ for(i = 0; i < MAX_AIM_BONES; ++i)
{
- vector aim = '1 0 0' * bound(-90, self.v_angle_x, 90) * e.bone_aim1weight;
- vector org = skel_get_boneabs(s, e.bone_aim1);
- vector ang_cur = fixedvectoangles2(v_forward, v_up);
- vector ang = AnglesTransform_Multiply(aim, ang_cur);
- fixedmakevectors(ang);
- skel_set_boneabs(s, e.bone_aim1, org);
- }
-
- if(e.bone_aim2)
- {
- vector aim = '1 0 0' * bound(-90, self.v_angle_x, 90) * e.bone_aim2weight;
- vector org = skel_get_boneabs(s, e.bone_aim2);
- vector ang_cur = fixedvectoangles2(v_forward, v_up);
- vector ang = AnglesTransform_Multiply(aim, ang_cur);
- fixedmakevectors(ang);
- skel_set_boneabs(s, e.bone_aim2, org);
+ if(e.bone_aim[i])
+ {
+ vector aim = '1 0 0' * bound(-90, self.v_angle_x, 90) * e.bone_aimweight[i];
+ vector org = skel_get_boneabs(s, e.bone_aim[i]);
+ vector ang_cur = fixedvectoangles2(v_forward, v_up);
+ vector ang = AnglesTransform_Multiply(aim, ang_cur);
+ fixedmakevectors(ang);
+ skel_set_boneabs(s, e.bone_aim[i], org);
+ }
}
}
float get_model_parameters(string m, float sk)
{
string fn, s, c;
- float fh;
+ float fh, i;
get_model_parameters_modelname = string_null;
get_model_parameters_modelskin = -1;
get_model_parameters_desc = string_null;
get_model_parameters_bone_upperbody = string_null;
get_model_parameters_bone_weapon = string_null;
- get_model_parameters_bone_aim1 = string_null;
- get_model_parameters_bone_aim2 = string_null;
- get_model_parameters_bone_aim1weight = 0;
- get_model_parameters_bone_aim2weight = 0;
+ for(i = 0; i < MAX_AIM_BONES; ++i)
+ {
+ get_model_parameters_bone_aim[i] = string_null;
+ get_model_parameters_bone_aimweight[i] = 0;
+ }
get_model_parameters_fixbone = 0;
if not(m)
get_model_parameters_bone_upperbody = s;
if(c == "bone_weapon")
get_model_parameters_bone_weapon = s;
- if(c == "bone_aim1")
- {
- get_model_parameters_bone_aim1weight = stof(car(s));
- get_model_parameters_bone_aim1 = cdr(s);
- }
- if(c == "bone_aim2")
- {
- get_model_parameters_bone_aim2weight = stof(car(s));
- get_model_parameters_bone_aim2 = cdr(s);
- }
+ for(i = 0; i < MAX_AIM_BONES; ++i)
+ if(c == strcat("bone_aim", ftos(i)))
+ {
+ get_model_parameters_bone_aimweight[i] = stof(car(s));
+ get_model_parameters_bone_aim[i] = cdr(s);
+ }
if(c == "fixbone")
get_model_parameters_fixbone = stof(s);
}
float get_model_parameters_age;
string get_model_parameters_bone_upperbody;
string get_model_parameters_bone_weapon;
-string get_model_parameters_bone_aim1;
-float get_model_parameters_bone_aim1weight;
-string get_model_parameters_bone_aim2;
-float get_model_parameters_bone_aim2weight;
+#define MAX_AIM_BONES 4
+string get_model_parameters_bone_aim[MAX_AIM_BONES];
+float get_model_parameters_bone_aimweight[MAX_AIM_BONES];
float get_model_parameters_fixbone;
string get_model_parameters_desc;
float get_model_parameters(string mod, float skn); // call with string_null to clear; skin -1 means mod is the filename of the txt file and is to be split