Jump to content
ribera1945e

[solved]PiP script and arsenal

Recommended Posts

I created a UAV live feed script based on this tutorial.

However, I noticed that when I opened Arsenal while it was working, the monitor screen went black.

Is there a way around this?

Share this post


Link to post
Share on other sites
Spoiler

/*-----------------------------------------------------------------------------------
Script: liveFeedUAV
Description:
	UAVのカメラフィードバックをモニターオブジェクトに行う。
Parameters:
	_monitor	- <OBJECT> フィードバック再生とaddActionを行うオブジェクト
Return:
	Nothing
Examples:
	nul = [this] execVM "scripts\liveFeedUAV1.sqf";
Author:
	ribera1945eBP
-----------------------------------------------------------------------------------*/
if (!isServer) exitWith {};

params ["_monitor"];

if (isNull _monitor) exitWith {};

_monitor setObjectTextureGlobal [0, "#(argb,512,512,1)r2t(uavrtt1,1)"];

cam1 = "camera" camCreate [0,0,0];
cam1 cameraEffect ["Internal", "Back", "uavrtt1"];

cam1 attachTo [MQ_1, [0,0,0], "PiP0_pos"];

fnc_selectZoom = {
	private _sZoom = _this select 0;
	switch (_sZoom) do {
		case "ULTRA WIDE":
		{
			cam1 camSetFov 0.46599999;
		};
		case "WIDE":
		{
			cam1 camSetFov 0.2;
		};
		case "MEDIUM":
		{
			cam1 camSetFov 0.1;
		};
		case "NARROW":
		{
			cam1 camSetFov 0.02;
		};
		case "NARROWER":
		{
			cam1 camSetFov 0.01;
		};
	};
};

fnc_selectMode = {
	private _sMode = _this select 0;
	switch (_sMode) do {
		case "DTV":
		{
			"uavrtt1" setPiPEffect [0];;
		};
		case "NV":
		{
			"uavrtt1" setPiPEffect [1];
		};
		case "WHOT":
		{
			"uavrtt1" setPiPEffect [2];
		};
		case "BHOT":
		{
			"uavrtt1" setPiPEffect [7];
		};
	};
};

{
	private _actionTitle = format ["Select Zoom - %1",_x];
	_monitor addAction [
		_actionTitle,
		{
			private _Value = _this select 3 select 0;
			[_Value] call fnc_selectZoom;
		},
		[_x],3.3,true,false,"","",8
	];
} forEach ["ULTRA WIDE", "WIDE", "MEDIUM", "NARROW", "NARROWER"];

{
	private _actionTitle = format ["Select Mode - %1",_x];
	_monitor addAction [
		_actionTitle,
		{
			private _Value = _this select 3 select 0;
			[_Value] call fnc_selectMode;
		},
		[_x],3.3,true,false,"","",8
	];
} forEach ["DTV", "NV", "WHOT", "BHOT"];

addMissionEventHandler ["Draw3D", {
    _dir = 
        (MQ_1 selectionPosition "laser_start") 
            vectorFromTo 
        (MQ_1 selectionPosition "laser_end");
    cam1 setVectorDirAndUp [
        _dir, 
        _dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0]
    ];
}];

 

Its code

Share this post


Link to post
Share on other sites

Try turning on the PiP option in your video settings. Simple, but it caught me out once before when I'd forgotten that I had disabled it.

Share this post


Link to post
Share on other sites

I'm sorry I don't have enough explanation.

The PiP render image is displayed on the monitor object until I open the arsenal, but when I open the arsenal it turns black.

I'm trying to find a solution with a script.

Share this post


Link to post
Share on other sites

Probably no (easy) solution because you're in another display: RscDisplayArsenal.

If pip stays black after closing arsenal, you need to recreate the camera.

Something like:
 

[missionNamespace, "arsenalClosed", {
  [yourMonitor] execVM "scripts\liveFeedUAV1.sqf";
}] call BIS_fnc_addScriptedEventHandler;

Not tested.

 

Share this post


Link to post
Share on other sites

I ran it globally with init.sqf, but it had no effect.

I also tried the following syntax to regenerate cam1 but it didn't work.

//PIP arsenal proof
[missionNamespace, "arsenalClosed", {
	isNil {
		cam1 cameraEffect ["TERMINATE", "BACK"];
		camDestroy cam1;

		cam1 = "camera" camCreate [0,0,0];
		cam1 cameraEffect ["INTERNAL", "BACK", "uavrtt1"];
		cam1 attachTo [MQ_1, [0,0,0], "PiP0_pos"];
	};
}] call BIS_fnc_addScriptedEventHandler;

 

Share this post


Link to post
Share on other sites

After the screen goes black, run the following code on the server to restore the monitor.

	isNil {
		cam1 cameraEffect ["TERMINATE", "BACK"];
		camDestroy cam1;

		cam1 = "camera" camCreate [0,0,0];
		cam1 cameraEffect ["INTERNAL", "BACK", "uavrtt1"];
		cam1 attachTo [MQ_1, [0,0,0], "PiP0_pos"];
	};

Is it possible for the event handler to not recognize the variable name?

Share this post


Link to post
Share on other sites

I gave up on how to execute code inside an event handler.

Instead, I succeeded in calling liveFeedUAV1.sqf from init.sqf with pierremgi's code.

But another problem arose. I limited the code with exitWith to avoid multiple execution of all the code in liveFeedUAV1.sqf, but cameraEffect and camCreate are not working with the following syntax.

if (missionNamespace getVariable ["liveFeedUAV1done", false] isEqualTo true) exitWith {
	cam1 cameraEffect ["TERMINATE", "BACK"];
	camDestroy cam1;
	
	cam1 = "camera" camCreate [0,0,0];
	cam1 cameraEffect ["Internal", "Back", "uavrtt1"];
	cam1 camSetFov 0.46599999;
	"uavrtt1" setPiPEffect [0];
	cam1 attachTo [MQ_1, [0,0,0], "PiP0_pos"];
};

I think the if statement is correct as it works when I run hint in the syntax.
Maybe I overlook something?

 

Thanks.

Share this post


Link to post
Share on other sites

Well. I think it's a simple question of precedence (delay) for running script in good order.

I tested with a monitor (I named it monitor) and a drone (I named it MQ_1)

As I was on quick test in preview I replaced your sqf by:
 

liveFeedUAV1 = {
  if (!isServer) exitWith {};
  params ["_monitor"];
  if (isNull _monitor) exitWith {};
  _monitor setObjectTextureGlobal [0, "#(argb,512,512,1)r2t(uavrtt1,1)"];
  cam1 = "camera" camCreate [0,0,0];
  cam1 cameraEffect ["Internal", "Back", "uavrtt1"];
  cam1 attachTo [MQ_1, [0,0,0], "PiP0_pos"];
 
fnc_selectZoom = {
  private _sZoom = _this select 0;
  switch (_sZoom) do {
    case "ULTRA WIDE": {cam1 camSetFov 0.46599999};
    case "WIDE": {cam1 camSetFov 0.2};
    case "MEDIUM": {cam1 camSetFov 0.1};
    case "NARROW": {cam1 camSetFov 0.02};
    case "NARROWER": {cam1 camSetFov 0.01};
  };
};
 
fnc_selectMode = {
  private _sMode = _this select 0;
  switch (_sMode) do {
    case "DTV": {"uavrtt1" setPiPEffect [0]};
    case "NV": {"uavrtt1" setPiPEffect [1]};
    case "WHOT": {"uavrtt1" setPiPEffect [2]};
    case "BHOT": {"uavrtt1" setPiPEffect [7]};
   };
};
 
{
  private _actionTitle = format ["Select Zoom - %1",_x];
  _monitor addAction [
    _actionTitle,
    {
      private _Value = _this select 3 select 0;
      [_Value] call fnc_selectZoom;
    },
    [_x],3.3,true,false,"","",8
   ];
} forEach ["ULTRA WIDE", "WIDE", "MEDIUM", "NARROW", "NARROWER"];
 
{
  private _actionTitle = format ["Select Mode - %1",_x];
  _monitor addAction [
    _actionTitle,
    {
      private _Value = _this select 3 select 0;
      [_Value] call fnc_selectMode;
    },
    [_x],3.3,true,false,"","",8
  ];
} forEach ["DTV", "NV", "WHOT", "BHOT"];
 
addMissionEventHandler ["Draw3D", {
  _dir = (MQ_1 selectionPosition "laser_start") vectorFromTo (MQ_1 selectionPosition "laser_end");
  cam1 setVectorDirAndUp [_dir,_dir vectorCrossProduct [-(_dir select 1),_dir select 0, 0]];
}];

};

in a trigger set to true (cond).

 

In init field of the monitor : this spawn { sleep 3; _this call liveFeedUAV1}

just to be sure the code liveFeedUAV1 exists before calling it.

I placed a hunter as virtual arsenal

In init field of the hunter (or everywhere else) :

[missionNamespace, "arsenalClosed", {
  MQ_1 spawn liveFeedUAV1;
}] call BIS_fnc_addScriptedEventHandler;

 

That works as is, but if you want to ensure the deal:

[missionNamespace, "arsenalClosed", {
  MQ_1 spawn {sleep 1; _this call liveFeedUAV1};
}] call BIS_fnc_addScriptedEventHandler;

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Thank you for your reply.

Your code helped me understand the code delays in arma3.

I solve the problem by simply adding sleep 1 to my code.

thank you for your politeness.

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

×