Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×

Recommended Posts

Hi all,

Can someone explain how to setup boundaries for mouse moving EH? To put it short, I want something similar to the Arsenal camera. I took a look over how BIS did it and ripped some parts out but it in the end everything is just too dependent on something else. Each variable is defined from somewhere else. Way too much hassle. In the video, you can see what is going on. I just want a nice smooth restricted camera without zoom.

_display displayAddEventHandler ["MouseMoving",
{
	params ["_display", "_xPos", "_yPos"];
	systemChat str _this;
	if (holding) then
	{
		unconsciousCamera camSetTarget _unit;
		unconsciousCamera camSetPos [_xPos, _yPos, 6];
		unconsciousCamera camCommit 0.1; // 0 is INSANE
	};
}];

I guess there needs to be 'some' calculations? Just have no idea what.

 

Here is part of what the Arsenal camera uses. Maybe someone can understand it better and explain?

#define CAM_DIS_MAX	5
	case "Mouse": {
		_ctrl = _this select 0;
		_mX = _this select 1;
		_mY = _this select 2;
		BIS_fnc_arsenal_mouse = [_mX,_mY];

		_cam = (uinamespace getvariable ["BIS_fnc_arsenal_cam",objnull]);
		_center = (missionnamespace getvariable ["BIS_fnc_arsenal_center",player]);
		_target = (missionnamespace getvariable ["BIS_fnc_arsenal_target",player]);

		_dis = BIS_fnc_arsenal_campos select 0;
		_dirH = BIS_fnc_arsenal_campos select 1;
		_dirV = BIS_fnc_arsenal_campos select 2;
		_targetPos = BIS_fnc_arsenal_campos select 3;
		_disLocal = _dis;

		_LMB = BIS_fnc_arsenal_buttons select 0;
		_RMB = BIS_fnc_arsenal_buttons select 1;

		if (isnull _ctrl) then {_LMB = [0,0];}; //--- Init

		if (count _LMB > 0) then {
			_cX = _LMB select 0;
			_cY = _LMB select 1;
			_dX = (_cX - _mX);
			_dY = (_cY - _mY);
			BIS_fnc_arsenal_buttons set [0,[_mX,_mY]];

			_centerBox = boundingboxreal _center;
			_centerSizeBottom = _centerBox select 0 select 2;
			_centerSizeUp = _centerBox select 1 select 2;
			_centerSize = sqrt ([_centerBox select 0 select 0,_centerBox select 0 select 1] distance [_centerBox select 1 select 0,_centerBox select 1 select 1]);
			_targetPos = [_targetPos,_dX * _centerSize,_dirH - 90] call bis_fnc_relpos;
			_targetPos = [
				[0,0,((_targetPos select 2) - _dY * _centerSize) max _centerSizeBottom min _centerSizeUp],
				([[0,0,0],_targetPos] call bis_fnc_distance2D) min _centerSize,
				[[0,0,0],_targetPos] call bis_fnc_dirto
			] call bis_fnc_relpos;
			//_targetPos set [2,(_targetPos select 2) max 0.1];
			_targetPos set [2,(_targetPos select 2) max ((boundingboxreal _center select 0 select 2) + 0.2)];

			//--- Do not let target go below ground
			_posZmin = 0.1;
			_targetWorldPosZ = (_center modeltoworldvisual _targetPos) select 2;
			if (_targetWorldPosZ < _posZmin) then {_targetPos set [2,(_targetPos select 2) - _targetWorldPosZ + _posZmin];};

			BIS_fnc_arsenal_campos set [3,_targetPos];
		};

		if (count _RMB > 0) then {
			_cX = _RMB select 0;
			_cY = _RMB select 1;
			_dX = (_cX - _mX) * 0.75;
			_dY = (_cY - _mY) * 0.75;
			_targetPos = [
				[0,0,_targetPos select 2],
				[[0,0,0],_targetPos] call bis_fnc_distance2D,
				([[0,0,0],_targetPos] call bis_fnc_dirto) - _dX * 180
			] call bis_fnc_relpos;

			BIS_fnc_arsenal_campos set [1,(_dirH - _dX * 180) % 360];
			BIS_fnc_arsenal_campos set [2,(_dirV - _dY * 100) max -89 min 89];
			BIS_fnc_arsenal_campos set [3,_targetPos];
			BIS_fnc_arsenal_buttons set [1,[_mX,_mY]];
		};

		if (isnull _ctrl) then {BIS_fnc_arsenal_buttons = [[],[]];};

		//--- Terminate when unit is dead
		if (!alive _center || isnull _center) then {
			(ctrlparent (_this select 0)) closedisplay 2;
		};
	};

	///////////////////////////////////////////////////////////////////////////////////////////
	case "MouseButtonDown": {
		BIS_fnc_arsenal_buttons set [_this select 1,[_this select 2,_this select 3]];
	};

	///////////////////////////////////////////////////////////////////////////////////////////
	case "MouseButtonUp": {
		BIS_fnc_arsenal_buttons set [_this select 1,[]];
	};

	///////////////////////////////////////////////////////////////////////////////////////////
	case "MouseZChanged": {
		_cam = (uinamespace getvariable ["BIS_fnc_arsenal_cam",objnull]);
		_center = (missionnamespace getvariable ["BIS_fnc_arsenal_center",player]);
		_target = (missionnamespace getvariable ["BIS_fnc_arsenal_target",player]);

		_disMax = if (bis_fnc_arsenal_type > 0) then {((boundingboxreal _center select 0) vectordistance (boundingboxreal _center select 1)) * 1.5} else {CAM_DIS_MAX};
		//_disMax = if (bis_fnc_arsenal_type > 0) then {sizeof typeof _center * 1.5} else {CAM_DIS_MAX};
		_disMin = _disMax * 0.15;
		_z = _this select 1;
		_dis = BIS_fnc_arsenal_campos select 0;
		_dis = _dis - (_z / 10);
		_dis = _dis max _disMin min _disMax;
		BIS_fnc_arsenal_campos set [0,_dis];
	};

Any help would be great! Thanks.

 

 

Share this post


Link to post
Share on other sites
2 hours ago, HazJ said:

I took a look over how BIS did it and ripped some parts out but it in the end everything is just too dependent on something else. Each variable is defined from somewhere else. Way too much hassle.

https://github.com/acemod/ACE3/blob/69a67ff4e253a5087e2e90e06480c448820942f4/addons/arsenal/functions/fnc_onArsenalOpen.sqf#L350-L351

https://github.com/acemod/ACE3/blob/master/addons/arsenal/functions/fnc_updateCamPos.sqf

https://github.com/acemod/ACE3/blob/master/addons/arsenal/functions/fnc_handleMouse.sqf

 

 

  • Like 1

Share this post


Link to post
Share on other sites

×