Jump to content
Sign in to follow this  
kavoven

Drone Attach Camera + VectorDir

Recommended Posts

Hi guys,

 

I am displaying a PIP of a drone (GunnerView) via a RscPicture dialog. This works the way I want to but the resolution is really bad. I thought that I would just have to change the values in text = "#(argb,512,512,1)r2t(renderTarget1,1);" but it appears as if the resolution of the picture displayed in the dialog remains at a 256*256 level. Is there a way to change that?

 

Secondly, I am using the following script to attach my camera to the drone:

 

while{not isnull drone1} do 
{
	_pipcam setVectorDir drone1 weaponDirection currentWeapon drone1;
	_campos = getposATL drone1;
	_droneheight = (getPosATL drone1 select 2);
	_campos set [2, _droneheight + 1];
	_pipcam setpos _campos;
};

 

I now want to give the player the possibility to rotate the camera view with two buttons (45 degree steps). My approach would be to add another variable into the setvectordir line that is initialized as 0 at the start of the mission and can be changed by pressing one of the buttons in my dialog. However, ArmA keeps throwing errors at me that it expects a three dimensional array if I try something like setVectorDir dirA + dirB. What am I doing wrong?

 

This is also the reason why I am not working with the attach command, but I did not find a way to tell the drone to turn the gunner view in a certain angle. 

 

Ah and a technical follow-up question. The player can simple exit the dialog by pressinc ESC. Since I use the while not isnull drone1 loop I am wondering whether the script will keep running afterwards and if I might run into troubles when the player starts and exits the camera 40 or 50 times? I guess I might need to insert some kind of event handler than that checks whether ESC was pressed and exit the loop...?

Share this post


Link to post
Share on other sites

1. Not sure

 

2. weaponDirection returns a vector [x,y,z] not direction in degrees. setVectorDir expects the same. To rotate the vector around an axis like you say you must use some fancier math called Axis-angle rotations (also known as Rodrigues rotation). I got a function for it on my desktop. I'll post back when I'm off work. 

 

It might just be easier to tell the drone gunner to watch certain positions with the doWatch command.

 

3. The loop will keep running as long as the condition returns true, so yes. If you set it up to create a new cam each time then you'd have to check for when the dialog is closed and then do some cleanup. The camera can exist on its own so it is possible to create and use the same camera over and over again. 

Share this post


Link to post
Share on other sites

Right here's the axis-angle rotation function:
 

Spoiler

 


fnc_axisAngleRotation = {
	params ["_vector", "_axis", "_angle"];
	_axis = vectorNormalized _axis;
	private _d = _axis vectorMultiply (_axis vectorDotProduct _vector);
	private _r = _vector vectorDiff _d;	
	(_d vectorAdd ((_r vectorMultiply cos _angle) vectorAdd ((_axis vectorCrossProduct _r) vectorMultiply sin _angle)))
};

 

 

In short it rotates a vector around an axis by a the given angle, here's a picture that might help with visualisation.
rYFyIqb.png

 

In your case the axis of rotation would be the same as the z-axis, for which the unit vector is [0,0,1].The angle given is read counterclockwise so to "go left" you add and "go right" you subtract.

Examples: 

Spoiler

 


//Get the current weapon direction turned 90 degrees left
[_drone weaponDirection currentWeapon _drone, [0,0,1], 90] call fnc_axisAngleRotation;

//Rotate vehicle around its own vector up
[] spawn {
	rotate = true;
	dir = 0;
	while {rotate} do {
		private _vDir = [vectorDir car, vectorUp car, dir] call fnc_axisAngleRotation;
		car setVectorDirAndUp [_vDir, vectorUp car];
		sleep 0.1;
	};
};

//Showcase vehicle
[] spawn {
	rotate = false;
	sleep 1;
	rotate = true; 
	rotateSpeed = 0.5; 
	
	private _posATL = getPosATL car;
	_posATL set [2, 2];
  
  	//Get normal of dir and up.
	private _vectorSide = vectorDir car vectorCrossProduct vectorUp car;	
  	
	//Position and pitch vehicle forward 
	car setPosATL _posATL;
	car setVectorDirAndUp [
		[vectorDir car, _vectorSide, -30] call fnc_axisAngleRotation, 
		[vectorUp car, _vectorSide, -30] call fnc_axisAngleRotation
	];
  
	//Spin vehicle
	while {rotate} do { 
		sleep 0.01;
		car setVectorDirAndUp [
			[vectorDir car, [0,0,1], rotateSpeed] call fnc_axisAngleRotation, 
			[vectorUp car, [0,0,1], rotateSpeed] call fnc_axisAngleRotation
		]; 
	};
};

 

 

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×