positionCameraToWorld: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "<code>([^ ]*)\[\[([a-zA-Z][a-zA-Z0-9_]+)\]\]([^ ]*)<\/code>" to "<code>$1$2$3</code>") |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
(14 intermediate revisions by the same user not shown) | |||
Line 20: | Line 20: | ||
|gr2= Positions | |gr2= Positions | ||
|descr=[[File:PositionCameraToWorld.jpg|right| | |descr= [[File:PositionCameraToWorld.jpg|right|200px]]Get the world coordinate space ({{Link|Position#PositionAGL|AGL}}) from a camera-relative position.<br> | ||
|s1= [[positionCameraToWorld]] cameraPos | |s1= [[positionCameraToWorld]] cameraPos | ||
|p1= cameraPos: [[Position#PositionRelative|PositionRelative]] - | |p1= cameraPos: [[Position#PositionRelative|PositionRelative]] - relative camera position, format '''[x, z, y]''' (X = left-right, Z = below-above, Y = back-front) | ||
{{Feature|important|This command has Y and Z axes swapped around, which is different from the usual model space coordinates format ({{Link|Position|[x, y, z]}}).}} | |||
|r1= [[Array]] - | |r1= [[Array]] - camera world position, format [[Position#PositionAGL|PositionAGL]] | ||
|x1= <sqf>_worldPos = positionCameraToWorld _cameraPos;</sqf> | |x1= <sqf>_worldPos = positionCameraToWorld _cameraPos;</sqf> | ||
|x2= Example demonstrating reversed | |x2= Example demonstrating reversed Y and Z: | ||
< | <sqf> | ||
player setDir 0; // assuming player is looking forward | |||
/ | hint str [positionCameraToWorld [0,0,0], positionCameraToWorld [0,0,1]]; | ||
</ | /* | ||
[ | |||
[2481.35, 5671.21, 1.51395], | |||
[2481.35, 5672.21, 1.46955] | |||
] | |||
*/ | |||
</sqf> | |||
|x3= <sqf>_cameraAGLPosition = positionCameraToWorld [0,0,0];</sqf> | |||
|seealso= [[modelToWorld]] [[modelToWorldVisual]] [[getCameraViewDirection]] [[weaponDirection]] [[eyeDirection]] [[vectorDir]] [[vectorDirVisual]] | |seealso= [[modelToWorld]] [[modelToWorldVisual]] [[getCameraViewDirection]] [[weaponDirection]] [[eyeDirection]] [[vectorDir]] [[vectorDirVisual]] | ||
}} | }} | ||
< | {{Note | ||
|user= Kronzky | |||
|timestamp= 20081017112500 | |||
|text= By measuring the distance between the camera and the player one can determine whether 1st-person or 3rd-person view is being used: | |||
<sqf>if ((positionCameraToWorld [0,0,0] distance player)>2) then { hint "3rd person" } else { hint "1st person" };</sqf> | |||
}} | |||
{{Note | |||
|user= Worldeater | |||
|timestamp= 20101017224500 | |||
|text= The camera coordinate system is different from the model coordinate system: when [[modelToWorld]] uses [x, y, z] then positionCameraToWorld uses [x, z, y]. So for a steady camera the following is true: | |||
<sqf>positionCameraToWorld [5,10,15] == _camera modelToWorld [5,15,10];</sqf> | |||
}} | |||
The camera coordinate system is different from the model coordinate system: when [[modelToWorld]] uses [x, y, z] then positionCameraToWorld uses [x, z, y]. So for a steady camera the following is true: | |||
< | |||
Latest revision as of 23:27, 24 March 2024
Description
- Description:
- Get the world coordinate space (AGL) from a camera-relative position.
- Groups:
- Camera ControlPositions
Syntax
- Syntax:
- positionCameraToWorld cameraPos
- Parameters:
- cameraPos: PositionRelative - relative camera position, format [x, z, y] (X = left-right, Z = below-above, Y = back-front)
- Return Value:
- Array - camera world position, format PositionAGL
Examples
- Example 1:
- Example 2:
- Example demonstrating reversed Y and Z:
- Example 3:
Additional Information
- See also:
- modelToWorld modelToWorldVisual getCameraViewDirection weaponDirection eyeDirection vectorDir vectorDirVisual
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
- Posted on Oct 17, 2008 - 11:25 (UTC)
- By measuring the distance between the camera and the player one can determine whether 1st-person or 3rd-person view is being used:
- Posted on Oct 17, 2010 - 22:45 (UTC)
-
The camera coordinate system is different from the model coordinate system: when modelToWorld uses [x, y, z] then positionCameraToWorld uses [x, z, y]. So for a steady camera the following is true:
Categories:
- Scripting Commands
- Introduced with Armed Assault version 1.00
- ArmA: Armed Assault: New Scripting Commands
- ArmA: Armed Assault: Scripting Commands
- Arma 2: Scripting Commands
- Arma 2: Operation Arrowhead: Scripting Commands
- Take On Helicopters: Scripting Commands
- Arma 3: Scripting Commands
- Command Group: Camera Control
- Command Group: Positions