Difference between revisions of "PRIM POSITION"

From Second Life Wiki
Jump to navigation Jump to search
m
 
(23 intermediate revisions by 5 users not shown)
Line 3: Line 3:
{{#vardefine:position_const|{{LSL Const|PRIM_POSITION|integer|6|c=Used to {{GetSet|{{{1|}}}|get|set|/}} the prim's position}}}}
{{#vardefine:position_const|{{LSL Const|PRIM_POSITION|integer|6|c=Used to {{GetSet|{{{1|}}}|get|set|/}} the prim's position}}}}


{{#vardefine:caveats-get|* '''position''' is always in [[Viewer_coordinate_frames#region|region coordinates]], even if the prim is a child or the root prim of an [[attachment]].}}
{{LSL_Function/position|positionget|region=*}}
{{LSL_Function/position|positionset|region=*|local=*}}


{{#vardefine:caveats-set|{{#ifeq:{{{1|}}}|set|**|*}} Depending upon the situation '''position''' may need to be in [[Viewer_coordinate_frames#local|local coordinates]] or [[Viewer_coordinate_frames#region|region coordinates]], See [[llSetPos#Specification]] for details.
{{#vardefine:caveats-get|* {{LSLP|positionget|position}} is always in [[Viewer_coordinate_frames#region|region coordinates]], even if the prim is a child or the root prim of an [[attachment]].}}
{{#ifeq:{{{1|}}}|set|**|*}} The range the prim can move is limited if it is an unattached root prim. The distance is capped to 10m per {{#var:position_const}} call. See [[WarpPos]]. This is a very special case. Do not rely on other tag duplication - the results are undefined, and things *will* break in the future.}}


{{#vardefine:caveats|
{{#vardefine:caveats-set|{{#ifeq:{{{1|}}}|set|**|*}} Depending upon the situation {{LSLP|positionset|position}} may need to be in [[Viewer_coordinate_frames#local|local coordinates]] or [[Viewer_coordinate_frames#region|region coordinates]], See [[llSetPos#Specification]] for details.
{{#switch:{{{1|}}}|set={{#var:caveats}}
{{#ifeq:{{{1|}}}|set|***|**}}It is usually not a good idea to combine [[PRIM_POSITION]] with [[LINK_SET]]. The root will treat the coordinates as world or attachment, while the children will treat them as local, yielding inconsistent results or failure. If you want to move the object as a unit, use [[LINK_ROOT]] instead.
* <span id="Caveats-PRIM_POSITION"></span> {{#var:position_const}} caveats
{{#ifeq:{{{1|}}}|set|**|*}} The range the prim can move is limited if it is an unattached root prim. The distance is capped to 10m per {{#var:position_const}} call. See [[WarpPos]]. This is a very special case. Do not rely on rule duplication of other flags - the results are undefined, and things ''will'' break in the future.
{{#var:caveats-set}}
{{#ifeq:{{{1|}}}|set|**|*}} Moving [[avatar]]s with {{#var:position_const}}
|get={{#var:caveats}}
{{#ifeq:{{{1|}}}|set|***|**}} Moving the prim the avatar sat upon does not move the avatar.
{{#var:caveats-get}}
{{#ifeq:{{{1|}}}|set|***|**}} Moving an avatar does not move the prim they sat upon.
|#default={{#var:caveats}}
{{#ifeq:{{{1|}}}|set|***|**}} Sit-target coordinates do not easily map to prim coordinates, use [[llSitTarget#Useful_Snippets|UpdateSitTarget]].
}}}}
{{#ifeq:{{{1|}}}|set|***|**}} If you have explicitally set your object as "static obstacle" for pathfinding , the function will fail with the error in the debug channel : "Unable to set prim position or scale: object contributes to the navmesh."
{{#ifeq:{{{1|}}}|set|***|**}} If {{LSLP|positionset|position}} is greater than 54 meters away from the center, the repositioning will silently fail.}}


{{#vardefine:p_positionget_desc|position in [[Viewer_coordinate_frames#region|region coordinates]].}}
{{#vardefine:p_positionget_hover|position in region coordinates.}}


{{#vardefine:p_positionset_desc|position in [[Viewer_coordinate_frames#local|local]] or [[Viewer_coordinate_frames#region|regional]] coordinates depending upon the situation.}}
{{#switch:{{{1|}}}|set={{#vardefine:caveats|{{#var:caveats}}
{{#vardefine:p_positionset_hover|position in local or regional coordinates depending upon the situation.}}
* <span id="Caveats-PRIM_POSITION"></span> {{#var:position_const}} caveats
{{#var:caveats-set}}{{#vardefine:caveats-set}}}}
|get={{#vardefine:caveats|{{#var:caveats}}
{{#var:caveats-get}}{{#vardefine:caveats-get}}}}
}}
 
{{#vardefine:PRIM_POSITION/SLPP&A|
Avatars sitting on the object can be moved with [[llSetLinkPrimitiveParams]] and [[PRIM_POSITION]]. This was originally a mis-feature but according to [http://jira.secondlife.com/browse/SVC-3408?focusedCommentId=88574#action_88574 Andrew Linden] LL has decided to support it.
 
=====Examples=====
The below example moves an avatar to x,y,z without moving the prim they are sitting on. If x,y,z is more than 54 meters away the call will silently fail. Remember x,y,z is in object relative coordinates just like any other linked prim in a set.
 
Avatars are always the last prims in the set, so [[llGetNumberOfPrims]] can be used for a single avatar sitting on a vehicle.
 
Example: <source lang="lsl2">llSetLinkPrimitiveParams(llGetNumberOfPrims(), [PRIM_POSITION, <x,y,z>]);</source>
}}


}}</onlyinclude>{{#if:
}}</onlyinclude>{{#if:


}}{{LSL Constant
}}{{LSL Constant
|inject-2={{LSL PrimitiveParam Categorize|Prim}}
|name=PRIM_POSITION
|name=PRIM_POSITION
|type=integer
|type=integer
|value=6
|value=6
|desc=PRIM_POSITION is used to get or set the prim's position.
|desc=PRIM_POSITION is used to get or set the prim's position.
|pa={{LSL Constant/List|i_front=[&#32;{{#var:position_const}},&#32;|i_end=&nbsp;]
|pa={{LSL Constant/List|i_front=[[llSetPrimitiveParams]]([&#32;...,&#32;{{#var:position_const}},&#32;|i_end=,&#32;...&nbsp;]);
|text=When used with [[llSetPrimitiveParams]] & [[llSetLinkPrimitiveParams]]
|text={{LSL Constant/PrimParamText|set}}
===Caveats===
{{LSL Generic/Caveats|caveats={{#var:caveats-set}}|title=*}}
{{#var:caveats-set}}
==={{LSLGC|Avatar|Avatars}}===
{{#var:PRIM_POSITION/SLPP&A}}
|i1_type=vector|i1_name=positionset|i1_disp=position
|i1_type=vector|i1_name=positionset|i1_disp=position
|toc=llSetPrimitiveParams
|toc=llSetPrimitiveParams
}}
}}
|pb={{LSL Constant/List|i_front=[[llGetPrimitiveParams]]([&nbsp;{{#var:position_const}}|i_end=&nbsp;]);|
|pb={{LSL Constant/List|i_front=[[llGetPrimitiveParams]]([&#32;...,&#32;{{#var:position_const}}|i_end=,&#32;...&nbsp;]);|
|r_front=Returns the list [&nbsp;|r_end=&nbsp;]
|r_front=Returns the list [&nbsp;|r_end=&nbsp;]
|text=
|text={{LSL Constant/PrimParamText|get}}
===Caveats===
{{LSL Generic/Caveats|caveats={{#var:caveats-get}}|title=*}}
{{#var:caveats-get}}
|r1_type=vector|r1_name=positionget|r1_disp=position
|r1_type=vector|r1_name=positionget|r1_disp=position
|toc=llGetPrimitiveParams
|toc=llGetPrimitiveParams
Line 47: Line 62:
|examples
|examples
|constants=
|constants=
<!--{{LSL ConstRow|CHANGED_SHAPE}}-->
{{LSL ConstRow|PRIM_ROTATION}}
|functions=
|functions=
{{LSL DefineRow||[[llGetPrimitiveParams]]|}}
{{LSL DefineRow||[[llGetPrimitiveParams]]|}}
Line 57: Line 72:
{{LSL DefineRow||[[llGetRootPosition]]|}}
{{LSL DefineRow||[[llGetRootPosition]]|}}
{{LSL DefineRow||[[llGetObjectDetails]]|}}
{{LSL DefineRow||[[llGetObjectDetails]]|}}
|events=
|events
<!--{{LSL DefineRow||[[changed]]|}}-->
|articles=
|articles=
{{LSL DefineRow||[[warpPos]]|}}
{{LSL DefineRow||[[warpPos]]|}}
{{LSL DefineRow||[[PosJump]]|}}
|location
|location
|cat1=Prim
|cat1
|cat2=Movement
|cat2=Movement
|cat3
|cat3
|cat4
|cat4
}}
}}

Latest revision as of 13:05, 8 September 2015

Description

Constant: integer PRIM_POSITION = 6;

The integer constant PRIM_POSITION has the value 6

PRIM_POSITION is used to get or set the prim's position.

llSetPrimitiveParams

llSetPrimitiveParams([ ..., PRIM_POSITION, vector position, ... ]);
• vector position position in region or local coordinates depending upon the situation

The same syntax applies to llSetLinkPrimitiveParams and llSetLinkPrimitiveParamsFast but with an additional prefixed link parameter in the function call.

Caveats

  • Depending upon the situation position may need to be in local coordinates or region coordinates, See llSetPos#Specification for details.
    • It is usually not a good idea to combine PRIM_POSITION with LINK_SET. The root will treat the coordinates as world or attachment, while the children will treat them as local, yielding inconsistent results or failure. If you want to move the object as a unit, use LINK_ROOT instead.
  • The range the prim can move is limited if it is an unattached root prim. The distance is capped to 10m per PRIM_POSITION call. See WarpPos. This is a very special case. Do not rely on rule duplication of other flags - the results are undefined, and things will break in the future.
  • Moving avatars with PRIM_POSITION
    • Moving the prim the avatar sat upon does not move the avatar.
    • Moving an avatar does not move the prim they sat upon.
    • Sit-target coordinates do not easily map to prim coordinates, use UpdateSitTarget.
    • If you have explicitally set your object as "static obstacle" for pathfinding , the function will fail with the error in the debug channel : "Unable to set prim position or scale: object contributes to the navmesh."
    • If position is greater than 54 meters away from the center, the repositioning will silently fail.


Avatars

Avatars sitting on the object can be moved with llSetLinkPrimitiveParams and PRIM_POSITION. This was originally a mis-feature but according to Andrew Linden LL has decided to support it.

Examples

The below example moves an avatar to x,y,z without moving the prim they are sitting on. If x,y,z is more than 54 meters away the call will silently fail. Remember x,y,z is in object relative coordinates just like any other linked prim in a set.

Avatars are always the last prims in the set, so llGetNumberOfPrims can be used for a single avatar sitting on a vehicle.

Example:
llSetLinkPrimitiveParams(llGetNumberOfPrims(), [PRIM_POSITION, <x,y,z>]);

llGetPrimitiveParams

llGetPrimitiveParams([ ..., PRIM_POSITION, ... ]);

Returns the list [ vector position ]

• vector position position in region coordinates

The same syntax applies to llGetLinkPrimitiveParams, but with an additional prefixed link parameter in the function call.

Caveats

Caveats


Related Articles

Constants

•  PRIM_ROTATION

Functions

•  llGetPrimitiveParams
•  llSetPrimitiveParams
•  llSetLinkPrimitiveParams
•  llGetPos
•  llSetPos
•  llGetLocalPos
•  llGetRootPosition
•  llGetObjectDetails

Articles

•  warpPos

Deep Notes

Search JIRA for related Issues

Signature

integer PRIM_POSITION = 6;