positionCameraToWorld: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Some wiki formatting)
 
(93 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


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


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


| Transform position from camera coordinate space to world coordinate space. |= Description
|game3= arma2oa
____________________________________________________________________________________________
|version3= 1.50


| [[Array]] <nowiki>=</nowiki> '''positionCameraToWorld''' position |= Syntax
|game4= tkoh
|version4= 1.00


|p1= position: [[Array]] - format [[Position]] |= Parameter 1
|game5= arma3
|version5= 0.50


| [[Array]] |= Return value
|gr1= Camera Control
____________________________________________________________________________________________
 
|x1= <pre>_worldPos = positionCameraToWorld _cameraPos</pre> |= Example 1
____________________________________________________________________________________________


| |= See also
|gr2= Positions


}}
|descr= [[File:PositionCameraToWorld.jpg|right|200px]]Get the world coordinate space ({{Link|Position#PositionAGL|AGL}}) from a camera-relative position.<br>
 
 
|s1= [[positionCameraToWorld]] cameraPos


<h3 style="display:none">Notes</h3>
|p1= cameraPos: [[Position#PositionRelative|PositionRelative]] - relative camera position, format '''[x, z, y]''' (X = left-right, Z = below-above, Y = back-front)
<dl class="command_description">
{{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]}}).}}
<!-- Note Section BEGIN -->


<dd class="notedate">Posted on October 17, 2008 - 11:25
|r1= [[Array]] - camera world position, format [[Position#PositionAGL|PositionAGL]]
<dt class="note">'''[[User:Kronzky|Kronzky]]'''
<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:
<pre>if ((positionCameraToWorld [0,0,0] distance player)>2) then {hint "3rd person"} else {hint "1st person"}</pre>


|x1= <sqf>_worldPos = positionCameraToWorld _cameraPos;</sqf>


The camera coordinate system is different from the model coordinate system: when [[modelToWorld]] uses [x, z, y] then positionCameraToWorld uses [x, y, z]. So for a steady camera the following is true:
|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>


positionCameraToWorld [5,10,15] == _camera modelToWorld [5,15,10];
|x3= <sqf>_cameraAGLPosition = positionCameraToWorld [0,0,0];</sqf>


--[[User:Worldeater|Worldeater]] 22:45, 17 October 2010 (CEST)
|seealso= [[modelToWorld]] [[modelToWorldVisual]] [[getCameraViewDirection]] [[weaponDirection]] [[eyeDirection]] [[vectorDir]] [[vectorDirVisual]]
<!-- Note Section END -->
}}
</dl>


<h3 style="display:none">Bottom Section</h3>
{{Note
[[Category:Scripting Commands|POSTIONCAMERATOWORLD]]
|user= Kronzky
[[Category:Scripting Commands ArmA|POSTIONCAMERATOWORLD]]
|timestamp= 20081017112500
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
|text= By measuring the distance between the camera and the player one can determine whether 1st-person or 3rd-person view is being used:
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
<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>
}}

Latest revision as of 00:27, 25 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];