positionCameraToWorld: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(description updated)
m (note format)
Line 36: Line 36:
<dl class="command_description">
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section BEGIN -->
<dd class="notedate">Posted on October 17, 2008 - 11:25
<dd class="notedate">Posted on October 17, 2008 - 11:25
<dt class="note">'''[[User:Kronzky|Kronzky]]'''
<dt class="note">'''[[User:Kronzky|Kronzky]]'''
Line 42: Line 41:
By measuring the distance between the camera and the player one can determine whether 1st-person or 3rd-person view is being used:
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>
<pre>if ((positionCameraToWorld [0,0,0] distance player)>2) then {hint "3rd person"} else {hint "1st person"}</pre>
 
<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:
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>
positionCameraToWorld [5,10,15] == _camera modelToWorld [5,15,10];
 
--[[User:Worldeater|Worldeater]] 22:45, 17 October 2010 (CEST)
<!-- Note Section END -->
<!-- Note Section END -->
</dl>
</dl>

Revision as of 14:38, 8 June 2014

-wrong parameter ("Arma") defined!-1.00
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:
Uncategorised

Syntax

Syntax:
worldPos = positionCameraToWorld cameraPos
Parameters:
cameraPos: Array - Relative camera position, format [x, z, y] NOTE: y and z are swapped around, different from your usual model space coordinates format
Return Value:
worldPos: Array - Camera world position, format Position

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:
See also needed

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