mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Added radar scan PFH
This commit is contained in:
parent
615d2ed0cf
commit
a596bc91c7
@ -1,4 +1,5 @@
|
|||||||
PREP(changeCone);
|
PREP(changeCone);
|
||||||
PREP(registerAircraft);
|
PREP(registerAircraft);
|
||||||
PREP(scan);
|
PREP(scan);
|
||||||
|
PREP(scanPFH);
|
||||||
PREP(switchRadar);
|
PREP(switchRadar);
|
||||||
|
@ -21,7 +21,7 @@ private _scanVectorV = _scanVector select [1, 2]; //[y, z]
|
|||||||
private _detectedAircraft = [];
|
private _detectedAircraft = [];
|
||||||
|
|
||||||
{
|
{
|
||||||
if ((getPosATL _x) select 2 > 10) then {
|
if (_x != _aircraft && {(getPosATL _x) select 2 > 10}) then {
|
||||||
private _dirToTarget = (getPosASL _x) vectorDiff (getPosASL _aircraft);
|
private _dirToTarget = (getPosASL _x) vectorDiff (getPosASL _aircraft);
|
||||||
|
|
||||||
private _diffRadH = (_dirToTarget select [0, 2]) vectorDotProduct _scanVectorH;
|
private _diffRadH = (_dirToTarget select [0, 2]) vectorDotProduct _scanVectorH;
|
||||||
|
80
addons/radar/functions/fnc_scanPFH.sqf
Normal file
80
addons/radar/functions/fnc_scanPFH.sqf
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* Author: BaerMitUmlaut
|
||||||
|
* PFH emulating radar scanning.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: PFH arguments
|
||||||
|
* 1: PFH handle
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
params ["_args"];
|
||||||
|
_args params ["_vehicle", "_lastDir", "_lastTick", "_moveRight"];
|
||||||
|
|
||||||
|
private _angleH = _vehicle getVariable QGVAR(coneAngleH);
|
||||||
|
private _angleV = _vehicle getVariable QGVAR(coneAngleV);
|
||||||
|
_lastDir params ["_dirH", "_dirV"];
|
||||||
|
|
||||||
|
/*
|
||||||
|
The radar scanning area is a cone with a rectangular
|
||||||
|
base (imagine an infinite pyramid coming out of the
|
||||||
|
nose of the aircraft). The radar beam itself now tries
|
||||||
|
to cover the whole area of the pyramid by following an
|
||||||
|
S shaped path (very similar to the rays of a CRT
|
||||||
|
display).
|
||||||
|
|
||||||
|
This means that a smaller horizontal or vertical angle
|
||||||
|
of the scanning cone will result in the beam having to
|
||||||
|
travel less and the scan becoming faster. The downside
|
||||||
|
is of course that it covers a smaller area.
|
||||||
|
|
||||||
|
To simulate this we divide the base of the pyramid into
|
||||||
|
rectangular areas that the beam went through between
|
||||||
|
now and the last call of the PFH. If we have an L
|
||||||
|
shaped area, we simply complete it to a rectangle.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// First check if the cone was changed and we're outside of the cone
|
||||||
|
if (_dirH > (_angleH / 2)) then {
|
||||||
|
_dirH = _angleH / 2;
|
||||||
|
};
|
||||||
|
if (_dirV > (_angleV / 2)) then {
|
||||||
|
_dirV = _angleV / 2;
|
||||||
|
};
|
||||||
|
if (_dirH < (_angleH / -2)) then {
|
||||||
|
_dirH = _angleH / -2;
|
||||||
|
};
|
||||||
|
if (_dirV < (_angleV / -2)) then {
|
||||||
|
_dirV = _angleV / -2;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 24 movement steps per second (60 deg horizontal)
|
||||||
|
private _steps = 1 max round ((CBA_time - _lastTick) * 24);
|
||||||
|
private _newDirH = _dirH;
|
||||||
|
private _newDirV = _dirV;
|
||||||
|
|
||||||
|
while {_steps > 0} do {
|
||||||
|
while {_steps > 0 && {_newDirH < _angleH}} do {
|
||||||
|
// Beam has an angle of 2.5 deg
|
||||||
|
_newDirH = [_newDirH + 2.5, _newDirH - 2.5] select _moveRight;
|
||||||
|
_steps = _steps - 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
// If we still have steps to take, switch direction, go one line lower
|
||||||
|
if (_steps > 0) then {
|
||||||
|
_moveRight = !_moveRight;
|
||||||
|
_newDirV = _newDirV - 2.5;
|
||||||
|
|
||||||
|
// If bottom of cone is reached, scan and back to the top.
|
||||||
|
if (_newDirV < (_angleV / -2)) then {
|
||||||
|
// scan here
|
||||||
|
_newDirV = _angleV / 2;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// scan here
|
Loading…
Reference in New Issue
Block a user