modelToWorld: 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 (Text replacement - "\{\{ *Wikipedia *\| *([-a-zA-Z0-9_#':%\/\\]+) *\| *([-a-zA-Z0-9_#':%\/\\ ]+) *\}\}" to "{{Link|https://en.wikipedia.org/wiki/$1|$2}}")
 
(45 intermediate revisions by 3 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= Positions |GROUP1=
|game3= arma2oa
____________________________________________________________________________________________
|version3= 1.50


| Translates relative position from object model space into world position.<br>
|game4= tkoh
|version4= 1.00
 
|game5= arma3
|version5= 0.50
 
|arg= global
 
|gr1= Positions
 
|descr= Translates relative position from object model space to world space in [[Position#PositionAGL|PositionAGL]] format.<br>
This command will take into account [[vectorUp]] of the object when calculating relative coordinates.
This command will take into account [[vectorUp]] of the object when calculating relative coordinates.
For ASL version see [[modelToWorldWorld]] |Description=
For the [[Position#PositionASL|PositionASL]] version of this command, see [[modelToWorldWorld]].
____________________________________________________________________________________________
 
{{Feature|important|For [[setObjectScale|scaled objects]], the relative position will first be [[vectorMultiply|multiplied]] by the object scale.<br>
For example, if the object scale is 2, <sqf inline>_obj modelToWorld [0,1,0]</sqf> will be offset '''2 meters''' from the model center (<sqf inline>[0,0,0]</sqf>).}}
 
|s1= model [[modelToWorld]] position


| model [[modelToWorld]] position |Syntax=
|p1= model: [[Object]]


|p1= model: [[Object]] |Parameter 1=
|p2= position: [[Array]] format [[Position#PositionRelative|PositionRelative]] - [x,y,z] offset relative to the model centre


|p2= position: [[Position]] - [x,y,z] offset relative to the model centre, format [[PositionRelative]] |Parameter 2=
|r1= [[Array]] format [[Position#PositionAGL|PositionAGL]] - translated world position


| [[Array]] - translated world position, format [[PositionAGL]] |Return value=
|x1= <sqf>_aboveAndBehindPlayer = player modelToWorld [0,-1,3];</sqf>
____________________________________________________________________________________________
|x1= <code>_aboveAndBehindPlayer = [[player]] [[modelToWorld]] [0,-1,3];</code> |Example 1=


| [[vectorModelToWorld]], [[modelToWorldVisual]], [[worldToModel]], [[modelToWorldWorld]], [[modelToWorldVisualWorld]], [[selectionPosition]] |See also=
|seealso= [[vectorModelToWorld]] [[modelToWorldVisual]] [[worldToModel]] [[modelToWorldWorld]] [[modelToWorldVisualWorld]] [[selectionPosition]]
}}
}}


<h3 style="display:none">Notes</h3>
{{Note
<dl class="command_description">
|user= Dr_Eyeball
<!-- Note Section BEGIN -->
|timestamp= 20070218015500
 
|text= The ''worldPos'' parameter appears to be a relative offset to the position of ''object'', so it can often simply be [0,0,0].<BR>
<dd class="notedate">Posted on 16 Feb, 2007
<dt class="note">[[User:Dr_Eyeball|Dr_Eyeball]]
<dd class="note">The ''worldPos'' parameter appears to be a relative offset to the position of ''object'', so it can often simply be [0,0,0].<BR>
'''Example:''' to position an object ''_obj'' relative to the position of another object ''_relObj'' with on offset of ''_offset'', try:
'''Example:''' to position an object ''_obj'' relative to the position of another object ''_relObj'' with on offset of ''_offset'', try:
<code>_offset = [_x,_y,_z];
<sqf>_offset = [_x,_y,_z];
_worldPos = _relObj modelToWorld _offset;
_worldPos = _relObj modelToWorld _offset;
_obj setPos _worldPos;</code>
_obj setPos _worldPos;</sqf>
 
}}


<dd class="notedate">Posted on 16 Feb, 2007
{{Note
<dt class="note">[[User:Manny|Manny]]
|user= ManDay
<dd class="note">The object model space has got its Z-Axis along the object's [[vectorUp]],
|timestamp= 20070724174500
|text= The object model space has got its Z-Axis along the object's [[vectorUp]],
its Y-Axis along the object's [[vectorDir]],
its Y-Axis along the object's [[vectorDir]],
while its X-Axis goes along [http://en.wikipedia.org/wiki/Cross_product vectorDir x VectorUp] (meaning as the X-Axis in a [http://en.wikipedia.org/wiki/Cartesian_coordinate_system#In_three_dimensions right-handed cartesian coordiante system]).
while its X-Axis goes along {{Link|https://en.wikipedia.org/wiki/Cross_product|vectorDir x VectorUp}} (meaning as the X-Axis in a {{Link|https://en.wikipedia.org/wiki/Cartesian_coordinate_system#In_three_dimensions|right-handed cartesian coordiante system}}).
 
}}


<dd class="notedate">Posted on 8 May, 2008
{{Note
<dt class="note">[[User:Dr_Eyeball|Dr_Eyeball]]
|user= Dr_Eyeball
<dd class="note">If your object requires a new direction, ensure you call [[setDir]] ''prior'' to [[setPos]] when using [[modelToWorld]].
|timestamp= 20080508080500
|text= If your object requires a new direction, ensure you call [[setDir]] ''prior'' to [[setPosATL]] when using [[modelToWorld]].
Calling setDir afterwards will skew its position otherwise.
Calling setDir afterwards will skew its position otherwise.
<code>_ladder setDir _angle;
<sqf>_ladder setDir _angle;
_ladder setPos (_building modelToWorld [_x, _y, _z]);</code>
_ladder setPosATL (_building modelToWorld [_x, _y, _z]);</sqf>
 
}}


<dd class="notedate">Posted on 6 Feb, 2011
{{Note
<dt class="note">[[User:Hduregger|Hduregger]]
|user= Hduregger
<dd class="note">The z height returned changes dynamically with the height of waves beneath the object, if the object is located over sea.
|timestamp= 20110206204100
|text= The z height returned changes dynamically with the height of waves beneath the object, if the object is located over sea.
The z height returned by [[getPosATL]] and [[getPosASL]] does not change like this.
The z height returned by [[getPosATL]] and [[getPosASL]] does not change like this.
This was tested by continuously retrieving the position of a static object, like the cross in the empty/corpses category, placed over sea or land.
This was tested by continuously retrieving the position of a static object, like the cross in the empty/corpses category, placed over sea or land.
[[modelToWorld]] behaves similar to [[getPos]] but it does not give the same result, therefore
[[modelToWorld]] behaves similar to [[getPos]] but it does not give the same result, therefore
<code>_obj modelToWorld [0.0, 0.0, 0.0]</code>
<sqf>_obj modelToWorld [0.0, 0.0, 0.0]</sqf>
is '''not''' the same as <code>getPos _obj</code>.
is '''not''' the same as <sqf>getPos _obj;</sqf>.
 
}}
<!-- Note Section END -->
</dl>
 
<h3 style="display:none">Bottom Section</h3>
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
{{GameCategory|arma1|Scripting Commands}}
[[Category:Scripting Commands Arma 2|{{uc:{{PAGENAME}}}}]]
{{GameCategory|arma3|Scripting Commands}}
[[Category:Scripting Commands Take On Helicopters|{{uc:{{PAGENAME}}}}]]

Latest revision as of 01:47, 24 February 2023

Hover & click on the images for description

Description

Description:
Translates relative position from object model space to world space in PositionAGL format.
This command will take into account vectorUp of the object when calculating relative coordinates. For the PositionASL version of this command, see modelToWorldWorld.
For scaled objects, the relative position will first be multiplied by the object scale.
For example, if the object scale is 2, _obj modelToWorld [0,1,0] will be offset 2 meters from the model center ([0,0,0]).
Groups:
Positions

Syntax

Syntax:
model modelToWorld position
Parameters:
model: Object
position: Array format PositionRelative - [x,y,z] offset relative to the model centre
Return Value:
Array format PositionAGL - translated world position

Examples

Example 1:
_aboveAndBehindPlayer = player modelToWorld [0,-1,3];

Additional Information

See also:
vectorModelToWorld modelToWorldVisual worldToModel modelToWorldWorld modelToWorldVisualWorld selectionPosition

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
Dr_Eyeball - c
Posted on Feb 18, 2007 - 01:55 (UTC)
The worldPos parameter appears to be a relative offset to the position of object, so it can often simply be [0,0,0].
Example: to position an object _obj relative to the position of another object _relObj with on offset of _offset, try:
_offset = [_x,_y,_z]; _worldPos = _relObj modelToWorld _offset; _obj setPos _worldPos;
ManDay - c
Posted on Jul 24, 2007 - 17:45 (UTC)
The object model space has got its Z-Axis along the object's vectorUp, its Y-Axis along the object's vectorDir, while its X-Axis goes along vectorDir x VectorUp (meaning as the X-Axis in a right-handed cartesian coordiante system).
Dr_Eyeball - c
Posted on May 08, 2008 - 08:05 (UTC)
If your object requires a new direction, ensure you call setDir prior to setPosATL when using modelToWorld. Calling setDir afterwards will skew its position otherwise.
_ladder setDir _angle; _ladder setPosATL (_building modelToWorld [_x, _y, _z]);
Hduregger - c
Posted on Feb 06, 2011 - 20:41 (UTC)
The z height returned changes dynamically with the height of waves beneath the object, if the object is located over sea. The z height returned by getPosATL and getPosASL does not change like this. This was tested by continuously retrieving the position of a static object, like the cross in the empty/corpses category, placed over sea or land. modelToWorld behaves similar to getPos but it does not give the same result, therefore
_obj modelToWorld [0.0, 0.0, 0.0]
is not the same as
getPos _obj;
.