modelToWorld: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "PositionRelative" to "PositionRelative") |
Lou Montana (talk | contribs) (Clear up World pos vs AGL pos) |
||
Line 15: | Line 15: | ||
|game5= arma3 | |game5= arma3 | ||
|version5= 0.50 | |version5= 0.50 | ||
|arg= global | |||
|gr1= Positions | |gr1= Positions | ||
|descr= Translates relative position from object model space | |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]] | For the ASL 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> | {{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, {{ic|_obj modelToWorld [0,1,0]}} will be offset '''2 meters''' from the model center ({{ic|[0,0,0]}}). | For example, if the object scale is 2, {{ic|_obj modelToWorld [0,1,0]}} will be offset '''2 meters''' from the model center ({{ic|[0,0,0]}}).}} | ||
}} | |||
|s1= model [[modelToWorld]] position | |s1= model [[modelToWorld]] position | ||
Line 29: | Line 31: | ||
|p1= model: [[Object]] | |p1= model: [[Object]] | ||
|p2= position: [[Position]] - [x,y,z] offset relative to the model centre | |p2= position: [[Array]] format [[Position#PositionRelative|PositionRelative]] - [x,y,z] offset relative to the model centre | ||
|r1= [[Array]] | |r1= [[Array]] format [[Position#PositionAGL|PositionAGL]] - translated world position | ||
|x1= <code>_aboveAndBehindPlayer = [[player]] [[modelToWorld]] [0,-1,3];</code> | |x1= <code>_aboveAndBehindPlayer = [[player]] [[modelToWorld]] [0,-1,3];</code> | ||
Line 38: | Line 40: | ||
}} | }} | ||
{{Note | |||
|user= Dr_Eyeball | |||
|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> | |||
'''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]; | <code>_offset = [_x,_y,_z]; | ||
_worldPos = _relObj modelToWorld _offset; | _worldPos = _relObj modelToWorld _offset; | ||
_obj setPos _worldPos;</code> | _obj setPos _worldPos;</code> | ||
}} | |||
{{Note | |||
|user= ManDay | |||
|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 {{Wikipedia|Cross_product|vectorDir x VectorUp}} (meaning as the X-Axis in a {{Wikipedia|Cartesian_coordinate_system#In_three_dimensions|right-handed cartesian coordiante system}}). | while its X-Axis goes along {{Wikipedia|Cross_product|vectorDir x VectorUp}} (meaning as the X-Axis in a {{Wikipedia|Cartesian_coordinate_system#In_three_dimensions|right-handed cartesian coordiante system}}). | ||
}} | |||
{{Note | |||
|user= Dr_Eyeball | |||
|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; | <code>_ladder [[setDir]] _angle; | ||
_ladder [[setPosATL]] (_building modelToWorld [_x, _y, _z]);</code> | |||
}} | |||
{{Note | |||
|user= Hduregger | |||
|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> | <code>_obj [[modelToWorld]] [0.0, 0.0, 0.0]</code> | ||
is '''not''' the same as <code>getPos _obj</code>. | is '''not''' the same as <code>[[getPos]] _obj</code>. | ||
}} | |||
Revision as of 14:51, 10 January 2022
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 ASL version of this command, see modelToWorldWorld. - 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:
- vectorModelToWorldmodelToWorldVisualworldToModelmodelToWorldWorldmodelToWorldVisualWorldselectionPosition
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
- 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;
- 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).
- 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]);
- 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 asgetPos _obj
.
Categories:
- Scripting Commands
- Introduced with Armed Assault version 1.00
- ArmA: Armed Assault: New Scripting Commands
- ArmA: Armed Assault: Scripting Commands
- Arma 2: Scripting Commands
- Arma 2: Operation Arrowhead: Scripting Commands
- Take On Helicopters: Scripting Commands
- Arma 3: Scripting Commands
- Command Group: Positions