Forum Jump :

Author Message


Posts: 122
Rank:


Level: Member

Country: fr
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2017-01-15 14:25        
     
Hi every one,

I'm trying to create a PIP render on a screen, following a KillZoneKid tutorial here. All seems to work excepted the setting at each frame of the camera direction. I get a script error (originally in french, trying to translate) : "cam [#]setVectorDirAndUp error 0 elements provided, 3 needed"

So far I'v only adapted KK's script to my objects but the script is strictly the same. The render is working, but it's locked to the front of the UAV, as this error seems to say that it cannot succeed in setting the cam direction.

Do you have any idea ?

EDIT : I've tried to display what is contained in _dir, as it's an array, and it seems to contain only "any's", so the calculation of _dir seems to be failed ?

This post was edited by Cheitan (2017-01-15 14:37, 615 days ago)


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 58
In-game name: Kobayashi Maru

 
#2 Posted at 2017-01-15 15:32        
     
You can't change pip0_pos and pip0_dir for other names as they are some specific attributes for an UAV camera.
If something else, you'd better post your entire script.

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Advertisement


Author Message


Posts: 122
Rank:


Level: Member

Country: fr
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2017-01-15 15:39        
     
I'm not sure to understand your message. The script I use, designed by KK, don't seems to try to modify the name of thoses two things ? Anyway, here is the short code I'm using :

params["_target"];
ecran setObjectTexture [0, "#(argb,512,512,1)r2t(uavrtt,1)"];

cam = "camera" camCreate [0,0,0];
cam cameraEffect ["Internal", "Back", "uavrtt"];

/* attach cam to gunner cam position */
cam attachTo [_target, [0,0,0], "PiP0_pos"];

/* make it zoom in a little */
cam camSetFov 0.1;

/* switch cam to thermal */
"uavrtt" setPiPEffect [2];

/* adjust cam orientation */
addMissionEventHandler ["Draw3D", {
    _dir = (_target selectionPosition "PiP0_pos") vectorFromTo (_target selectionPosition "PiP0_dir");
	hint format ["%1 %2 %3",(_dir select 0),(_dir select 1),(_dir select 2)];
    cam setVectorDirAndUp [_dir, _dir vectorCrossProduct [-(_dir select 1), (_dir select 0), 0]];
}];


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 21
In-game name: Wak

 
#4 Posted at 2017-01-15 15:51        
     
"Error, 0 elements provided, 3 expected" is a classic error for empty vectors. The command is expecting an array with 3 elements (usually a vector) but you're giving it an empty array. The reason for this is that _target is undefined in that event handler's code, so _dir acts weird. You can't pass parameters to mission event handlers, so I'd recommend using CBA's addPerFrameHandler.

Btw, instead of that whole code at line #19, you can just do this:
hint str _dir;

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 58
In-game name: Kobayashi Maru

 
#5 Posted at 2017-01-15 16:03        
     
Effectively, you didn't change these names, which are specific for some models (not simple variables, but parts of cam attributes here). It was a supposition for your problem, without any script to read.

Now I can tell you, you have 2 mistakes:
pip0_pos / dir must refer to UAV cam because selectionPosition searches for selections in the object model (here uav camera);
- you introduce a local variable: _target which is not defined in the event handler scope. (inside the code for Draw3D).

Apply selectionPosition to UAV

Added 13 minutes later:

# 654wak654 : I'd recommend using CBA's addPerFrameHandler.

Nothing against CBA, most of the time, but what's added value of addPerFrameHandler, not so sure? With BI command, you just have to pay attention for global variables. Not so hard.
Do you have any test for CPU's optimization? With a "per frame" execution, I'd rather be sure to run the fastest.

This post was edited by Pierre MGI (2017-01-15 16:19, 615 days ago)

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 4
Rank:


Level: Member

Country: br
Location:
Occupation:
Age:
In-game name:

 
#6 Posted at 2018-03-11 00:40        
     
Hello everyone, any ideas, why does this Kill Zone_Kid script no longer work? It does not transmit the image any more, just a black screen.
/* create render surface */
_bb = "Land_Billboard_F" createVehicle position player;
_bb setObjectTexture [0, "#(argb,512,512,1)r2t(uavrtt,1)"];

/* create uav and make it fly */
uav = createVehicle ["B_UAV_01_F", _bb modelToWorld [0,100,100], [], 0, "FLY"];
createVehicleCrew uav;
uav lockCameraTo [_bb, [0]];
uav flyInHeight 100;

/* add loiter waypoint */
_wp = group uav addWaypoint [position _bb, 0];
_wp setWaypointType "LOITER";
_wp setWaypointLoiterType "CIRCLE_L";
_wp setWaypointLoiterRadius 100;

/* create camera and stream to render surface */
cam = "camera" camCreate [0,0,0];
cam cameraEffect ["Internal", "Back", "uavrtt"];

/* attach cam to gunner cam position */
cam attachTo [uav, [0,0,0], "PiP0_pos"];

/* make it zoom in a little */
cam camSetFov 0.1;

/* switch cam to thermal */
"uavrtt" setPiPEffect [2];

/* adjust cam orientation */
addMissionEventHandler ["Draw3D", {
    _dir = 
        (uav selectionPosition "PiP0_pos") 
            vectorFromTo 
        (uav selectionPosition "PiP0_dir");
    cam setVectorDirAndUp [
        _dir, 
        _dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0]
    ];
}];


Author Message


Posts: 1513
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#7 Posted at 2018-03-11 01:21        
     
Works for me, the screen is dark but there, I think it's a thermal image.

To see it better try this
"uavrtt" setPiPEffect [2]; change this to [0] for day light.


Author Message


Posts: 4
Rank:


Level: Member

Country: br
Location:
Occupation:
Age:
In-game name:

 
#8 Posted at 2018-03-11 03:42        
     
Thanks to Pierre MGI , who replied to my post in another forum, the problem was solved. My in-game video setup was with PIP turned off, so the picture on the screen did not appear.
Thank you for answering me so promptly.

This post was edited by dineidevos (2018-03-11 04:05, 195 days ago)