mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Constraints work, added worldToScreenBounds to common.
This commit is contained in:
parent
721898d9fb
commit
0a88220fc2
@ -178,6 +178,9 @@ PREP(useItem);
|
||||
PREP(useMagazine);
|
||||
PREP(waitAndExecute);
|
||||
|
||||
// Model and drawing helpers
|
||||
PREP(worldToScreenBounds);
|
||||
|
||||
// config items
|
||||
PREP(getConfigType);
|
||||
PREP(getItemType);
|
||||
|
52
addons/common/functions/fnc_worldToScreenBounds.sqf
Normal file
52
addons/common/functions/fnc_worldToScreenBounds.sqf
Normal file
@ -0,0 +1,52 @@
|
||||
// (c) zGuba 2011
|
||||
// Function helper for framing objects on screen.
|
||||
// Input: [_object,_margins3D,_offset3D] (object, 3 * float array, 3 * float array)
|
||||
// Output: [_minX,_minY,_minY,_maxY] (4 * float)
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_minX","_minY","_maxX","_maxY"];
|
||||
|
||||
PARAMS_3(_object,_margins,_offsets);
|
||||
|
||||
_minX = 10;
|
||||
_minY = 10;
|
||||
_maxX = -10;
|
||||
_maxY = -10;
|
||||
|
||||
if (true) then {
|
||||
_bounds = boundingBox _object;
|
||||
|
||||
_boundsMin = _bounds select 0;
|
||||
_boundsMinX = (_boundsMin select 0) - (_margins select 0) + (_offsets select 0);
|
||||
_boundsMinY = (_boundsMin select 1) - (_margins select 1) + (_offsets select 1);
|
||||
_boundsMinZ = (_boundsMin select 2) - (_margins select 2) + (_offsets select 2);
|
||||
_boundsMax = _bounds select 1;
|
||||
_boundsMaxX = (_boundsMax select 0) + (_margins select 0) + (_offsets select 0);
|
||||
_boundsMaxY = (_boundsMax select 1) + (_margins select 1) + (_offsets select 1);
|
||||
_boundsMaxZ = (_boundsMax select 2) + (_margins select 2) + (_offsets select 2);
|
||||
|
||||
_boundsCorners = [
|
||||
[_boundsMinX,_boundsMinY,_boundsMinZ],
|
||||
[_boundsMinX,_boundsMinY,_boundsMaxZ],
|
||||
[_boundsMinX,_boundsMaxY,_boundsMinZ],
|
||||
[_boundsMinX,_boundsMaxY,_boundsMaxZ],
|
||||
[_boundsMaxX,_boundsMinY,_boundsMinZ],
|
||||
[_boundsMaxX,_boundsMinY,_boundsMaxZ],
|
||||
[_boundsMaxX,_boundsMaxY,_boundsMinZ],
|
||||
[_boundsMaxX,_boundsMaxY,_boundsMaxZ]
|
||||
];
|
||||
|
||||
|
||||
{
|
||||
_ppos = worldToScreen (_object modelToWorld _x);
|
||||
_pposX = _ppos select 0;
|
||||
_pposY = _ppos select 1;
|
||||
if (_pposX < _minX) then {_minX = _pposX};
|
||||
if (_pposX > _maxX) then {_maxX = _pposX};
|
||||
if (_pposY < _minY) then {_minY = _pposY};
|
||||
if (_pposY > _maxY) then {_maxY = _pposY};
|
||||
} forEach _boundsCorners;
|
||||
};
|
||||
|
||||
[_minX,_minY,_maxX,_maxY]
|
@ -84,7 +84,7 @@ class RscInGameUI {
|
||||
class ACE_TargetingGate : ACE_TargetingConstrains {
|
||||
idc = 699200;
|
||||
class Controls {
|
||||
class TargetingGateTL: TargetingConstrains {
|
||||
class TargetingGateTL: ACE_TargetingConstrains {
|
||||
x = "((SafezoneW -(3/4)*SafezoneH)/2) - SafezoneX";
|
||||
y = "0.15*SafezoneH - SafezoneY";
|
||||
idc = 699201;
|
||||
|
@ -1,8 +1,5 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
PREP(translateToWeaponSpace);
|
||||
PREP(translateToModelSpace);
|
||||
|
||||
PREP(lockKeyDown);
|
||||
PREP(lockKeyUp);
|
||||
|
||||
|
@ -83,9 +83,59 @@ if (isNull _newTarget) then {
|
||||
} else {
|
||||
if(diag_tickTime - _lockTime > 3) then {
|
||||
TRACE_2("LOCKED!", _currentTarget, _lockTime);
|
||||
|
||||
__JavelinIGUISeek ctrlSetTextColor __ColorGreen;
|
||||
__JavelinIGUINFOV ctrlSetTextColor __ColorNull;
|
||||
__JavelinIGUITargetingConstrains ctrlShow true;
|
||||
__JavelinIGUITargetingGate ctrlShow true;
|
||||
__JavelinIGUITargetingLines ctrlShow true;
|
||||
|
||||
|
||||
_apos = worldToScreen (_newTarget modelToWorld _randomPosWithinBounds);
|
||||
|
||||
_aposX = 0;
|
||||
_aposY = 0;
|
||||
if (count _apos < 2) then {
|
||||
_aposX = 1;
|
||||
_aposY = 0;
|
||||
} else {
|
||||
_aposX = (_apos select 0) + _offsetX;
|
||||
_aposY = (_apos select 1) + _offsetY;
|
||||
};
|
||||
|
||||
// Move target marker to coords.
|
||||
__JavelinIGUITargetingLineV ctrlSetPosition [_aposX,ctrlPosition __JavelinIGUITargetingLineV select 1];
|
||||
__JavelinIGUITargetingLineH ctrlSetPosition [ctrlPosition __JavelinIGUITargetingLineH select 0,_aposY];
|
||||
{_x ctrlCommit __TRACKINTERVAL} forEach [__JavelinIGUITargetingLineH,__JavelinIGUITargetingLineV];
|
||||
|
||||
_boundsInput = if (_currentTarget isKindOf "CAManBase") then {
|
||||
[_currentTarget,[-1,-1,-2],_currentTarget selectionPosition "body"];
|
||||
} else {
|
||||
[_currentTarget,[-1,-1,-2],_currentTarget selectionPosition "zamerny"];
|
||||
};
|
||||
|
||||
_bpos = _boundsInput call FUNC(worldToScreenBounds);
|
||||
|
||||
_constraintTop = __ConstraintTop;
|
||||
_constraintLeft = __ConstraintLeft;
|
||||
_constraintBottom = __ConstraintBottom;
|
||||
_constraintRight = __ConstraintRight;
|
||||
|
||||
_offsetX = __OffsetX;
|
||||
_offsetY = __OffsetY;
|
||||
|
||||
_minX = ((_bpos select 0) + _offsetX) max _constraintLeft;
|
||||
_minY = ((_bpos select 1) + _offsetY) max _constraintTop;
|
||||
_maxX = ((_bpos select 2) + _offsetX) min (_constraintRight - 0.025*(3/4)*SafezoneH);
|
||||
_maxY = ((_bpos select 3) + _offsetY) min (_constraintBottom - 0.025*SafezoneH);
|
||||
|
||||
__JavelinIGUITargetingGateTL ctrlSetPosition [_minX,_minY];
|
||||
__JavelinIGUITargetingGateTR ctrlSetPosition [_maxX,_minY];
|
||||
__JavelinIGUITargetingGateBL ctrlSetPosition [_minX,_maxY];
|
||||
__JavelinIGUITargetingGateBR ctrlSetPosition [_maxX,_maxY];
|
||||
|
||||
{_x ctrlCommit __TRACKINTERVAL} forEach [__JavelinIGUITargetingGateTL,__JavelinIGUITargetingGateTR,__JavelinIGUITargetingGateBL,__JavelinIGUITargetingGateBR];
|
||||
|
||||
|
||||
ACE_player setVariable["ace_missileguidance_target", _currentTarget, false];
|
||||
|
||||
|
@ -1,20 +0,0 @@
|
||||
//#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
TRACE_1("enter", _this);
|
||||
|
||||
_object = _this select 0;
|
||||
_origin = getPosASL _object;
|
||||
_matrix = _this select 1;
|
||||
_xVec = _matrix select 0;
|
||||
_yVec = _matrix select 1;
|
||||
_zVec = _matrix select 2;
|
||||
|
||||
_offset = _this select 2;
|
||||
|
||||
_x = _offset select 0;
|
||||
_y = _offset select 1;
|
||||
_z = _offset select 2;
|
||||
|
||||
_out = (((_xVec vectorMultiply _x) vectorAdd (_yVec vectorMultiply _y)) vectorAdd (_zVec vectorMultiply _z)) vectorAdd _origin;
|
||||
|
||||
_out;
|
@ -1,26 +0,0 @@
|
||||
//#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
TRACE_1("enter", _this);
|
||||
|
||||
_object = _this select 0;
|
||||
_origin = getPosASL _object;
|
||||
_matrix = _this select 1;
|
||||
_xVec = _matrix select 0;
|
||||
_yVec = _matrix select 1;
|
||||
_zVec = _matrix select 2;
|
||||
|
||||
_offset = _this select 2;
|
||||
|
||||
_offset = _offset vectorDiff _origin;
|
||||
|
||||
_x = _offset select 0;
|
||||
_y = _offset select 1;
|
||||
_z = _offset select 2;
|
||||
|
||||
_out = [
|
||||
((_xVec select 0)*_x) + ((_xVec select 1)*_y) + ((_xVec select 2)*_z),
|
||||
((_yVec select 0)*_x) + ((_yVec select 1)*_y) + ((_yVec select 2)*_z),
|
||||
((_zVec select 0)*_x) + ((_zVec select 1)*_y) + ((_zVec select 2)*_z)
|
||||
];
|
||||
|
||||
_out;
|
Loading…
Reference in New Issue
Block a user