mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Animations nearly aligning correctly.
This commit is contained in:
parent
ac1ae6c596
commit
77614ca015
@ -35,7 +35,7 @@ if(_sendToExtension) then {
|
||||
|
||||
_cmd = "set_animation_state:";
|
||||
{
|
||||
_cmd = _cmd + format["%1,%2,", (_x select 0), (_x select 1)];
|
||||
_cmd = _cmd + format["%1,%2,", (_x select 0), ([(_x select 1)] call CBA_fnc_formatNumber)];
|
||||
} forEach _animationResults;
|
||||
|
||||
_cmd call FUNC(callExtension);
|
||||
|
@ -18,4 +18,4 @@
|
||||
#define DEBUG_EXTENSION_DYNLOAD
|
||||
#define DEBUG_LOG_EXTENSION
|
||||
//#define DEBUG_EXTENSION_DYNLOAD_RELOAD
|
||||
#define DEBUG_VEHICLEDAMAGE_RENDER
|
||||
//#define DEBUG_VEHICLEDAMAGE_RENDER
|
@ -40,6 +40,9 @@ namespace ace {
|
||||
public:
|
||||
arguments(const std::string & str) : _original(str) {
|
||||
_args = ace::split(str, ',');
|
||||
for (int i = 0; i < _args.size(); i++) {
|
||||
_args[i] = trim(_args[i]);
|
||||
}
|
||||
}
|
||||
|
||||
size_t size() const { return _args.size(); }
|
||||
|
@ -1,5 +1,10 @@
|
||||
#include "shared.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <cctype>
|
||||
#include <locale>
|
||||
|
||||
int test(int var) {
|
||||
return var;
|
||||
}
|
||||
|
@ -40,6 +40,23 @@ namespace ace {
|
||||
std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems);
|
||||
std::vector<std::string> split(const std::string &s, char delim);
|
||||
|
||||
// trim from start
|
||||
static inline std::string <rim(std::string &s) {
|
||||
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
|
||||
return s;
|
||||
}
|
||||
|
||||
// trim from end
|
||||
static inline std::string &rtrim(std::string &s) {
|
||||
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
|
||||
return s;
|
||||
}
|
||||
|
||||
// trim from both ends
|
||||
static inline std::string &trim(std::string &s) {
|
||||
return ltrim(rtrim(s));
|
||||
}
|
||||
|
||||
inline void runtime_assert(bool result);
|
||||
|
||||
struct exception {
|
||||
|
@ -220,15 +220,18 @@ animation_transform ace::simulation::animation::animate(const float phase, const
|
||||
|
||||
float scale = get_scale(phase);
|
||||
|
||||
glm::vec3 axis_position = glm::vec3(this->lod_info[lod_id]->axis_position.x(), this->lod_info[lod_id]->axis_position.y(), this->lod_info[lod_id]->axis_position.z());
|
||||
glm::vec3 axis_direction = glm::vec3(this->lod_info[lod_id]->axis_direction.x(), this->lod_info[lod_id]->axis_direction.y(), this->lod_info[lod_id]->axis_direction.z());
|
||||
|
||||
if (true) {
|
||||
switch (this->type) {
|
||||
//rotation
|
||||
case 0: {
|
||||
scale = (scale / (max_value - min_value)) * (angle1 - angle0);
|
||||
glm::vec3 rotation_axis = glm::vec3(this->lod_info[lod_id]->axis_position.x(), this->lod_info[lod_id]->axis_position.y(), this->lod_info[lod_id]->axis_position.z());
|
||||
glm::vec3 rotation_direction = glm::vec3(this->lod_info[lod_id]->axis_direction.x(), this->lod_info[lod_id]->axis_direction.y(), this->lod_info[lod_id]->axis_direction.z());
|
||||
|
||||
animation_matrix = glm::rotate(glm::mat4(1.0f), scale, rotation_direction);
|
||||
direction_matrix = glm::translate(glm::mat4(1.0f), rotation_axis);
|
||||
animation_matrix = glm::rotate(glm::mat4(1.0f), scale, axis_direction);
|
||||
direction_matrix = glm::translate(glm::mat4(1.0f), axis_position);
|
||||
|
||||
animation_matrix = animation_matrix * direction_matrix;
|
||||
|
||||
rotation_offset = this->lod_info[lod_id]->axis_position;
|
||||
@ -238,7 +241,12 @@ animation_transform ace::simulation::animation::animate(const float phase, const
|
||||
case 1: {
|
||||
scale = (scale / (max_value - min_value)) * (angle1 - angle0);
|
||||
glm::vec3 rotation_axis = glm::vec3(1.0f, 0.0f, 0.0f);
|
||||
animation_matrix = glm::rotate(animation_matrix, scale, rotation_axis);
|
||||
|
||||
animation_matrix = glm::rotate(glm::mat4(1.0f), scale, rotation_axis);
|
||||
direction_matrix = glm::translate(glm::mat4(1.0f), axis_position);
|
||||
|
||||
animation_matrix = animation_matrix * direction_matrix;
|
||||
|
||||
rotation_offset = this->lod_info[lod_id]->axis_position;
|
||||
break;
|
||||
}
|
||||
@ -246,7 +254,12 @@ animation_transform ace::simulation::animation::animate(const float phase, const
|
||||
case 2: {
|
||||
scale = (scale / (max_value - min_value)) * (angle1 - angle0);
|
||||
glm::vec3 rotation_axis = glm::vec3(0.0f, 1.0f, 0.0f);
|
||||
animation_matrix = glm::rotate(animation_matrix, scale, rotation_axis);
|
||||
|
||||
animation_matrix = glm::rotate(glm::mat4(1.0f), scale, rotation_axis);
|
||||
direction_matrix = glm::translate(glm::mat4(1.0f), axis_position);
|
||||
|
||||
animation_matrix = animation_matrix * direction_matrix;
|
||||
|
||||
rotation_offset = this->lod_info[lod_id]->axis_position;
|
||||
break;
|
||||
}
|
||||
@ -254,23 +267,28 @@ animation_transform ace::simulation::animation::animate(const float phase, const
|
||||
case 3: {
|
||||
scale = (scale / (max_value - min_value)) * (angle1 - angle0);
|
||||
glm::vec3 rotation_axis = glm::vec3(0.0f, 0.0f, 1.0f);
|
||||
animation_matrix = glm::rotate(animation_matrix, scale, rotation_axis);
|
||||
|
||||
animation_matrix = glm::rotate(glm::mat4(1.0f), scale, rotation_axis);
|
||||
direction_matrix = glm::translate(glm::mat4(1.0f), axis_position);
|
||||
|
||||
animation_matrix = animation_matrix * direction_matrix;
|
||||
|
||||
rotation_offset = this->lod_info[lod_id]->axis_position;
|
||||
break;
|
||||
}
|
||||
//translation
|
||||
case 4: {
|
||||
scale = (scale / (max_value - min_value)) * (offset1 - offset0);
|
||||
animation_matrix = glm::translate(animation_matrix, glm::vec3(
|
||||
animation_matrix = glm::translate(glm::mat4(1.0f), glm::vec3(
|
||||
this->lod_info[lod_id]->axis_direction.x()*scale,
|
||||
this->lod_info[lod_id]->axis_direction.y()*scale,
|
||||
this->lod_info[lod_id]->axis_direction.z()*scale
|
||||
));
|
||||
|
||||
break;
|
||||
}
|
||||
//translationX
|
||||
case 5: {
|
||||
scale = (scale / (max_value - min_value)) * (offset1 - offset0);
|
||||
animation_matrix = glm::translate(animation_matrix, glm::vec3(
|
||||
scale,
|
||||
0.0f,
|
||||
@ -280,6 +298,7 @@ animation_transform ace::simulation::animation::animate(const float phase, const
|
||||
}
|
||||
//translationY
|
||||
case 6: {
|
||||
scale = (scale / (max_value - min_value)) * (offset1 - offset0);
|
||||
animation_matrix = glm::translate(animation_matrix, glm::vec3(
|
||||
0.0f,
|
||||
scale,
|
||||
@ -289,6 +308,7 @@ animation_transform ace::simulation::animation::animate(const float phase, const
|
||||
}
|
||||
//translationZ
|
||||
case 7: {
|
||||
scale = (scale / (max_value - min_value)) * (offset1 - offset0);
|
||||
animation_matrix = glm::translate(animation_matrix, glm::vec3(
|
||||
0.0f,
|
||||
0.0f,
|
||||
@ -310,6 +330,7 @@ animation_transform ace::simulation::animation::animate(const float phase, const
|
||||
return_matrices[lod_id].first = animation_matrix * base_matrix;
|
||||
return_matrices[lod_id].second = base_rotation_offset + rotation_offset;
|
||||
}
|
||||
}
|
||||
return return_matrices;
|
||||
}
|
||||
|
||||
|
@ -69,5 +69,11 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
getchar();
|
||||
while (true) {
|
||||
scanf_s("%s", buffer, sizeof(buffer) - 1);
|
||||
memset(output, 0x00, sizeof(output));
|
||||
LOG(INFO) << "Executing: '" << buffer << "'";
|
||||
RVExtension(output, sizeof(output), buffer);
|
||||
LOG(INFO) << "Result: '" << output << "'";
|
||||
}
|
||||
}
|
@ -1,9 +1,5 @@
|
||||
#c:\arma\arma3\addons\armor_f_epb.pbo C:\dev\ace3\extensions\tests\longrod_dxtk_test.txt
|
||||
init:
|
||||
debug_render:
|
||||
register_vehicle:\A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, 1, 4046.21;3902.56;5.075
|
||||
#set_animation_state:damageHide, 0, Wheel_kolL1, 4.45242e-005, Wheel_koloL1, 4.45242e-005, Wheel_podkoloL1, 0.520781, Wheel_kolP1, 4.45066e-005, Wheel_koloP1, 4.45066e-005, Wheel_podkoloP1, 0.521964, Wheel_kolL2, 4.45242e-005, Wheel_kolP2, 4.45066e-005, Wheel_koloL2, 4.45242e-005, Wheel_koloL3, 4.45242e-005, Wheel_koloL4, 4.45242e-005, Wheel_koloL5, 4.45242e-005, Wheel_koloL6, 4.45242e-005, Wheel_koloL7, 4.45242e-005, Wheel_koloP2, 4.45066e-005, Wheel_koloP3, 4.45066e-005, Wheel_koloP4, 4.45066e-005, Wheel_koloP5, 4.45066e-005, Wheel_koloP6, 4.45066e-005, Wheel_koloP7, 4.45066e-005, Wheel_podkoloL2, 0.507025, Wheel_podkoloL3, 0.500526, Wheel_podkoloL4, 0.509195, Wheel_podkoloL5, 0.49289, Wheel_podkoloL6, 0.48161, Wheel_podkoloP2, 0.513542, Wheel_podkoloP3, 0.507042, Wheel_podkoloP4, 0.500768, Wheel_podkoloP5, 0.496353, Wheel_podkoloP6, 0.503705, podkoloL1_hide_damage, 0, podkoloL2_hide_damage, 0, podkoloL3_hide_damage, 0, podkoloL4_hide_damage, 0, podkoloL5_hide_damage, 0, podkoloL6_hide_damage, 0, podkoloL7_hide_damage, 0, podkoloL8_hide_damage, 0, podkoloP1_hide_damage, 0, podkoloP2_hide_damage, 0, podkoloP3_hide_damage, 0, podkoloP4_hide_damage, 0, podkoloP5_hide_damage, 0, podkoloP6_hide_damage, 0, podkoloP7_hide_damage, 0, podkoloP8_hide_damage, 0, damageVez, 0, MainTurret, 2.37036, MainGun, 0.347653, Recoil, 0, ObsTurret, 0, ObsGun, 0, MainGunOptics, 0.347653, Wheel_podkoloP7, 0.493503, Wheel_podkoloL7, 0.479849, HatchDriver, 0, HatchCommander, 0, HatchGunner, 0, damageVezVelitele, 0, poklop_commander_damage, 0, poklop_gunner_damage, 0, poklop_driver_damage, 0, zaslehROT_HMG, 0, zaslehROT_coax, 14.094, cannon_muzzle_flash, 0, zaslehROT_cannon, 18, HideHull, 0.303806, HideTurret, 0.0209581, LockMuzzle, 0,
|
||||
#hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, ["damagehide"], 0.984803;0.173649;-0.00285841, 0.0029445;-0.000238176;0.999996, 2, Sh_120mm_APFSDS_Tracer_Yellow, 65, 27, 0, 0, 0, -108.073;1739.99;-17.7792, -18.9268;0.0336914;-1.73933, -0.0619889;0.998028;-0.00989257, 0.173648;-0.984808;-0.000745866
|
||||
hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, [], 0.984803;0.173649;-0.00285841, 0.0029445;-0.000238176;0.999996, 2, Sh_120mm_APFSDS_Tracer_Yellow, 65, 27, 0, 0, 0, -107.792;1724.28;-18.3618, -18.9268;0.0336914;-1.73933, -0.0619889;0.998028;-0.00989257, 0.173648;-0.984808;-0.000746796
|
||||
#hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, [], 0.984803;0.173649;-0.00285841, 0.0029445;-0.000238176;0.999996, 2, Sh_120mm_APFSDS_Tracer_Yellow, 65, 27, 0, 0, 0, -106.921;1703.28;-19.728, -18.9268;0.0336914;-1.73933, -0.0619889;0.998028;-0.00989257, 0.173648;-0.984808;-0.000745866
|
||||
#hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, [], 0.984803;0.173649;-0.00285841, 0.0029445;-0.000238176;0.999996, 2, Sh_120mm_APFSDS_Tracer_Yellow, 65, 27, 0, 0, 0, -92.8136;1569.56;-19.7856, -18.9268;0.0336914;-1.73933, -0.0619889;0.998028;-0.00989257, 0.173648;-0.984808;-0.000746472
|
||||
#hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, ["damagehide"], 0.984803;0.173649;-0.00285841, 0.0029445;-0.000238176;0.999996, 2, Sh_120mm_APFSDS_Tracer_Yellow, 65, 27, 0, 0, 0, -76.7551;1435.97;-17.8176, -18.9268;0.0336914;-1.73933, -0.0619889;0.998028;-0.00989257, 0.173648;-0.984808;-0.000745866
|
||||
set_animation_state:1,damageHide, 0, Wheel_kolL1, 0, Wheel_koloL1, 0, Wheel_podkoloL1, 1, Wheel_kolP1, 0, Wheel_koloP1, 0, Wheel_podkoloP1, 1, Wheel_kolL2, 0, Wheel_kolP2, 0, Wheel_koloL2, 0, Wheel_koloL3, 0, Wheel_koloL4, 0, Wheel_koloL5, 0, Wheel_koloL6, 0, Wheel_koloL7, 0, Wheel_koloP2, 0, Wheel_koloP3, 0, Wheel_koloP4, 0, Wheel_koloP5, 0, Wheel_koloP6, 0, Wheel_koloP7, 0, Wheel_podkoloL2, 1, Wheel_podkoloL3, 1, Wheel_podkoloL4, 1, Wheel_podkoloL5, 0, Wheel_podkoloL6, 0, Wheel_podkoloP2, 1, Wheel_podkoloP3, 1, Wheel_podkoloP4, 1, Wheel_podkoloP5, 0, Wheel_podkoloP6, 1, podkoloL1_hide_damage, 0, podkoloL2_hide_damage, 0, podkoloL3_hide_damage, 0, podkoloL4_hide_damage, 0, podkoloL5_hide_damage, 0, podkoloL6_hide_damage, 0, podkoloL7_hide_damage, 0, podkoloL8_hide_damage, 0, podkoloP1_hide_damage, 0, podkoloP2_hide_damage, 0, podkoloP3_hide_damage, 0, podkoloP4_hide_damage, 0, podkoloP5_hide_damage, 0, podkoloP6_hide_damage, 0, podkoloP7_hide_damage, 0, podkoloP8_hide_damage, 0, damageVez, 0, MainTurret, -3, MainGun, 0, Recoil, 0, ObsTurret, -0, ObsGun, 0, MainGunOptics, 0, Wheel_podkoloP7, 0, Wheel_podkoloL7, 0, HatchDriver, 0, HatchCommander, 0, HatchGunner, 0, damageVezVelitele, 0, poklop_commander_damage, 0, poklop_gunner_damage, 0, poklop_driver_damage, 0, zaslehROT_HMG, 101, zaslehROT_coax, 16, cannon_muzzle_flash, 0, zaslehROT_cannon, 956, HideHull, 1, HideTurret, 1, LockMuzzle, 0
|
@ -1,5 +1,6 @@
|
||||
#c:\arma\arma3\addons\structures_f_ind.pbo C:\dev\ace3\extensions\tests\longrod_dxtk_test.txt.backup
|
||||
init:
|
||||
debug_render:
|
||||
register_vehicle:\A3\Structures_F\Ind\Cargo\Cargo40_blue_F.p3d,0,4050.18;3802.55;5.075
|
||||
set_animation_state:Door_1_rot,1,Door_Locked_1_rot,0,Door_2_rot,0,Door_Locked_2_rot,0,
|
||||
set_animation_state:0,Door_1_rot,0,Door_Locked_1_rot,0,Door_2_rot,0,Door_Locked_2_rot,0,
|
||||
fetch_result:1
|
Binary file not shown.
@ -1,3 +1,5 @@
|
||||
# C:\dev\ace3\extensions\tests\test.pbo C:\dev\ace3\extensions\tests\test.pbo.txt
|
||||
init:
|
||||
debug_render:
|
||||
register_vehicle:\test\test.p3d,2,4050.18;3802.55;5.075
|
||||
register_vehicle:\test\test.p3d,0,4050.18;3802.55;5.075
|
||||
set_animation_state:0,box3_rotate,0.5,box3_translate,0,
|
@ -18,7 +18,7 @@ class CfgVehicles {
|
||||
author = "Nou";
|
||||
_generalMacro = "nou_snow_2x2";
|
||||
scope = 2;
|
||||
model = "\x\nou\addons\test_model\test.p3d";
|
||||
model = "test_model\test.p3d";
|
||||
vehicleClass = "Structures";
|
||||
cost = 50000;
|
||||
replaceDamagedLimit = 0.99999;
|
||||
|
@ -20,7 +20,8 @@ namespace ace {
|
||||
}
|
||||
}
|
||||
if (fire_lod == -1) // @TODO: fallback on geo LOD
|
||||
fire_lod = 11;
|
||||
fire_lod = 0;
|
||||
//fire_lod = 0;
|
||||
assert(fire_lod != -1);
|
||||
|
||||
// Build the mesh from object faces
|
||||
|
@ -153,7 +153,7 @@ namespace ace {
|
||||
if (vehicles.find(id) == vehicles.end())
|
||||
return false;
|
||||
|
||||
for (int x = 0, y = 0; x < vehicles[id]->animation_state.size() && x < _args.size() / 2; x++, y +=2) {
|
||||
for (int x = 1, y = 1; x < vehicles[id]->animation_state.size() && x < _args.size() / 2; x++, y +=2) {
|
||||
std::string animation_name = _args[y];
|
||||
float state = _args[y + 1];
|
||||
vehicles[id]->animation_state[animation_name] = state;
|
||||
|
Loading…
Reference in New Issue
Block a user