positionCameraToWorld: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "<dd class="note">([^}]*)<code>([^<]*)<\/code>" to "<dd class="note">$1<sqf>$2</sqf>")
m (Some wiki formatting)
Line 33: Line 33:


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


|seealso= [[modelToWorld]] [[modelToWorldVisual]] [[getCameraViewDirection]] [[weaponDirection]] [[eyeDirection]] [[vectorDir]] [[vectorDirVisual]]
|seealso= [[modelToWorld]] [[modelToWorldVisual]] [[getCameraViewDirection]] [[weaponDirection]] [[eyeDirection]] [[vectorDir]] [[vectorDirVisual]]
}}
}}


<dl class="command_description">
{{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>
}}


<dt></dt>
{{Note
<dd class="notedate">Posted on October 17, 2008 - 11:25</dd>
|user= Worldeater
<dt class="note">[[User:Kronzky|Kronzky]]</dt>
|timestamp= 20101017224500
<dd class="note">
|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:
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>
<dd class="notedate">Posted on 22:45, 17 October 2010 (CEST)</dd>
<dt class="note">[[User:Worldeater|Worldeater]]</dt>
<dd class="note">
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>
<sqf>positionCameraToWorld [5,10,15] == _camera modelToWorld [5,15,10];</sqf>
 
}}
<dt></dt>
<dd class="notedate">Posted on July 20, 2014 - 20:07 (UTC)</dd>
<dt class="note">[[User:AgentRevolution|AgentRev]]</dt>
<dd class="note">
When over land, the position returned is in format [[Position#PositionATL|PositionATL]], and over sea, [[Position#PositionASLW|PositionASLW]].
</dd>
 
</dl>

Revision as of 19:50, 13 May 2022

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:
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
Kronzky - c
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:
if ((positionCameraToWorld [0,0,0] distance player)>2) then { hint "3rd person" } else { hint "1st person" };
Worldeater - c
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:
positionCameraToWorld [5,10,15] == _camera modelToWorld [5,15,10];