Jump to content
Sign in to follow this  
dragon zen

Need help: I just can't handle the camera...

Recommended Posts

SORRY, I didn't say my question correctly: I mean I want to let player control the camera, just as satellite view. Thanks.:p

OK, bros:

I want to create a sattelite view in my mission, and I try several hours but it just can't work. So need help, thx.

Now I can create a camera in the air, but I can't let the player move the camera. I use

_keyDownEHId = (findDisplay 46) displayAddEventHandler ["KeyDown","_key = _this select 1;if (_key in (actionkeys 'HeliUp')) then {_cam camSetPos [2300,1000,130];};"];
, but it tell me TYPE NOTHING, EXPECT BOOL. why? I unpack the UAV module in official files, I think that is similar to mine.

I unpack other's file (proving ground.utes, thx), found that somebody use such as

_keyhandler = (findDisplay 46) displayAddEventHandler ["KeyDown", "_this call (PG_logic getVariable ""satcam_keyhandler"")"];
but I don't know how to use "call" script.

I saw http://community.bistudio.com/wiki/User_Interface_Event_Handlers, but don't know where to put those long codes

functionName_keyDown = .........

Well, it seems that I need to learn: 1, handle the camera. 2, make new function and call it. 3, some thing about "displayAddEventHandler". Too complex.:confused:

THANKS

PS: coming from CN, sorry for my EN.

Edited by Dragon Zen

Share this post


Link to post
Share on other sites
OK, bros:

I want to create a sattelite view in my mission, and I try several hours but it just can't work. So need help, thx.

Now I can create a camera in the air, but I can't let the player move the camera. I use , but it tell me TYPE NOTHING, EXPECT BOOL. why? I unpack the UAV module in official files, I think that is similar to mine.

I unpack other's file (proving ground.utes, thx), found that somebody use such as but I don't know how to use "call" script.

I saw http://community.bistudio.com/wiki/User_Interface_Event_Handlers, but don't know where to put those long codes

Well, it seems that I need to learn: 1, handle the camera. 2, make new function and call it. 3, some thing about "displayAddEventHandler". Too complex.:confused:

THANKS

PS: coming from CN, sorry for my EN.

Hey dude. Be confident, nobody thinks your English is poor and you should be proud of being as a Chinese, don't you think so? Btw, do you have any ID in VME forum? lol.

Okay joking apart, just getting down to business, maybe here I can only answer you the second question.

If you wanna to call a function, you should pre-define your script by useing "compile preProcessfile" and "compile preprocessFileLineNumbers" before you start calling it. Each function can return a specific value you want but it relies on how you script it. The syntax is just the same as sqf syntax but you should bear it in your mind that never use "sleep" in your function because it may cause error. Different from normal sqf files, at the end of the function should be the place to indicate the value you wanna to calling without semicolon. It can be easier understood if you've some knowledge on how to scripting.

P.S. (How strange for two Chinese talk in English here, I prefer Chinese to English if the forum allows me to do that. lol)

Edited by ffur2007slx2_5

Share this post


Link to post
Share on other sites

Haha, I am glad to see Chinese here.

VME... I forget whether I have a ID there, because most time I go to SAMREN.

OK, it seems that I have much to learn to handle the camera.

Share this post


Link to post
Share on other sites

OK you got as far as:

this exec "camera.sqs";

in the init line of the player to get a camera?

Camera movement:

http://community.bistudio.com/wiki/camera.sqs

Camera commands:

http://community.bistudio.com/wiki/Category:Command_Group:_Camera_Control

Then have a look on youtube and on this thread:

http://forums.bistudio.com/showthread.php?t=82020&page=3

-You will need to move the camera up to get a satellite view: shift + Q

-Then tilt down: Keyboard - Number pad - 2.

-Left click mouse to get camera position in clipboard.

-Alt+Tab to desktop and paste in Notepad or text editor of your choice.

To use your camera position - see my posts in the thread above. You can either create a camera script and run it during the mission or create an intro to run at the beginning of the mission.

Edited by PELHAM

Share this post


Link to post
Share on other sites

Try this simple satelite style zoom in , switch to thermal imaging script for the airfield on Utes Island.

Use a radio trigger or save it as initIntro.sqf to use it in the intro.

//nul = [] execVM "satscene1.sqf";

cutText ["","BLACK FADED"];

0 fadeSound 0;

showCinemaBorder false;

playMusic ["EP1_Track07", 20];

_camera = "camera" camCreate [0,0,0];

_camera cameraEffect ["INTERNAL", "Back"];

_camera camCommand "inertia on";

_camera camPrepareTarget [3176.53,3069.60,-97740.07];

_camera camPreparePos [3567.46,3608.86,2739.88];

_camera camPrepareFOV 0.700;

_camera camCommitPrepared 0;

waitUntil {camCommitted _camera};

cutText ["", "BLACK IN"];

["Live Satellite Feed", "Utes Island"] call BIS_fnc_infoText;

_camera camPrepareTarget [3609.59,2961.36,-99579.96];

_camera camPreparePos [3567.54,3611.22,637.63];

_camera camPrepareFOV 0.700;

_camera camCommitPrepared 10;

waitUntil {camCommitted _camera};

["Target", "Air Base"] call BIS_fnc_infoText;

_camera camPrepareTarget [3567.23,6227.03,-99925.52];

_camera camPreparePos [3567.41,3609.26,81.80];

_camera camPrepareFOV 0.700;

true setCamUseTi 0;

["Thermal Imaging Mode"] call BIS_fnc_infoText;

_camera camCommitPrepared 15;

waitUntil {camCommitted _camera};

cutText ["","BLACK FADED"];

_camera cameraeffect ["terminate","BACK"];

camdestroy _camera;

cutText ["", "BLACK IN"];

Share this post


Link to post
Share on other sites

THANK YOU PELHAM. I have some question:

Camera.sqs can let player control the camera directly? Thus, how can I forbid some functions (sattelite can't head up and head down)?? And the scripts in 5# seems can't control by player.

What's more, I real want to learn how to define the input (such as KeyDown), this is a useful function. :D

Edited by Dragon Zen

Share this post


Link to post
Share on other sites

What's more, I real want to learn how to define the input (such as KeyDown), this is a useful function. :D

in init.sqf put this at bottom.


// do like this and have a function in that file called MY_CAM_KEYDOWN_FNC and MY_CAM_KEYUP_FNC
call compile preprocessFileLineNumbers "camera\cam_key_fnc.sqf";    

//or in init.
MY_CAM_KEYDOWN_FNC =
{
   switch (_this) do {
       //Button 2
       case 3: {
             titletext["I just pressed button 2. but i can do more here", "PLAIN"];
       };
   };
};
MY_CAM_KEYUP_FNC =
{
   switch (_this) do {
       //Button 2
       case 3: {
             titletext["I just relesed button 2. but i can do more here", "PLAIN"];
       };
   };
};



WaitUntil {!IsNull (FindDisplay 46)};
(findDisplay 46) displayAddEventHandler ["KeyDown","_this select 1 call MY_CAM_KEYDOWN_FNC;false;"];
(findDisplay 46) displayAddEventHandler ["KeyUp","_this select 1 call MY_CAM_KEYUP_FNC;false;"];

there is also a way to contol the camera by mouse movement. but that require you to make a custom camscript combined with dialog.

my latest work using camera.

Edited by nuxil

Share this post


Link to post
Share on other sites

Hi Dragon,

My script is for a non player controlled camera scene.

If you want a player controlled satellite camera you will need to find a script somewhere. Either search here or try Armaholic.com

Share this post


Link to post
Share on other sites

@Dragon Zen: Well, I can tell you about my project of Satellite view. There´s a link on armaholic.com

Share this post


Link to post
Share on other sites
@Dragon Zen: Well, I can tell you about my project of Satellite view. There´s a link on armaholic.com

Haha, thanks CHICAGO. I want to learn sattelite from you, and add you in my thankslist then:D.

I saw your SATCOM, but it is too complex. My need is simple now, I just want to know how to let player handle the camera. It seems the KeyDown function combines more than one sqf, so I can't learn it from others' scripts. I saw the wiki but don't understand it yet.

Share this post


Link to post
Share on other sites

So I try to explain to you in simply. Below you can find my script where I defined eventHandler for "KeyDown".

disableSerialization;

sleep 0.1;

PXS_keyEventHandler = (findDisplay 46) displayAddEventHandler ["KeyDown","_this call PXS_keyEventFunction"];

And function PXS_keyEventFunction I defined like this:

PXS_keyEventFunction = compile preprocessFileLineNumbers "pxs_satcom_oa\key_function.sqf";

For example there´s PXS_keyEventFunction in key_function.sqf file:

private["_event","_keyCode","_return"];

_event = _this;
_keyCode = _event select 1;
_return = true;

#define FACTOR 50

switch (_keyCode) do
{
case 1://ESC
{
	call PXS_closeCamera;
};
case 2://1 normal view
{
	[2] call PXS_adjustCamera;
};
case 3://2 night vision
{
	[3] call PXS_adjustCamera;
};
case 4://3 white is hot
{
	[4] call PXS_adjustCamera;
};
case 5://4 black is hot
{
	[5] call PXS_adjustCamera;
};
default
{
	_return = false;
};
};
// key combo handling
if (!(_return)) then
{
private["_pressedButtonArray"];
_pressedButtonArray = [_keyCode];
_return = true;

// check for key actions
switch (true) do
{
	//case 17://W
	case (({_x in _pressedButtonArray} count (actionKeys "MoveForward")) > 0):
	{
		PXS_SatelliteNorthMovementDelta = 2.5;
		PXS_SatelliteTarget setPos [((getPos PXS_SatelliteTarget) select 0) - PXS_SatelliteNorthMovementDelta,((getPos PXS_SatelliteTarget) select 1) + PXS_SatelliteNorthMovementDelta,(getPos PXS_SatelliteTarget) select 2];
		call PXS_updateCamera;
	};
	//case 31://S
	case (({_x in _pressedButtonArray} count (actionKeys "MoveBack")) > 0):
	{
		PXS_SatelliteSouthMovementDelta = 2.5;
		PXS_SatelliteTarget setPos [((getPos PXS_SatelliteTarget) select 0) + PXS_SatelliteSouthMovementDelta,((getPos PXS_SatelliteTarget) select 1) - PXS_SatelliteSouthMovementDelta,(getPos PXS_SatelliteTarget) select 2];
		call PXS_updateCamera;
	};
	//case 30://A
	case (({_x in _pressedButtonArray} count (actionKeys "TurnLeft")) > 0):
	{
		PXS_SatelliteWestMovementDelta = 2.5;
		PXS_SatelliteTarget setPos [((getPos PXS_SatelliteTarget) select 0) - PXS_SatelliteWestMovementDelta,((getPos PXS_SatelliteTarget) select 1) - PXS_SatelliteWestMovementDelta,(getPos PXS_SatelliteTarget) select 2];
		call PXS_updateCamera;
	};
	//case 32://D
	case (({_x in _pressedButtonArray} count (actionKeys "TurnRight")) > 0):
	{
		PXS_SatelliteEastMovementDelta = 2.5;
		PXS_SatelliteTarget setPos [((getPos PXS_SatelliteTarget) select 0) + PXS_SatelliteEastMovementDelta,((getPos PXS_SatelliteTarget) select 1) + PXS_SatelliteEastMovementDelta,(getPos PXS_SatelliteTarget) select 2];
		call PXS_updateCamera;
	};
	//case 78://Num +
	case ((({_x in _pressedButtonArray} count (actionKeys "ZoomIn")) > 0) || (({_x in _pressedButtonArray} count (actionKeys "MoveDown")) > 0)):
	{
		if ((PXS_SatelliteZoom + (0.02 * FACTOR)) <= 27) then
		{
			PXS_SatelliteFOV = PXS_SatelliteFOV - (0.0005 * FACTOR);
			PXS_SatelliteZoom = PXS_SatelliteZoom + (0.02 * FACTOR);
			call PXS_updateCamera;
		};
	};
	//case 74://Num -
	case ((({_x in _pressedButtonArray} count (actionKeys "ZoomOut")) > 0) || (({_x in _pressedButtonArray} count (actionKeys "MoveUp")) > 0)):
	{
		if ((PXS_SatelliteZoom - (0.02 * FACTOR)) >= 0.1) then
		{
			PXS_SatelliteFOV = PXS_SatelliteFOV + (0.0005 * FACTOR);
			PXS_SatelliteZoom = PXS_SatelliteZoom - (0.02 * FACTOR);
			call PXS_updateCamera;
		};
	};
	default
	{
		_return = false;
	};
};
};
_return;

Edited by chicago

Share this post


Link to post
Share on other sites

Thanks, chicago. Now the major function is OK.

There are still some question:

1:I saw you use "PXS_keyEventHandler = (findDisplay 1000) displayAddEventHandler ["KeyDown","_this call PXS_keyEventFunction"];" However others use "(findDisplay 46) displayAddEventHandler ["KeyDown","_this call PXS_keyEventFunction"];". Is there any difference between display 46 or 1000???Why wiki say 46 is a special number?

2:What's more, what is the meaning or necessarity of "#define FACTOR 50", I never saw this kind of code. Is this same as "FACTOR=50;"?

3:I saw you use "case (({_x in _pressedButtonArray} count (actionKeys "MoveForward")) > 0)", why this code can check key moveforward?? I mean what is the mechanism of ({_x in _pressedButtonArray} count 17) > 0 ??

4: I saw your "KeyFucntion.sqf" has three variable:

_event = _this;

_keyCode = _event select 1;

_return = true;

What is the importance of _return and _event?? I saw other function-sqf just use "nil;" at the end. So I don't understand why you write so.

Thanks a lot.

Edited by Dragon Zen

Share this post


Link to post
Share on other sites

1. The Number 46 is number of main dialog of interface in Arma (Arma 2, etc.). And my number 1000 is number of my dialog which is defined in description.ext file. I was wrong when I said that it is not working with number 46. It works correct. Sorry because of that. You can only define event-handler for own dialog.

2. Yes, it is the same.

3. This mechanism is checking if it was pressed key no.17 (W) or something from "MoveForward" action keys (like arrow or another keys for action of move forward).

4. You also can write "_keyCode = _this select 1;". I don´t remember why I wrote this. And _return is there because when you press the key in no.1 - 5 so this function to not to run commands below.

switch (_keyCode) do
{
case 1://ESC
{
	call PXS_closeCamera;
};
case 2://1 normal view
{
	[2] call PXS_adjustCamera;
};
case 3://2 night vision
{
	[3] call PXS_adjustCamera;
};
case 4://3 white is hot
{
	[4] call PXS_adjustCamera;
};
case 5://4 black is hot
{
	[5] call PXS_adjustCamera;
};
[b]default
{
	_return = false;
};[/b]
};
// key combo handling
[b]if (!(_return)) then[/b]
{
private["_pressedButtonArray"];
_pressedButtonArray = [_keyCode];
_return = true;

// check for key actions
switch (true) do
{
	//case 17://W
	case (({_x in _pressedButtonArray} count (actionKeys "MoveForward")) > 0):
...

Edited by chicago

Share this post


Link to post
Share on other sites

OK, I see, thanks for your help, Chicago.

I think most of functions are OK now.

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  

×