From e8fc6dd3d2e6503fa59e4a39200a76a247ea059c Mon Sep 17 00:00:00 2001 From: jaynus Date: Fri, 15 May 2015 18:48:53 -0700 Subject: [PATCH] Build out of penetration methods, debug export, and hit camera. --- addons/penetration/CfgAmmo.hpp | 9 +++-- addons/vehicledamage/XEH_preInit.sqf | 29 ++-------------- addons/vehicledamage/functions/fnc_doHit.sqf | 34 +++++++++++++------ .../functions/fnc_exportLogClipboard.sqf | 19 +++++++++++ .../functions/fnc_exportLogFile.sqf | 3 ++ extensions/common/simulation/object.cpp | 26 +++++++------- extensions/tests/REAL_AT_01.txt | 6 ++++ extensions/tests/anim_test/$PBOPREFIX$ | 1 + extensions/tests/anim_test/$PBOPREFIX$.txt | 6 ---- extensions/tests/longrod_dxtk_test.txt | 16 ++------- extensions/vd/base_vehicle.cpp | 2 +- extensions/vd/controller.cpp | 2 +- extensions/vd/game.hpp | 30 ++++++++++------ extensions/vd/penetration/basic.cpp | 19 +++++++++++ extensions/vd/penetration/basic.hpp | 14 ++++++++ extensions/vd/penetration/longrod.cpp | 30 ++++++++-------- 16 files changed, 146 insertions(+), 100 deletions(-) create mode 100644 addons/vehicledamage/functions/fnc_exportLogClipboard.sqf create mode 100644 addons/vehicledamage/functions/fnc_exportLogFile.sqf create mode 100644 extensions/tests/REAL_AT_01.txt create mode 100644 extensions/tests/anim_test/$PBOPREFIX$ delete mode 100644 extensions/tests/anim_test/$PBOPREFIX$.txt create mode 100644 extensions/vd/penetration/basic.cpp create mode 100644 extensions/vd/penetration/basic.hpp diff --git a/addons/penetration/CfgAmmo.hpp b/addons/penetration/CfgAmmo.hpp index 81015323a8..3224672a2e 100644 --- a/addons/penetration/CfgAmmo.hpp +++ b/addons/penetration/CfgAmmo.hpp @@ -6,7 +6,7 @@ class CfgAmmo { class ShellBase: ShellCore { }; - class Sh_120mm_APFSDS: ShellBase { + class Sh_120mm_APFSDS : ShellBase { /* enum class PROJECTILE_TYPE { CYLINDER = 1, // This also uses long rod calcs, but for a cylinder default. ignores frustrum lengths @@ -28,11 +28,14 @@ class CfgAmmo { GVAR(mass) = 4600; // grams, used if defined for penetrator, otherwise falls back on bulletMass ACE_materialType = 2; // 0=tungsten,1=DU,2=hard steel alloy + GVAR(materialType) = 2; + ACE_materialDensity = 19100; + GVAR(materialDensity) = 19100; + // Below densities are only used to override materialType, // OPTIONALS - ACE_materialDensity = 19100; - GVAR(density) = 19100; // kg/m3 used if defined for penetrator, otherwise falls back on ACE_materialDensity + // This is ony used if defined, otherwise it is assumed the round is a cylinder GVAR(frustumLength) = 0.05; // meter GVAR(frustumDiameter) = 0.01; // meter diff --git a/addons/vehicledamage/XEH_preInit.sqf b/addons/vehicledamage/XEH_preInit.sqf index fe50e1bcaf..16419542aa 100644 --- a/addons/vehicledamage/XEH_preInit.sqf +++ b/addons/vehicledamage/XEH_preInit.sqf @@ -14,6 +14,8 @@ GVAR(ready) = false; #ifdef DEBUG_LOG_EXTENSION GVAR(debug_log) = []; +PREP(exportLogClipboard); +PREP(exportLogFile); #endif #ifdef DEBUG_EXTENSION_DYNLOAD // This value is used for debug loading of the extension with dynload @@ -45,32 +47,7 @@ FUNC(_textVector) = { }; #ifdef DEBUG_LOG_EXTENSION -FUNC(clipboardExport) = { - private["_chunks"]; - _chunks = []; - - _chunks = [_this select 0, ";"] call CBA_fnc_split; - - { - private["_chunk"]; - _chunk = _x + ";"; - "ace_clipboard" callExtension format["%1", _chunk]; - } forEach _chunks; - - "ace_clipboard" callExtension "--COMPLETE--"; -}; -FUNC(exportLog) = { - private["_chunks"]; - _chunks = [str(_this select 0), ","] call CBA_fnc_split; - - { - private["_chunk"]; - _chunk = _x + ";"; - "ace_clipboard" callExtension format["%1", _chunk]; - } forEach _chunks; - - "ace_clipboard" callExtension "--COMPLETE--"; -}; + #endif diff --git a/addons/vehicledamage/functions/fnc_doHit.sqf b/addons/vehicledamage/functions/fnc_doHit.sqf index 704aa3de7e..968feb2aa8 100644 --- a/addons/vehicledamage/functions/fnc_doHit.sqf +++ b/addons/vehicledamage/functions/fnc_doHit.sqf @@ -13,25 +13,31 @@ _impactSurfaceType = (_this select 0) select 9; _isDirectHit = (_this select 0) select 10; TRACE_2("",_impactSurfaceType,_isDirectHit); -_projectileType = (getNumber (__PROJECTILE_CLASS >> "ACE_projectileType") ); +_projectileType = getNumber (__PROJECTILE_CLASS >> "ACE_projectileType"); -_projectileDensity = getNumber (__PROJECTILE_CLASS >> "ACE_bulletDensity"); -_projectileLength = (getNumber (__PROJECTILE_CLASS >> "ACE_bulletLength") ) * 1000; // fucking inches dafuq!?!?!? -_projectileDiameter = (getNumber (__PROJECTILE_CLASS >> "ACE_caliber") ) * 1000; // fucking inches dafuq!?!?!? +_projectileDensity = getNumber (__PROJECTILE_CLASS >> "ace_penetration_materialDensity"); +_projectileMaterialType = getNumber (__PROJECTILE_CLASS >> "ace_penetration_materialType"); + +_projectileLength = (getNumber (__PROJECTILE_CLASS >> "ace_penetration_length")) * 1000; // fucking inches dafuq!?!?!? +_projectileDiameter = (getNumber (__PROJECTILE_CLASS >> "ace_penetration_diameter") ) * 1000; // fucking inches dafuq!?!?!? _projectileCaliber = getNumber (__PROJECTILE_CLASS >> "caliber"); -_frastumLength = (getNumber (__PROJECTILE_CLASS >> "ACE_frastumLength") ) * 1000; -_frastumDiameter = (getNumber (__PROJECTILE_CLASS >> "ACE_frastumDiameter") ) * 1000; +_frastumLength = (getNumber (__PROJECTILE_CLASS >> "ace_penetration_frustumLength") ) * 1000; +_frastumDiameter = (getNumber (__PROJECTILE_CLASS >> "ace_penetration_frustumDiameter") ) * 1000; _model = getText (__VEHICLE_CLASS >> "model"); -TRACE_4("Measurements", _projectileDensity,_projectileLength,_projectileDiameter,_projectileCaliber); +TRACE_5("Measurements", _projectileDensity,_projectileLength,_projectileDiameter,_projectileCaliber, _projectileMaterialType); // If there was no ACE length defined, default to caliber if(_projectileLength == 0) then { _projectileLength = ACE_BASE_BULLET_LENGTH * _projectileCaliber; // Length in mm, 1 caliber = 55.6 = ~13mm length round }; +// @TODO: WHERE DO WE LOAD THESE FROM!?!?!?! +_impactSurfaceDensity = 7840; +_impactSurfaceMaterialType = 2; + _vehicleId = _vehicle getVariable[QGVAR(id), -1]; @@ -44,28 +50,36 @@ _projectilePosition = _vehicle worldToModelVisual (position _projectile); _relProjectilePos = (position _projectile) vectorAdd (velocity _projectile); _relProjectileVelocity = _projectilePosition vectorFromTo (_vehicle modelToWorldVisual _relProjectilePos); +_relProjectileVelocity = _relProjectileVelocity vectorMultiply (vectorMagnitude (velocity _projectile)); _relImpactVelPos = _impactPosition vectorAdd _impactVelocity; _relImpactVelocity = _relImpactPosition vectorFromTo (_vehicle modelToWorldVisual _relImpactVelPos); +_relImpactVelocity = _relImpactVelocity vectorMultiply (vectorMagnitude _impactVelocity); _relSurfDirectionPos = _impactPosition vectorAdd _surfaceDirection; _relSurfaceDirection = _relImpactPosition vectorFromTo (_vehicle modelToWorldVisual _relSurfDirectionPos); -_command = format["hit:%1,%2,%3,%4,%5,%6,%7,%8,%9,%10,%11,%12,%13,%14,%15,%16,%17,%18", +TRACE_2("", (vectorMagnitude _relImpactVelocity), (vectorMagnitude _relProjectileVelocity)); +TRACE_2("", (vectorMagnitude _impactVelocity), (vectorMagnitude (velocity _projectile))); + +_command = format["hit:%1,%2,%3,%4,%5,%6,%7,%8,%9,%10,%11,%12,%13,%14,%15,%16,%17,%18,%19,%20,%21,%22", _vehicleId, // vehicle id registered // _model, _selection, _model, "BALLS", VECTOR_TEXT(vectorDir _vehicle), VECTOR_TEXT(vectorUp _vehicle), _projectileType, //projectile type id - (_ammo select 4), _projectileLength, _projectileDiameter, _projectileDensity, + (_ammo select 4), _projectileLength, _projectileDiameter, _projectileDensity, _projectileMaterialType, _frastumLength, _frastumDiameter, VECTOR_TEXT(_relProjectileVelocity), VECTOR_TEXT(_projectilePosition), VECTOR_TEXT(vectorDir _projectile), VECTOR_TEXT(_relSurfaceDirection), VECTOR_TEXT(_relImpactPosition), - VECTOR_TEXT(_relImpactVelocity) + VECTOR_TEXT(_relImpactVelocity), + _impactSurfaceType, + _impactSurfaceDensity, + _impactSurfaceMaterialType ]; TRACE_1("", _command); _result = _command call FUNC(callExtension); diff --git a/addons/vehicledamage/functions/fnc_exportLogClipboard.sqf b/addons/vehicledamage/functions/fnc_exportLogClipboard.sqf new file mode 100644 index 0000000000..f50e3c72a9 --- /dev/null +++ b/addons/vehicledamage/functions/fnc_exportLogClipboard.sqf @@ -0,0 +1,19 @@ +#include "script_component.hpp" +private["_chunks", "_logString"]; +_chunks = []; + +if((count _this) < 1) then { + _logString = str GVAR(debug_log); +} else { + _logString = _this select 0; +}; + +_chunks = [_logString, ";"] call CBA_fnc_split; + +{ + private["_chunk"]; + _chunk = _x + ";"; + "ace_clipboard" callExtension format["%1", _chunk]; +} forEach _chunks; + +"ace_clipboard" callExtension "--COMPLETE--"; diff --git a/addons/vehicledamage/functions/fnc_exportLogFile.sqf b/addons/vehicledamage/functions/fnc_exportLogFile.sqf new file mode 100644 index 0000000000..a4ba65a8c9 --- /dev/null +++ b/addons/vehicledamage/functions/fnc_exportLogFile.sqf @@ -0,0 +1,3 @@ +#include "script_component.hpp" +private["_chunks"]; + diff --git a/extensions/common/simulation/object.cpp b/extensions/common/simulation/object.cpp index b3c4c935ef..73b4d2dd49 100644 --- a/extensions/common/simulation/object.cpp +++ b/extensions/common/simulation/object.cpp @@ -223,9 +223,9 @@ animation_transform ace::simulation::animation::animate(const float phase, const //rotation case 0: { scale = (scale / (max_value - min_value)) * (angle1 - angle0); - animation_matrix = glm::translate(glm::mat4(1.0f), -axis_position); + animation_matrix = glm::translate(glm::mat4(1.0f), axis_position); animation_matrix *= glm::rotate(glm::mat4(1.0f), -scale, axis_direction); - animation_matrix *= glm::translate(glm::mat4(1.0f), axis_position); + animation_matrix *= glm::translate(glm::mat4(1.0f), -axis_position); break; } //rotationX @@ -234,27 +234,27 @@ animation_transform ace::simulation::animation::animate(const float phase, const glm::vec3 rotation_axis = glm::vec3(1.0f, 0.0f, 0.0f); - animation_matrix = glm::translate(glm::mat4(1.0f), -axis_position); + animation_matrix = glm::translate(glm::mat4(1.0f), axis_position); animation_matrix *= glm::rotate(glm::mat4(1.0f), -scale, rotation_axis); - animation_matrix *= glm::translate(glm::mat4(1.0f),axis_position); + animation_matrix *= glm::translate(glm::mat4(1.0f),-axis_position); break; } //rotationY 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::translate(glm::mat4(1.0f), -axis_position); - animation_matrix *= glm::rotate(glm::mat4(1.0f), -scale, rotation_axis); - animation_matrix *= glm::translate(glm::mat4(1.0f), axis_position); + animation_matrix = glm::translate(glm::mat4(1.0f), axis_position); + animation_matrix *= glm::rotate(glm::mat4(1.0f), scale, rotation_axis); // should this be positive? + animation_matrix *= glm::translate(glm::mat4(1.0f), -axis_position); break; } //rotationZ 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::translate(glm::mat4(1.0f), -axis_position); + animation_matrix = glm::translate(glm::mat4(1.0f), axis_position); animation_matrix *= glm::rotate(glm::mat4(1.0f), -scale, rotation_axis); - animation_matrix *= glm::translate(glm::mat4(1.0f), axis_position); + animation_matrix *= glm::translate(glm::mat4(1.0f), -axis_position); break; } //translation @@ -320,16 +320,16 @@ float ace::simulation::animation::get_scale(float phase) switch (source_address) { - case 1: - scale = fmod(phase - min_value, (max_value - min_value) * 2) + min_value; + case 1: // LOOP + scale = fmod(phase - min_value, (max_value - min_value)) + 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)) + min_value; + case 2: // MIRROR + scale = fmod(phase - min_value, (max_value - min_value) * 2) + 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/REAL_AT_01.txt b/extensions/tests/REAL_AT_01.txt new file mode 100644 index 0000000000..ab3e670158 --- /dev/null +++ b/extensions/tests/REAL_AT_01.txt @@ -0,0 +1,6 @@ +#c:\arma\arma3\addons\static_f_gamma.pbo C:\dev\ace3\extensions\tests\REAL_AT_01.txt +init: +debug_render: +register_vehicle:\A3\Static_F_gamma\AT_01\AT_01.p3d,0,4050.18;3802.55;5.075 +#set_animation_state:0, MainTurret, 0, MainGun, 0, MainTurret_destructX, 0, MainTurret_destructY, 0, MainTurret_destructZ, 0, MainGun_destructX, 0, MainGun_destructY, 0, MainGun_destructZ, 0, magazine_destruct, 0, ammo_belt_destruct, 0, bolt_destruct, 0, charging_handle_destruct, 0, damagehideVez_destruct, 0, damagehideHlaven_destruct, 0, damagehideRecoil_destruct, 0, Turret_shake, 0, Turret_shake_aside, 0, Magazine_hide, 0, Ammo_belt_hide, 0, muzzleFlash, 0, AddAutonomous_unhide, 0, bullet001_reload_hide, 0, bullet002_reload_hide, 0, bullet003_reload_hide, 0, bullet004_reload_hide, 0, bullet005_reload_hide, 0, bullet006_reload_hide, 0, bullet007_reload_hide, 0, bullet008_reload_hide, 0 +set_animation_state:0, MainTurret, -0, MainGun, 1, MainTurret_destructX, 0, MainTurret_destructY, 0, MainTurret_destructZ, 0, MainGun_destructX, 0, MainGun_destructY, 0, MainGun_destructZ, 0, magazine_destruct, 0, ammo_belt_destruct, 0, bolt_destruct, 0, charging_handle_destruct, 0, damagehideVez_destruct, 0, damagehideHlaven_destruct, 0, damagehideRecoil_destruct, 0, Turret_shake, 0, Turret_shake_aside, 0, Magazine_hide, 0, Ammo_belt_hide, 0, muzzleFlash, 0, AddAutonomous_unhide, 0, bullet001_reload_hide, 0, bullet002_reload_hide, 0, bullet003_reload_hide, 0, bullet004_reload_hide, 0, bullet005_reload_hide, 0, bullet006_reload_hide, 0, bullet007_reload_hide, 0, bullet008_reload_hide, 0 diff --git a/extensions/tests/anim_test/$PBOPREFIX$ b/extensions/tests/anim_test/$PBOPREFIX$ new file mode 100644 index 0000000000..775648801b --- /dev/null +++ b/extensions/tests/anim_test/$PBOPREFIX$ @@ -0,0 +1 @@ +x\nou\addons\anim_test \ No newline at end of file diff --git a/extensions/tests/anim_test/$PBOPREFIX$.txt b/extensions/tests/anim_test/$PBOPREFIX$.txt deleted file mode 100644 index 93757a4227..0000000000 --- a/extensions/tests/anim_test/$PBOPREFIX$.txt +++ /dev/null @@ -1,6 +0,0 @@ -///////
/////// -prefix=z\ace\test -Mikero=DePbo.dll -Pbo Type is: Arma Addon -Sha: 'B57F52A263D29E93AC869A50E7058065B93F97D5' -//////
////// diff --git a/extensions/tests/longrod_dxtk_test.txt b/extensions/tests/longrod_dxtk_test.txt index 1a9aca0311..e95d23fffc 100644 --- a/extensions/tests/longrod_dxtk_test.txt +++ b/extensions/tests/longrod_dxtk_test.txt @@ -2,17 +2,7 @@ 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: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 +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 #set_vehicle_state:1,0;-20;0,0;0;0,0;0;0 -hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984808;0.173648;-0.000321539, 0.000336425;-5.62874e-005;1, 0, B_65x39_Caseless, 32893, 6706, 11300, 0, 0, 0.000173648;-0.000984808;-1.13852e-007, 1.90674;-2.97705;-1.01589, 9.3088e-005;0.999998;0.00182291, 0.997565;0.0697389;0.00040539, 2.1709;-3.00732;3.9504, 0.996985;0.0775994;0.000355178 -hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984808;0.173648;-0.000321539, 0.000336425;-5.62874e-005;1, 0, B_65x39_Caseless, 32893, 6706, 11300, 0, 0, 0.000173648;-0.000984808;-1.13852e-007, 1.90674;-2.97705;-1.01589, 9.3088e-005;0.999998;0.00182291, 0.997565;0.0697387;0.000405358, 1.90527;-2.97852;3.94798, 0.997251;0.0740926;0.000152842 -hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984803;0.173649;-0.00285841, 0.00294448;-0.000238045;0.999996, 0, B_65x39_Caseless, 32893, 6706, 11300, 0, 0, 7.61759e-005;-0.000997094;-4.61654e-007, 1.77954;-2.83154;-0.219069, -0.0380967;0.999228;0.00961505, 0.997566;0.069721;-0.00105282, 1.7749;-2.8457;4.74479, 0.996762;0.0804012;-0.000602539 -hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984803;0.173649;-0.00284932, 0.00294109;-0.000271166;0.999995, 0, B_65x39_Caseless, 32893, 6706, 11300, 0, 0, 0.000173647;-0.000984808;-7.73569e-007, 1.82178;-1.9292;-0.268372, -0.0288651;0.999542;0.00905338, 0.997581;0.0695041;-0.00106295, 1.81689;-1.94336;4.69548, 0.996832;0.079526;-0.000653841 -hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984803;0.173649;-0.00284391, 0.00293735;-0.000281132;0.999996, 0, B_65x39_Caseless, 32893, 6706, 11300, 0, 0, 0.000173647;-0.000984808;-7.85849e-007, 1.84595;-2.57471;-2.50434, -0.0354257;0.999277;-0.0138109, 0.997571;0.0696509;-0.00106625, 1.84106;-2.58887;2.45951, 0.99678;0.0801495;-0.00236906 -hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984803;0.173649;-0.00284275, 0.00293741;-0.000288139;0.999996, 0, B_65x39_Caseless, 32893, 6706, 11300, 0, 0, 0.000173647;-0.000984808;-7.92519e-007, 1.90674;-2.85693;-0.816221, -0.0381079;0.999267;0.00357182, 0.997566;0.069714;-0.00106831, 2.16724;-2.90381;4.15556, 0.996761;0.08041;-0.00106769 -hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984803;0.173649;-0.00284275, 0.00293741;-0.000288139;0.999996, 0, B_65x39_Caseless, 32893, 6706, 11300, 0, 0, 0.000173647;-0.000984808;-7.92519e-007, 1.90674;-2.85693;-0.816221, -0.0381079;0.999267;0.00357182, 0.997566;0.0697129;-0.00106831, 1.90186;-2.87109;4.14763, 0.997275;0.0737539;-0.00188146 -hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984803;0.173649;-0.002843, 0.00293819;-0.000291138;0.999996, 0, B_65x39_Caseless, 32893, 6706, 11300, 0, 0, 0.000173647;-0.000984808;-7.95372e-007, 1.67578;-2.15332;-2.30106, -0.0313568;0.99944;-0.0117081, 0.997577;0.0695593;-0.00107051, 1.6709;-2.16797;2.6628, 0.996812;0.0797612;-0.00221558 -hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984803;0.173649;-0.00284299, 0.00293839;-0.0002923;0.999996, 2, Sh_120mm_APFSDS_Tracer_Yellow, 65, 27, 0, 0, 0, -94.1198;1574.74;-13.4215, -3.81567;-2.31543;-0.841839, -0.0666772;0.997769;-0.00347184, 0.997565;0.0697371;-0.00107085, 2.16748;-3.00537;4.17418, 0.995139;0.0984623;-0.00199962 -hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984803;0.173649;-0.00284299, 0.00293839;-0.0002923;0.999996, 2, Sh_120mm_APFSDS_Tracer_Yellow, 65, 27, 0, 0, 0, -94.1198;1574.74;-13.4215, -3.81567;-2.31543;-0.841839, -0.0666772;0.997769;-0.00347184, 0.997565;0.069737;-0.00107086, 1.90186;-2.97705;4.17292, 0.995158;0.0982686;-0.00206677 -hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984803;0.173649;-0.00284299, 0.00293839;-0.0002923;0.999996, 2, Sh_120mm_APFSDS_Tracer_Yellow, 65, 27, 0, 0, 0, -94.1198;1574.74;-13.4215, -3.81567;-2.31543;-0.841839, -0.0666772;0.997769;-0.00347184, 0.997565;0.0697312;-0.00107094, -1.75977;-2.56689;4.15401, 0.995311;0.0967058;-0.00210695 -hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984803;0.173649;-0.00284299, 0.00293839;-0.0002923;0.999996, 2, Sh_120mm_APFSDS_Tracer_Yellow, 65, 27, 0, 0, 0, -94.1198;1574.74;-13.4215, -3.81567;-2.31543;-0.841839, -0.0666772;0.997769;-0.00347184, 0.997565;0.0697306;-0.00107095, -2.08813;-2.5293;4.15127, 0.995439;0.0953656;-0.00261482 \ No newline at end of file +hit:1,\A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d,BALLS,0.984803;0.173649;-0.00285841,0.0029445;-0.000238176;0.999996,2,Sh_120mm_APFSDS_Tracer_Yellow,65,27,19100,2,50,10,0.995217;0.0976774;-0.00161879,-2.42871;-2.42871;-0.794659,-0.0660895;0.997809;-0.00319795,0.997566;0.0697239;-0.00105289,2.16772;-2.94727;4.19943,0.99515;0.0983533;-0.00194169,A3\data_f\Penetration\armour_plate_7mm.bisurf,7840,2 +hit:1,\A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d,BALLS,0.984803;0.173649;-0.00285841,0.0029445;-0.000238176;0.999996,2,Sh_120mm_APFSDS_Tracer_Yellow,65,27,19100,2,50,10,0.995217;0.0976774;-0.00161879,-2.42871;-2.42871;-0.794659,-0.0660895;0.997809;-0.00319795,0.997566;0.0697195;-0.00105303,-2.08813;-2.48047;4.18355,0.995188;0.0979676;-0.00189929,A3\data_f\Penetration\armour_plate_7mm.bisurf,7840,2 \ No newline at end of file diff --git a/extensions/vd/base_vehicle.cpp b/extensions/vd/base_vehicle.cpp index ff145e0486..22ca5b6d27 100644 --- a/extensions/vd/base_vehicle.cpp +++ b/extensions/vd/base_vehicle.cpp @@ -20,7 +20,7 @@ namespace ace { } } if (fire_lod == -1) // @TODO: fallback on geo LOD - fire_lod = 0; + fire_lod = 11; //fire_lod = 0; assert(fire_lod != -1); diff --git a/extensions/vd/controller.cpp b/extensions/vd/controller.cpp index 76b8c34140..6cca39502d 100644 --- a/extensions/vd/controller.cpp +++ b/extensions/vd/controller.cpp @@ -196,7 +196,7 @@ namespace ace { } bool controller::handle_hit(const arguments &_args, std::string & result) { - if (_args.size() < 18) return false; + if (_args.size() < 22) return false; auto _vehicle = vehicles.find(_args[0]); if (_vehicle == vehicles.end()) diff --git a/extensions/vd/game.hpp b/extensions/vd/game.hpp index 941284c79a..50f0d18efb 100644 --- a/extensions/vd/game.hpp +++ b/extensions/vd/game.hpp @@ -64,15 +64,15 @@ namespace ace { class projectile { public: - projectile(uint32_t projtypeid_, const std::string & classname_, float length_, float diameter_, float density_, float frustum_length_, float frustum_diameter_, + projectile(uint32_t projtypeid_, const std::string & classname_, float length_, float diameter_, float material_density_, int material_type_, float frustum_length_, float frustum_diameter_, ace::vector3 vel, ace::vector3 pos, ace::vector3 dir) : - type(PROJECTILE_TYPE(projtypeid_)), classname(classname_), length(length_), diameter(diameter_), density(density_), frustum_length(frustum_length_), frustum_diameter(frustum_diameter_), + type(PROJECTILE_TYPE(projtypeid_)), classname(classname_), length(length_), diameter(diameter_), material_density(material_density_), material_type(material_type_), frustum_length(frustum_length_), frustum_diameter(frustum_diameter_), velocity(vel), position(pos), direction(dir) {} projectile & operator= (const projectile& other) { - type = other.type; classname = other.classname; length = other.length; diameter = other.diameter, density = other.density; - frustum_length = other.frustum_length; frustum_diameter = other.frustum_diameter; + type = other.type; classname = other.classname; length = other.length; diameter = other.diameter, material_density = other.material_density; material_type = other.material_type; + frustum_length = other.frustum_length; frustum_diameter = other.frustum_diameter; velocity = other.velocity; position = other.position; direction = other.direction; return *this; } @@ -83,7 +83,9 @@ namespace ace { float length; float diameter; - float density; + + float material_density; + int material_type; float frustum_diameter; float frustum_length; @@ -102,20 +104,22 @@ namespace ace { const std::string & classname, const std::string & selection, ace::vector3 dir, ace::vector3 up, projectile proj, - ace::vector3 orthosurface, ace::vector3 impactpos, ace::vector3 impactvel) + ace::vector3 orthosurface, ace::vector3 impactpos, ace::vector3 impactvel, std::string bisurf_, float material_density_, int material_type_) : id(id), objectid(objectid), classname(classname), selection(selection), vehicle_direction(dir), vehicle_up(up), projectile(proj), - surface(orthosurface), impactposition(impactpos), impactvelocity(impactvel) + surface(orthosurface), impactposition(impactpos), impactvelocity(impactvel), bisurf(bisurf_), + material_density(material_density_), material_type(material_type_) {} - +#define PROJ_ARG_COUNT 16 static std::shared_ptr create(const arguments & args) { return std::make_shared(-1, args.as_uint32(0), args.as_string(1), args.as_string(2), args[3], args[4], - ace::vehicledamage::projectile(args.as_uint32(5), args.as_string(6), args.as_float(7), args.as_float(8), args[9], args[10], args[11], - args.as_vector(12), args[13], args.as_vector(14)), - args.as_vector(15), args.as_vector(16), args.as_vector(17)); + ace::vehicledamage::projectile(args[5], args[6], args[7], args[8], args[9], args[10], args[11], args[12], + args[13], args[14], args[15]), + args.as_vector(PROJ_ARG_COUNT), args.as_vector(PROJ_ARG_COUNT+1), args.as_vector(PROJ_ARG_COUNT+2), args[PROJ_ARG_COUNT+3], + args[PROJ_ARG_COUNT + 4], args[PROJ_ARG_COUNT + 5]); } uint32_t id; @@ -130,9 +134,13 @@ namespace ace { ace::vector3 vehicle_up; ace::vector3 surface; + std::string bisurf; ace::vector3 impactposition; ace::vector3 impactvelocity; + + int material_type; + float material_density; }; typedef std::shared_ptr gamehit_p; } diff --git a/extensions/vd/penetration/basic.cpp b/extensions/vd/penetration/basic.cpp new file mode 100644 index 0000000000..c16988071c --- /dev/null +++ b/extensions/vd/penetration/basic.cpp @@ -0,0 +1,19 @@ +#include "basic.hpp" + +#include +#include + +namespace ace { + namespace vehicledamage { + namespace penetration { + bool basic::process() { + + + + + + return true; + } + } + } +} \ No newline at end of file diff --git a/extensions/vd/penetration/basic.hpp b/extensions/vd/penetration/basic.hpp new file mode 100644 index 0000000000..1ce1ce2be3 --- /dev/null +++ b/extensions/vd/penetration/basic.hpp @@ -0,0 +1,14 @@ +#pragma once + +#include "penetration.hpp" + +namespace ace { + namespace vehicledamage { + namespace penetration { + class basic : public base_penetration_model { + public: + bool process() override; + }; + } + } +} \ No newline at end of file diff --git a/extensions/vd/penetration/longrod.cpp b/extensions/vd/penetration/longrod.cpp index 483ad09e6d..5694ce19bf 100644 --- a/extensions/vd/penetration/longrod.cpp +++ b/extensions/vd/penetration/longrod.cpp @@ -63,36 +63,34 @@ namespace ace { float m = -0.224; float Lw = _working_length(); - float impact_velocity = _hit->projectile.velocity.magnitude() / 1000; - ace::vector3 vel_norm = _hit->projectile.velocity.normalize(); + float impact_velocity = _hit->impactvelocity.magnitude(); + ace::vector3 vel_norm = _hit->impactvelocity.normalize(); ace::vector3 surface_norm = _hit->surface.normalize(); float impact_angle = surface_norm.dot(vel_norm); - uint32_t material_index = 2; - - float targetHardness = material_properties[material_index][0]; - float projectileHardness = material_properties[material_index][0]; - float target_density = material_properties[material_index][1]; + float targetHardness = material_properties[_hit->material_type][0]; + float projectileHardness = material_properties[_hit->projectile.material_type][0]; + float target_density = material_properties[_hit->material_type][1]; - float a = material_coefficients[material_index][0]; - float c0 = material_coefficients[material_index][1]; - float c1 = material_coefficients[material_index][2]; - float k = material_coefficients[material_index][3]; - float n = material_coefficients[material_index][4]; + float a = material_coefficients[_hit->projectile.material_type][0]; + float c0 = material_coefficients[_hit->projectile.material_type][1]; + float c1 = material_coefficients[_hit->projectile.material_type][2]; + float k = material_coefficients[_hit->projectile.material_type][3]; + float n = material_coefficients[_hit->projectile.material_type][4]; float s2 = 0; - if (material_index < 2) { - s2 = (c0 + c1 * targetHardness) * targetHardness / _hit->projectile.density; + if (_hit->projectile.material_type < 2) { + s2 = (c0 + c1 * targetHardness) * targetHardness / _hit->projectile.material_density; } else { - s2 = c0 * (std::pow(projectileHardness, k)) * (std::pow(targetHardness, n)) / _hit->projectile.density; + s2 = c0 * (std::pow(projectileHardness, k)) * (std::pow(targetHardness, n)) / _hit->projectile.material_density; }; float tanX = b0 + b1 * (Lw / _hit->projectile.diameter); float w = 1 / std::tanh(tanX); float x = std::pow(std::cos(impact_angle), m); - float y = sqrt(_hit->projectile.density / target_density); + float y = sqrt(_hit->projectile.material_density / target_density); float z = std::pow(std::exp(1), (-(s2) / std::pow(impact_velocity, 2))); float P = a * w * x * y * z;