diff --git a/extensions/common/p3d/lod_info.cpp b/extensions/common/p3d/lod_info.cpp index b7d3cfe094..4b95c853b4 100644 --- a/extensions/common/p3d/lod_info.cpp +++ b/extensions/common/p3d/lod_info.cpp @@ -43,7 +43,7 @@ namespace ace { stream_.read((char *)&u_float_1, sizeof(float)); // Derp, this was only TOH apparently!? - //point_flags = compressed(stream_, true, true); + //point_flags = compressed(stream_, true, true, version); stream_.read((char *)&u_float_2, sizeof(float)); stream_.read((char *)&u_float_3, sizeof(float)); @@ -70,8 +70,8 @@ namespace ace { materials.push_back(std::make_shared(stream_, version)); } - edges.mlod = compressed(stream_, true, false).data; - edges.vertex = compressed(stream_, true, false).data; + edges.mlod = compressed(stream_, true, false, version).data; + edges.vertex = compressed(stream_, true, false, version).data; // @TODO: THIS IS OFF WTF?! // The first face is coming up null, so we missed something @@ -128,14 +128,14 @@ namespace ace { uv::uv() {} uv::uv(std::istream &stream_, uint32_t version = 68) { stream_.read((char *)&uv_scale, sizeof(float) * 4); - data = compressed(stream_, true, true); + data = compressed(stream_, true, true, version); } c_vertex_table::c_vertex_table() {} c_vertex_table::c_vertex_table(std::istream &stream_, uint32_t size_, uint32_t version = 68) : size(size_) { uint32_t temp_count; - point_flags = compressed(stream_, true, true); + point_flags = compressed(stream_, true, true, version); uvsets.push_back(std::make_shared(stream_, version)); @@ -145,7 +145,7 @@ namespace ace { uvsets.push_back(std::make_shared(stream_, version)); } - points = compressed>(stream_, true, false, false); + points = compressed>(stream_, true, false, false, version); size = points.size; } @@ -157,15 +157,15 @@ namespace ace { READ_STRING(name); - faces = compressed(stream_, true, false); + faces = compressed(stream_, true, false, version); - //face_weights = compressed(stream_, true, false); // Face weights - face_weights = compressed(stream_, true, false); + //face_weights = compressed(stream_, true, false, version); // Face weights + face_weights = compressed(stream_, true, false, version); READ_BOOL(is_sectional); - sections = compressed(stream_, true, false); - vertex_table = compressed(stream_, true, false); - texture_weights = compressed(stream_, true, false); + sections = compressed(stream_, true, false, version); + vertex_table = compressed(stream_, true, false, version); + texture_weights = compressed(stream_, true, false, version); //stream_.read((char *)&junk, 4); } diff --git a/extensions/common/p3d/model_info.cpp b/extensions/common/p3d/model_info.cpp index 09b85f6e93..c373907a9a 100644 --- a/extensions/common/p3d/model_info.cpp +++ b/extensions/common/p3d/model_info.cpp @@ -8,7 +8,7 @@ namespace ace { raw_resolutions(nullptr), u_floats_1(nullptr), default_indicators(nullptr) { } - model_info::model_info(std::istream & stream_, const uint32_t lod_count) + model_info::model_info(std::istream & stream_, const uint32_t lod_count, uint32_t version) : raw_resolutions(nullptr), u_floats_1(nullptr), default_indicators(nullptr) { raw_resolutions = new float[lod_count]; @@ -57,7 +57,7 @@ namespace ace { stream_.read((char *)&u_byte_1, sizeof(uint8_t)); - compressed u_floats_1(stream_, true, false); + compressed u_floats_1(stream_, true, false, version); stream_.read((char *)&mass, sizeof(float)); stream_.read((char *)&mass_reciprocal, sizeof(float)); diff --git a/extensions/common/p3d/model_info.hpp b/extensions/common/p3d/model_info.hpp index e6baa9b240..195e925a5a 100644 --- a/extensions/common/p3d/model_info.hpp +++ b/extensions/common/p3d/model_info.hpp @@ -11,7 +11,7 @@ namespace ace { class model_info { public: model_info(); - model_info(std::istream &, const uint32_t lod_count); + model_info(std::istream &, const uint32_t lod_count, uint32_t version = 68); ~model_info(); diff --git a/extensions/common/simulation/object.cpp b/extensions/common/simulation/object.cpp index 092eb2d518..0831111711 100644 --- a/extensions/common/simulation/object.cpp +++ b/extensions/common/simulation/object.cpp @@ -223,7 +223,7 @@ animation_transform ace::simulation::animation::animate(const float phase, const 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) { + if (this->type < 4) { switch (this->type) { //rotation case 0: { @@ -242,7 +242,7 @@ animation_transform ace::simulation::animation::animate(const float phase, const scale = (scale / (max_value - min_value)) * (angle1 - angle0); glm::vec3 rotation_axis = glm::vec3(1.0f, 0.0f, 0.0f); - animation_matrix = glm::rotate(glm::mat4(1.0f), 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; @@ -268,8 +268,9 @@ animation_transform ace::simulation::animation::animate(const float phase, const scale = (scale / (max_value - min_value)) * (angle1 - angle0); glm::vec3 rotation_axis = glm::vec3(0.0f, 0.0f, 1.0f); - animation_matrix = glm::rotate(glm::mat4(1.0f), scale, rotation_axis); direction_matrix = glm::translate(glm::mat4(1.0f), axis_position); + animation_matrix = glm::rotate(direction_matrix, -scale, rotation_axis); + animation_matrix = animation_matrix * direction_matrix; @@ -279,11 +280,16 @@ animation_transform ace::simulation::animation::animate(const float phase, const //translation case 4: { scale = (scale / (max_value - min_value)) * (offset1 - offset0); - 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 - )); + glm::vec3 direction( + this->lod_info[lod_id]->axis_direction.x(), + this->lod_info[lod_id]->axis_direction.y(), + this->lod_info[lod_id]->axis_direction.z() + ); + direction = direction * scale; + direction_matrix = glm::translate(glm::mat4(1.0f), axis_position); + animation_matrix = glm::translate(glm::mat4(1.0f), direction); + animation_matrix = animation_matrix * direction_matrix; + break; } //translationX @@ -318,6 +324,7 @@ animation_transform ace::simulation::animation::animate(const float phase, const } case 8: { // fuck direct for now + break; } //hide case 9: { @@ -342,11 +349,15 @@ float ace::simulation::animation::get_scale(float phase) switch (source_address) { case 1: - scale = fmod(phase - min_value, max_value - min_value) + min_value; + scale = fmod(phase - min_value, (max_value - min_value) * 2) + min_value; + // when over limit, mirror + if (phase > max_value) phase = max_value - (phase - max_value); + scale = std::min(std::max(scale, min_phase), max_phase); + break; case 2: - scale = fmod(phase - min_value, (max_value - min_value) * 2) + min_value; + scale = fmod(phase - min_value, (max_value - min_value)) + min_value; if (scale > max_value) scale = max_value - (scale - max_value); scale = std::min(std::max(scale, min_phase), max_phase); break; diff --git a/extensions/tests/AT_01.txt b/extensions/tests/AT_01.txt new file mode 100644 index 0000000000..27bdedcf03 --- /dev/null +++ b/extensions/tests/AT_01.txt @@ -0,0 +1,5 @@ +#c:\arma\arma3\addons\static_f_gamma.pbo C:\dev\ace3\extensions\tests\AT_01.txt +init: +debug_render: +register_vehicle:\A3\Static_F_gamma\AT_01\AT_01.p3d,0,4050.18;3802.55;5.075 +fetch_result:1 \ No newline at end of file diff --git a/extensions/tests/longrod_dxtk_test.txt.backup b/extensions/tests/longrod_dxtk_test.txt.backup index ab2eeb6a0e..f924e48327 100644 --- a/extensions/tests/longrod_dxtk_test.txt.backup +++ b/extensions/tests/longrod_dxtk_test.txt.backup @@ -2,5 +2,5 @@ init: debug_render: register_vehicle:\A3\Structures_F\Ind\Cargo\Cargo40_blue_F.p3d,0,4050.18;3802.55;5.075 -set_animation_state:0,Door_1_rot,0,Door_Locked_1_rot,0,Door_2_rot,0,Door_Locked_2_rot,0, +set_animation_state:0,Door_1_rot,1,Door_Locked_1_rot,0,Door_2_rot,0,Door_Locked_2_rot,0, fetch_result:1 \ No newline at end of file diff --git a/extensions/tests/test_model/config.cpp b/extensions/tests/test_model/config.cpp deleted file mode 100644 index 2a7deaa41e..0000000000 --- a/extensions/tests/test_model/config.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//config.cpp - -class CfgPatches -{ - class nou_sys_snow - { - units[] = {}; - weapons[] = {}; - requiredVersion = 0.1; - requiredAddons[] = {"A3_Data_F"}; - }; -}; - -class CfgVehicles { - class House; - class nou_test_model: House - { - author = "Nou"; - _generalMacro = "nou_snow_2x2"; - scope = 2; - model = "test_model\test.p3d"; - vehicleClass = "Structures"; - cost = 50000; - replaceDamagedLimit = 0.99999; - class AnimationSources { - class box1 - { - source = "user"; - animPeriod = 0.0001; - initPhase = 0; - minValue = 0; - maxValue = 3; - }; - class box2 - { - source = "user"; - animPeriod = 0.0001; - initPhase = 0; - minValue = -1; - maxValue = 1; - }; - class box3_translate - { - source = "user"; - animPeriod = 0.0001; - initPhase = 0; - minValue = -10; - maxValue = 10; - }; - class box3_rotate - { - source = "user"; - animPeriod = 0.0001; - initPhase = 0; - minValue = 0; - maxValue = 1; - }; - }; - }; - -}; \ No newline at end of file diff --git a/extensions/tests/test_model/model.cfg b/extensions/tests/test_model/model.cfg deleted file mode 100644 index 558475d736..0000000000 --- a/extensions/tests/test_model/model.cfg +++ /dev/null @@ -1,113 +0,0 @@ -//model.cfg - -class CfgSkeletons -{ - class Default - { - isDiscrete = 1; - skeletonInherit = ""; - skeletonBones[] = {}; - }; - - class test_skeleton : Default { - skeletonBones[] = - { - "box1","", - "box2","box1", - "box3","box2" - }; - pivotsModel = ""; - }; -}; - -class CfgModels -{ - class Default - { - sectionsInherit = ""; - sections[] = {}; - }; - - class test : Default { - sectionsInherit = ""; - sections[] = - { - }; - skeletonName = "test_skeleton"; - - class Animations - { - class box1 - { - type = "rotationY"; - axis = "box2_translate_axis"; - source = "box1"; - selection = "box1"; - animPeriod = 0.0001; - minValue = 0; - maxValue = 3; - offset0 = 0; - offset1 = 1; - angle0 = 0; - angle1 = "rad 360"; - sourceAddress = "loop"; - }; - - class box2 { - type = "translationZ"; - source = "box2"; - selection = "box2"; - animPeriod = 0.0001; - minValue = -1; - maxValue = 1; - sourceAddress = "loop"; - }; - class box3_rotate - { - type = "direct"; - source = "box3_rotate"; - selection = "box3"; - animPeriod = 0.0001; - axisPos[] = {1,2,3}; - axisDir[] = {4,5,6}; - angle = "401.070457"; - axisOffset = 8; - sourceAddress = "loop"; - minValue = 0; - maxValue = 10; - }; - class box3_translate - { - type = "translation"; - source = "box3_translate"; - selection = "box3"; - axis = "box2_translate_axis"; - offset0 = 1; - offset1 = -1; - animPeriod = 0.0001; - minValue = -10; - maxValue = 10; - sourceAddress = "clamp"; - }; - - /* - class box3_rotate - { - type = "direct"; - source = "box3_rotate"; - selection = "box3"; - animPeriod = 0.0001; - axisPos[] = {0,0,0}; - axisDir[] = {0,1,0}; - angle = "1080"; - axisOffset = 1; - sourceAddress = "loop"; - minValue = 0; - maxValue = 10; - }; - */ - - }; - }; - -}; \ No newline at end of file diff --git a/extensions/tests/test_model/test.p3d b/extensions/tests/test_model/test.p3d deleted file mode 100644 index a07bd8a128..0000000000 Binary files a/extensions/tests/test_model/test.p3d and /dev/null differ