From 166e9c67e14a8ab65e883a3824167fbfd62b37c0 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Tue, 12 Feb 2013 12:18:05 +0100 Subject: [PATCH] support up to 4 aim bones --- models/player/erebus.iqm_0.txt | 2 +- models/player/gak.iqm_0.txt | 2 +- models/player/gakarmored.iqm_0.txt | 2 +- models/player/gakmasked.iqm_0.txt | 2 +- models/player/ignis.iqm_0.txt | 2 +- models/player/ignishalfmasked.iqm_0.txt | 2 +- models/player/ignismasked.iqm_0.txt | 2 +- models/player/megaerebus.iqm_0.txt | 2 +- models/player/nyx.iqm_0.txt | 2 +- models/player/pyria.iqm_0.txt | 2 +- models/player/seraphina.iqm_0.txt | 2 +- models/player/seraphinamasked.iqm_0.txt | 2 +- models/player/umbra.iqm_0.txt | 2 +- qcsrc/client/player_skeleton.qc | 53 +++++++++++-------------- qcsrc/client/player_skeleton.qh | 6 +-- qcsrc/common/util.qc | 27 ++++++------- qcsrc/common/util.qh | 7 ++-- 17 files changed, 54 insertions(+), 65 deletions(-) diff --git a/models/player/erebus.iqm_0.txt b/models/player/erebus.iqm_0.txt index 359949d2e..a7fc97853 100644 --- a/models/player/erebus.iqm_0.txt +++ b/models/player/erebus.iqm_0.txt @@ -4,7 +4,7 @@ sex Male weight 105 age 26 bone_upperbody spine2 -bone_aim1 1 spine2 +bone_aim0 1 spine2 bone_weapon bip01 r hand fixbone 1 diff --git a/models/player/gak.iqm_0.txt b/models/player/gak.iqm_0.txt index 160f2ec4e..ba6faaed7 100644 --- a/models/player/gak.iqm_0.txt +++ b/models/player/gak.iqm_0.txt @@ -4,7 +4,7 @@ sex Male weight 85 age 16 bone_upperbody spine2 -bone_aim1 1 spine2 +bone_aim0 1 spine2 bone_weapon bip01 r hand fixbone 1 diff --git a/models/player/gakarmored.iqm_0.txt b/models/player/gakarmored.iqm_0.txt index 3378343fc..c3096b387 100644 --- a/models/player/gakarmored.iqm_0.txt +++ b/models/player/gakarmored.iqm_0.txt @@ -4,7 +4,7 @@ sex Male weight 90 age 20 bone_upperbody spine2 -bone_aim1 1 spine2 +bone_aim0 1 spine2 bone_weapon bip01 r hand fixbone 1 diff --git a/models/player/gakmasked.iqm_0.txt b/models/player/gakmasked.iqm_0.txt index 84b27c74e..796da05aa 100644 --- a/models/player/gakmasked.iqm_0.txt +++ b/models/player/gakmasked.iqm_0.txt @@ -4,7 +4,7 @@ sex Male weight 87 age 18 bone_upperbody spine2 -bone_aim1 1 spine2 +bone_aim0 1 spine2 bone_weapon bip01 r hand fixbone 1 diff --git a/models/player/ignis.iqm_0.txt b/models/player/ignis.iqm_0.txt index f2b4e3ff3..73035425b 100644 --- a/models/player/ignis.iqm_0.txt +++ b/models/player/ignis.iqm_0.txt @@ -4,7 +4,7 @@ sex Male weight 88 age 31 bone_upperbody spine2 -bone_aim1 1 spine2 +bone_aim0 1 spine2 bone_weapon bip01 r hand fixbone 1 diff --git a/models/player/ignishalfmasked.iqm_0.txt b/models/player/ignishalfmasked.iqm_0.txt index 7cd377b31..e0d82ea74 100644 --- a/models/player/ignishalfmasked.iqm_0.txt +++ b/models/player/ignishalfmasked.iqm_0.txt @@ -4,7 +4,7 @@ sex Male weight 90 age 31 bone_upperbody spine2 -bone_aim1 1 spine2 +bone_aim0 1 spine2 bone_weapon bip01 r hand fixbone 1 diff --git a/models/player/ignismasked.iqm_0.txt b/models/player/ignismasked.iqm_0.txt index a4b082c70..3db94af41 100644 --- a/models/player/ignismasked.iqm_0.txt +++ b/models/player/ignismasked.iqm_0.txt @@ -4,7 +4,7 @@ sex Male weight 92 age 31 bone_upperbody spine2 -bone_aim1 1 spine2 +bone_aim0 1 spine2 bone_weapon bip01 r hand fixbone 1 diff --git a/models/player/megaerebus.iqm_0.txt b/models/player/megaerebus.iqm_0.txt index e8bbbf10c..4097c3b8b 100644 --- a/models/player/megaerebus.iqm_0.txt +++ b/models/player/megaerebus.iqm_0.txt @@ -4,7 +4,7 @@ sex Male weight 210 age 26 bone_upperbody spine2 -bone_aim1 1 spine2 +bone_aim0 1 spine2 bone_weapon bip01 r hand fixbone 1 diff --git a/models/player/nyx.iqm_0.txt b/models/player/nyx.iqm_0.txt index 6184efddb..385546f12 100644 --- a/models/player/nyx.iqm_0.txt +++ b/models/player/nyx.iqm_0.txt @@ -4,7 +4,7 @@ sex Female weight 100 age 24 bone_upperbody spine2 -bone_aim1 1 spine2 +bone_aim0 1 spine2 bone_weapon bip01 r hand fixbone 1 diff --git a/models/player/pyria.iqm_0.txt b/models/player/pyria.iqm_0.txt index d18f4b56f..f1abbd371 100644 --- a/models/player/pyria.iqm_0.txt +++ b/models/player/pyria.iqm_0.txt @@ -4,7 +4,7 @@ sex Female weight 57 age 53 bone_upperbody spine2 -bone_aim1 1 spine2 +bone_aim0 1 spine2 bone_weapon bip01 r hand fixbone 1 diff --git a/models/player/seraphina.iqm_0.txt b/models/player/seraphina.iqm_0.txt index 186c4a421..530f559e1 100644 --- a/models/player/seraphina.iqm_0.txt +++ b/models/player/seraphina.iqm_0.txt @@ -4,7 +4,7 @@ sex Female weight 89 age 31 bone_upperbody spine2 -bone_aim1 1 spine2 +bone_aim0 1 spine2 bone_weapon bip01 r hand fixbone 1 diff --git a/models/player/seraphinamasked.iqm_0.txt b/models/player/seraphinamasked.iqm_0.txt index b20ef794a..be15edbaf 100644 --- a/models/player/seraphinamasked.iqm_0.txt +++ b/models/player/seraphinamasked.iqm_0.txt @@ -4,7 +4,7 @@ sex Female weight 90 age 31 bone_upperbody spine2 -bone_aim1 1 spine2 +bone_aim0 1 spine2 bone_weapon bip01 r hand fixbone 1 diff --git a/models/player/umbra.iqm_0.txt b/models/player/umbra.iqm_0.txt index 0572cb2b3..f20562a9f 100644 --- a/models/player/umbra.iqm_0.txt +++ b/models/player/umbra.iqm_0.txt @@ -4,7 +4,7 @@ sex Female weight 61 age 25 bone_upperbody spine2 -bone_aim1 1 spine2 +bone_aim0 1 spine2 bone_weapon bip01 r hand fixbone 1 diff --git a/qcsrc/client/player_skeleton.qc b/qcsrc/client/player_skeleton.qc index 96879c561..fbbbb94a9 100644 --- a/qcsrc/client/player_skeleton.qc +++ b/qcsrc/client/player_skeleton.qc @@ -8,6 +8,7 @@ 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; @@ -16,10 +17,11 @@ void skeleton_loadinfo(entity e) 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)) { @@ -29,14 +31,13 @@ void skeleton_loadinfo(entity e) 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"); @@ -99,6 +100,7 @@ void free_skeleton_from_frames(entity e) void skeleton_from_frames(entity e) { + float i; float m = e.modelindex; if(!e.skeletonindex) { @@ -164,23 +166,16 @@ void skeleton_from_frames(entity e) 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); + } } } diff --git a/qcsrc/client/player_skeleton.qh b/qcsrc/client/player_skeleton.qh index 45023a7b1..047a15671 100644 --- a/qcsrc/client/player_skeleton.qh +++ b/qcsrc/client/player_skeleton.qh @@ -4,8 +4,6 @@ void skeleton_loadinfo(entity e); .float bone_upperbody; .float bone_weapon; -.float bone_aim1; -.float bone_aim1weight; -.float bone_aim2; -.float bone_aim2weight; +.float bone_aim[MAX_AIM_BONES]; +.float bone_aimweight[MAX_AIM_BONES]; .float fixbone; diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index f6f318c48..8f6a9c05c 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -2001,7 +2001,7 @@ string get_model_datafilename(string m, float sk, string fil) 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; @@ -2013,10 +2013,11 @@ float get_model_parameters(string m, float sk) 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) @@ -2077,16 +2078,12 @@ float get_model_parameters(string m, float sk) 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); } diff --git a/qcsrc/common/util.qh b/qcsrc/common/util.qh index a406e1242..93a62fcf6 100644 --- a/qcsrc/common/util.qh +++ b/qcsrc/common/util.qh @@ -252,10 +252,9 @@ float get_model_parameters_weight; 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 -- 2.39.2