Mouse dollying

This commit is contained in:
SilentSpike 2015-07-21 18:05:29 +01:00
parent b6ff45e8bd
commit e81f9f5e59
3 changed files with 23 additions and 35 deletions

View File

@ -23,27 +23,9 @@ if (isNil QGVAR(camHandler)) exitWith { [_this select 1] call CBA_fnc_removePerF
private ["_oldPos","_mX","_mY","_mZ","_pan","_x","_y","_z"];
_oldPos = getPosASL GVAR(camera);
_mX = 0;
_mY = 0;
_mZ = 0;
if (GVAR(camDolly) select 0) then { // Forward
_mY = _mY + GVAR(camSpeed);
};
if (GVAR(camDolly) select 1) then { // Backward
_mY = _mY - GVAR(camSpeed);
};
if (GVAR(camDolly) select 2) then { // Left
_mX = _mX - GVAR(camSpeed);
};
if (GVAR(camDolly) select 3) then { // Right
_mX = _mX + GVAR(camSpeed);
};
if (GVAR(camBoom) select 0) then { // Up
_mZ = _mZ + 0.5;
};
if (GVAR(camBoom) select 1) then { // Down
_mZ = _mZ - 0.5;
};
_mX = GVAR(camDolly) select 0;
_mY = GVAR(camDolly) select 1;
_mZ = GVAR(camBoom);
_pan = (GVAR(camPan) + 360) % 360;
_x = (_oldPos select 0) + (_mX * cos(_pan)) + (_mY * sin(_pan));

View File

@ -26,8 +26,8 @@ switch (toLower _mode) do {
if !(isNull (GETUVAR(GVAR(display),displayNull))) exitWith {};
// Initalize camera variables
GVAR(camBoom) = [false,false];
GVAR(camDolly) = [false,false,false,false];
GVAR(camBoom) = 0;
GVAR(camDolly) = [0,0];
GVAR(camGun) = false;
// Initalize display variables
@ -120,7 +120,7 @@ switch (toLower _mode) do {
// Detect right click
if ((_button == 1) && (GVAR(camMode) == 1)) then {
// In first person toggle sights mode
GVAR(gunCam) = !GVAR(gunCam);
GVAR(camGun) = !GVAR(camGun);
[] call FUNC(transitionCamera);
};
};
@ -165,28 +165,28 @@ switch (toLower _mode) do {
[_display,nil,nil,true] call FUNC(toggleInterface);
};
case 16: { // Q
GVAR(camBoom) set [0,true];
GVAR(camBoom) = 0.5;
};
case 17: { // W
GVAR(camDolly) set [0,true];
GVAR(camDolly) set [0, GVAR(camSpeed)];
};
case 29: { // Ctrl
GVAR(ctrlKey) = true;
};
case 30: { // A
GVAR(camDolly) set [2,true];
GVAR(camDolly) set [1, -GVAR(camSpeed)];
};
case 31: { // S
GVAR(camDolly) set [1,true];
GVAR(camDolly) set [0, -GVAR(camSpeed)];
};
case 32: { // D
GVAR(camDolly) set [3,true];
GVAR(camDolly) set [1, GVAR(camSpeed)];
};
case 35: { // H
[_display,nil,true] call FUNC(toggleInterface);
};
case 44: { // Z
GVAR(camBoom) set [1,true];
GVAR(camBoom) = -0.5;
};
case 49: { // N
[nil,nil,1] call FUNC(cycleCamera);
@ -320,8 +320,9 @@ switch (toLower _mode) do {
if (GVAR(camMode == 0) && (_button == 0) && _ctrl) then {
_newPos = _map ctrlMapScreenToWorld [_x,_y];
_newPos set [2, GVAR(camPos) select 2];
GVAR(camPos) = _newPos;
_oldZ = (ASLtoATL GVAR(camPos)) select 2;
_newPos set [2, _oldZ]
GVAR(camPos) = (ATLtoASL _newPos);
};
};
};

View File

@ -30,9 +30,14 @@ _oldY = GVAR(mousePos) select 1;
_deltaX = _oldX - _x;
_deltaY = _oldY - _y;
if (_rightButton && !_leftButton) then {
GVAR(camPan) = GVAR(camPan) - (_deltaX * 360);
GVAR(camTilt) = ((GVAR(camTilt) + (_deltaY * 180)) min 89) max -89;
if (_leftButton && _rightButton) then {
GVAR(camDolly) set [0, _deltaX * GVAR(camSpeed)];
GVAR(camDolly) set [1, _deltaY * GVAR(camSpeed)];
} else {
if (_rightButton) then {
GVAR(camPan) = GVAR(camPan) - (_deltaX * 360);
GVAR(camTilt) = ((GVAR(camTilt) + (_deltaY * 180)) min 89) max -89;
};
};
GVAR(mousePos) = [_x,_y];