positionCameraToWorld: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "_{10,} " to "")
m (Text replacement - " *\| *([Cc]omments|COMMENTS|Game|[Gg]ame [Nn]ame|Game [Vv]ersion|Game Version \(number surrounded by NO SPACES\)|Multiplayer Arguments( \("local" or "global"\))?|Effects|Multiplayer Effects( \("local" or "global"\))?|Multiplayer Exe...)
Line 1: Line 1:
{{Command|Comments=
{{Command


| arma1 |Game name=
| arma1


|1.00|Game version=
|1.00


|gr1 = Camera Control |GROUP1=
|gr1 = Camera Control


|gr2 = Positions |GROUP2=
|gr2 = Positions


|[[File:PositionCameraToWorld.jpg|right|120x120px]]Transforms position from camera coordinate space to world coordinate space.  
|[[File:PositionCameraToWorld.jpg|right|120x120px]]Transforms position from camera coordinate space to world coordinate space.  


Camera axes are relative to camera orientation. x axis goes from left of the camera to right of the camera, z axis goes from underneath the camera to above the camera and y axis goes from back of the camera to where the camera is looking. |DESCRIPTION=
Camera axes are relative to camera orientation. x axis goes from left of the camera to right of the camera, z axis goes from underneath the camera to above the camera and y axis goes from back of the camera to where the camera is looking.


| '''positionCameraToWorld''' cameraPos |SYNTAX=
| '''positionCameraToWorld''' cameraPos


|p1= cameraPos: [[PositionRelative]] - Relative camera position, format [x, z, y]<br><br>
|p1= cameraPos: [[PositionRelative]] - Relative camera position, format [x, z, y]<br><br>
{{Important | Note that y and z for this command are swapped around, which is different from your usual model space coordinates format}} |PARAMETER1=
{{Important | Note that y and z for this command are swapped around, which is different from your usual model space coordinates format}}


| [[Array]] - Camera world position, format [[PositionAGL]] |RETURNVALUE=
| [[Array]] - Camera world position, format [[PositionAGL]]
   
   
|x1= <code>_worldPos = [[positionCameraToWorld]] _cameraPos;</code> |EXAMPLE1=
|x1= <code>_worldPos = [[positionCameraToWorld]] _cameraPos;</code>


|x2= Example demonstrating reversed y and z:<code>[[player]] [[setDir]] 0; //assuming player is looking forward
|x2= Example demonstrating reversed y and z:<code>[[player]] [[setDir]] 0; //assuming player is looking forward
[[hint]] [[str]] [<nowiki/>[[positionCameraToWorld]] [0,0,0], [[positionCameraToWorld]] [0,0,1]];
[[hint]] [[str]] [<nowiki/>[[positionCameraToWorld]] [0,0,0], [[positionCameraToWorld]] [0,0,1]];
//[[2481.35,567'''1'''.21,1.51395],[2481.35,567'''2'''.21,1.46955]]
//[[2481.35,567'''1'''.21,1.51395],[2481.35,567'''2'''.21,1.46955]]
</code> |EXAMPLE2=
</code>


| [[modelToWorld]], [[modelToWorldVisual]], [[getCameraViewDirection]], [[weaponDirection]], [[eyeDirection]], [[vectorDir]], [[vectorDirVisual]] |SEEALSO=
| [[modelToWorld]], [[modelToWorldVisual]], [[getCameraViewDirection]], [[weaponDirection]], [[eyeDirection]], [[vectorDir]], [[vectorDirVisual]]


}}
}}

Revision as of 02:22, 18 January 2021

Hover & click on the images for description

Description

Description:
PositionCameraToWorld.jpg
Transforms position from camera coordinate space to world coordinate space. Camera axes are relative to camera orientation. x axis goes from left of the camera to right of the camera, z axis goes from underneath the camera to above the camera and y axis goes from back of the camera to where the camera is looking.
Groups:
Camera ControlPositions

Syntax

Syntax:
positionCameraToWorld cameraPos
Parameters:
cameraPos: PositionRelative - Relative camera position, format [x, z, y]

Note that y and z for this command are swapped around, which is different from your usual model space coordinates format
Return Value:
Array - Camera world position, format PositionAGL

Examples

Example 1:
_worldPos = positionCameraToWorld _cameraPos;
Example 2:
Example demonstrating reversed y and z: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]]

Additional Information

See also:
modelToWorldmodelToWorldVisualgetCameraViewDirectionweaponDirectioneyeDirectionvectorDirvectorDirVisual

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

Notes

Posted on October 17, 2008 - 11:25
Kronzky
By measuring the distance between the camera and the player one can determine whether 1st-person or 3rd-person view is being used: if ((positionCameraToWorld [0,0,0] distance player)>2) then {hint "3rd person"} else {hint "1st person"};
Posted on 22:45, 17 October 2010 (CEST)
Worldeater
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: positionCameraToWorld [5,10,15] == _camera modelToWorld [5,15,10];

Bottom Section

Posted on July 20, 2014 - 20:07 (UTC)
AgentRev
When over land, the position returned is in format PositionATL, and over sea, PositionASLW.