2015-01-11 16:42:31 +00:00
|
|
|
/*
|
|
|
|
* Taken From:
|
|
|
|
* https://community.bistudio.com/wiki/BIS_fnc_setPitchBank
|
|
|
|
* Edited By:
|
|
|
|
* KoffeinFlummi
|
2015-01-12 04:02:33 +00:00
|
|
|
*
|
2015-01-11 16:42:31 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: Unit/Vehicle
|
|
|
|
* 1: Pitch (degrees)
|
|
|
|
* 2: Yaw (degrees)
|
|
|
|
* 3: Bank (degrees)
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*/
|
2015-01-12 11:14:15 +00:00
|
|
|
#include "\z\ace\addons\core\script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
private ["_object", "_aroundX", "_aroundY", "_aroundZ", "_dirX", "_dirY", "_dirZ", "_upX", "_upY", "_upZ", "_dir", "_up", "_dirXTemp", "_upXTemp"];
|
|
|
|
|
|
|
|
_object = _this select 0;
|
|
|
|
_aroundX = _this select 1;
|
|
|
|
_aroundY = _this select 2;
|
|
|
|
_aroundZ = (360 - (_this select 3)) - 360;
|
|
|
|
|
|
|
|
_dirX = 0;
|
|
|
|
_dirY = 1;
|
|
|
|
_dirZ = 0;
|
|
|
|
_upX = 0;
|
|
|
|
_upY = 0;
|
|
|
|
_upZ = 1;
|
2015-01-12 04:02:33 +00:00
|
|
|
if (_aroundX != 0) then {
|
2015-01-11 16:42:31 +00:00
|
|
|
_dirY = cos _aroundX;
|
|
|
|
_dirZ = sin _aroundX;
|
|
|
|
_upY = -sin _aroundX;
|
|
|
|
_upZ = cos _aroundX;
|
|
|
|
};
|
2015-01-12 04:02:33 +00:00
|
|
|
if (_aroundY != 0) then {
|
2015-01-11 16:42:31 +00:00
|
|
|
_dirX = _dirZ * sin _aroundY;
|
|
|
|
_dirZ = _dirZ * cos _aroundY;
|
|
|
|
_upX = _upZ * sin _aroundY;
|
|
|
|
_upZ = _upZ * cos _aroundY;
|
|
|
|
};
|
2015-01-12 04:02:33 +00:00
|
|
|
if (_aroundZ != 0) then {
|
2015-01-11 16:42:31 +00:00
|
|
|
_dirXTemp = _dirX;
|
|
|
|
_dirX = (_dirXTemp* cos _aroundZ) - (_dirY * sin _aroundZ);
|
2015-01-12 04:02:33 +00:00
|
|
|
_dirY = (_dirY * cos _aroundZ) + (_dirXTemp * sin _aroundZ);
|
2015-01-11 16:42:31 +00:00
|
|
|
_upXTemp = _upX;
|
|
|
|
_upX = (_upXTemp * cos _aroundZ) - (_upY * sin _aroundZ);
|
2015-01-12 04:02:33 +00:00
|
|
|
_upY = (_upY * cos _aroundZ) + (_upXTemp * sin _aroundZ);
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_dir = [_dirX,_dirY,_dirZ];
|
|
|
|
_up = [_upX,_upY,_upZ];
|
|
|
|
|
|
|
|
_object setVectorDirAndUp [_dir,_up];
|