positionCameraToWorld: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\[\[Category:[ _]?Scripting[ _]Commands[ _]Arma[ _]3(\|.*)\]\]" to "{{GameCategory|arma3|Scripting Commands}}")
m (Some wiki formatting)
 
(65 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| arma1 |Game name=
|game1= arma1
|version1= 1.00


|1.00|Game version=
|game2= arma2
|version2= 1.00


|gr1 = Camera Control |GROUP1=
|game3= arma2oa
|version3= 1.50


|gr2 = Positions |GROUP2=
|game4= tkoh
____________________________________________________________________________________________
|version4= 1.00


|[[File:PositionCameraToWorld.jpg|right|120x120px]]Transforms position from camera coordinate space to world coordinate space.  
|game5= arma3
|version5= 0.50


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=
|gr1= Camera Control
____________________________________________________________________________________________


| '''positionCameraToWorld''' cameraPos |SYNTAX=
|gr2= Positions


|p1= cameraPos: [[PositionRelative]] - Relative camera position, format [x, z, y]<br><br>
|descr= [[File:PositionCameraToWorld.jpg|right|200px]]Get the world coordinate space ({{Link|Position#PositionAGL|AGL}}) from a camera-relative position.<br>
{{Important | Note that y and z for this command are swapped around, which is different from your usual model space coordinates format}} |PARAMETER1=


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


|x2= Example demonstrating reversed y and z:<code>[[player]] [[setDir]] 0; //assuming player is looking forward
|s1= [[positionCameraToWorld]] cameraPos
[[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]]
</code> |EXAMPLE2=
____________________________________________________________________________________________


| [[modelToWorld]], [[modelToWorldVisual]], [[getCameraViewDirection]], [[weaponDirection]], [[eyeDirection]], [[vectorDir]], [[vectorDirVisual]] |SEEALSO=
|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]] - camera world position, format [[Position#PositionAGL|PositionAGL]]
|x1= <sqf>_worldPos = positionCameraToWorld _cameraPos;</sqf>
|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]]
}}
}}


<h3 style="display:none">Notes</h3>
{{Note
<dl class="command_description">
|user= Kronzky
<!-- Note Section BEGIN -->
|timestamp= 20081017112500
<dd class="notedate">Posted on October 17, 2008 - 11:25
|text= By measuring the distance between the camera and the player one can determine whether 1st-person or 3rd-person view is being used:
<dt class="note">[[User:Kronzky|Kronzky]]
<sqf>if ((positionCameraToWorld [0,0,0] distance player)>2) then { hint "3rd person" } else { hint "1st person" };</sqf>
<dd class="note">
}}
By measuring the distance between the camera and the player one can determine whether 1st-person or 3rd-person view is being used:
<code>[[if]] (([[positionCameraToWorld]] [0,0,0] [[distance]] [[player]])>2) [[then]] {[[hint]] "3rd person"} [[else]] {[[hint]] "1st person"};</code>
<dd class="notedate">Posted on 22:45, 17 October 2010 (CEST)
<dt class="note">[[User:Worldeater|Worldeater]]<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:
<code>[[positionCameraToWorld]] [5,10,15] == _camera [[modelToWorld]] [5,15,10];</code>
<!-- Note Section END -->
</dl>


<h3 style="display:none">Bottom Section</h3>
{{Note
[[Category:Scripting Commands|POSTIONCAMERATOWORLD]]
|user= Worldeater
{{GameCategory|arma1|Scripting Commands}}
|timestamp= 20101017224500
[[Category:Scripting Commands Arma 2|{{uc:{{PAGENAME}}}}]]
|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:
{{GameCategory|arma3|Scripting Commands}}
<sqf>positionCameraToWorld [5,10,15] == _camera modelToWorld [5,15,10];</sqf>
[[Category:Scripting Commands Take On Helicopters|{{uc:{{PAGENAME}}}}]]
}}
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<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 [[PositionATL]], and over sea, [[PositionASLW]].
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 23:27, 24 March 2024

Hover & click on the images for description

Description

Description:
PositionCameraToWorld.jpg
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)
This command has Y and Z axes swapped around, which is different from the usual model space coordinates format ([x, y, z]).
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] ] */
Example 3:
_cameraAGLPosition = positionCameraToWorld [0,0,0];

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];