Difference between revisions of "LlSetLinkTextureAnim"

From Second Life Wiki
Jump to navigation Jump to search
m ('inject's allow the templates to be called mid way through the base template instead of at the beginning, this means they can mooch internal values.)
(18 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{LSL_Function/face|face}}{{LSL_Function
{{LSL_Function
|inject-1=
|inject-2=
{{LSL_Generic/pre-release|function|server-release=1.38.0}}
{{LSL_Function/link|link}}
{{LSL_Function/link|link}}
{{LSL_Function/face|face}}
{{Issues/SVC-3925}}
{{Issues/SVC-3925}}
{{Issues/SVC-1242}}
{{Issues/SVC-1242}}
{{Issues/VWR-4018}}
{{Issues/VWR-4018}}
|inject-2=
|inject-3=
{{LSL_Function/negative index|true|start|length={{LSL Param|length}}}}
{{LSL_Function/negative index|true|start|length={{LSLPT|length}}}}
|func_id
|func_id=356
|func_sleep=0.0
|func_sleep=0.0
|func_energy=10.0
|func_energy=10.0
|sort=SetLinkTextureAnim
|sort=SetLinkTextureAnim
|func=llSetLinkTextureAnim
|func=llSetLinkTextureAnim
|p1_type=integer|p1_name=link|p1_desc=to effect|p1_hover=to effect
|p1_type=integer|p1_subtype=link|p1_name=link|p1_desc=to effect|p1_hover=to effect
|p2_type=integer|p2_name=mode|p2_desc=mask of Mode flags
|p2_type=integer|p2_subtype=bit_field|p2_name=mode|p2_desc=bit field of Mode flags
|p3_type=integer|p3_name=face
|p3_type=integer|p3_name=face
|p4_type=integer|p4_name=sizex|p4_desc=horizontal frames (ignored for [[ROTATE]] and [[SCALE]])
|p4_type=integer|p4_name=sizex|p4_desc=horizontal frames (ignored for [[ROTATE]] and [[SCALE]])
Line 20: Line 20:
|p6_type=float|p6_name=start|p6_desc=Start position/frame number (or radians for [[ROTATE]])
|p6_type=float|p6_name=start|p6_desc=Start position/frame number (or radians for [[ROTATE]])
|p7_type=float|p7_name=length|p7_desc=number of frames to display (or radians for [[ROTATE]])
|p7_type=float|p7_name=length|p7_desc=number of frames to display (or radians for [[ROTATE]])
|p8_type=float|p8_name=rate|p8_desc=frames per second (must not be zero)
|p8_type=float|p8_name=rate|p8_desc=Frames per second, or radians per second when [[ROTATE]] is set, or UV coordinates when [[SMOOTH]] is set (must not be zero)
|func_footnote=Frames are numbered from left to right, top to bottom, starting at 0.<br/>If '''rate''' is negative, it has the same effect as using the [[REVERSE]] flag.{{Footnote|Though if '''rate''' is negative and the [[REVERSE]] flag is used, they cancel each other out.}}
|func_footnote=Frames are numbered from left to right, top to bottom, starting at 0.<br/>If {{LSLP|rate}} is negative, it has the same effect as using the [[REVERSE]] flag.{{Footnote|Though if {{LSLP|rate}} is negative and the [[REVERSE]] flag is used, they cancel each other out.|Though if rate is negative and the REVERSE flag is used, they cancel each other out.}}
|func_desc=Animate the texture on the specified face/faces of the specified prim/prims by setting the texture scale and offset.  Identical to [[llSetTextureAnim]] except able to modify any prim in the link set.
|func_desc=Animate the texture on the specified face/faces of the specified prim/prims by setting the texture scale and offset.  Identical to [[llSetTextureAnim]] except able to modify any prim in the link set.
|return_text
|return_text
|spec=
|spec=
===Frames===
===Frames===
Frames are sub-rectangles within the texture. A set of frames with 2 horizontal ('''{{LSL Param|sizex}}''') and 3 vertical ('''{{LSL Param|sizey}}''') means the overall texture is divided into 3 rows of 2 columns of images, each of which is a frame. llSetTextureAnim will animate across these 6 starting with the top left image and going across and down, optionally repeating. If [[SMOOTH]] is set the frames slide smoothly from one to the next, if off, each frame is displayed in turn centered on the face.
Frames are sub-rectangles within the texture. A set of frames with 2 horizontal ({{LSLP|sizex}}) and 3 vertical ({{LSLP|sizey}}) means the overall texture is divided into 3 rows of 2 columns of images, each of which is a frame. llSetLinkTextureAnim will animate across these 6 starting with the top left image and going across and down, optionally repeating. If [[SMOOTH]] is set the frames slide smoothly from one to the next, if off, each frame is displayed in turn centered on the face.
|caveats=*You can only have one texture animation on a prim
|caveats=*You can only have one texture animation on a prim
**Calling llSetTextureAnim more than once on a prim will reset it.
**Calling llSetLinkTextureAnim more than once on a prim will reset it.
**Calling llSetLinkTextureAnim again with exact same values will not reset animation (a small difference in rate will suffice).
*You cannot combine [[ROTATE]] and [[SCALE]] flags.
*You cannot combine [[ROTATE]] and [[SCALE]] flags.
*'''sizex''' & '''sizey''' are both limited to a range of 0 to 255
*{{LSLP|sizex}} & {{LSLP|sizey}} are both limited to a range of 0 to 255
*llSetTextureAnim when on shows the texture with 1 repeat in X and Y and 0 rotation and offset.
*llSetLinkTextureAnim, when on, shows the texture with 1 repeat in X and Y and 0 rotation and offset.
*Selecting and un-selecting a prim with animation will reset animation from beginning.
|constants={{{!}} class="sortable collapsible" {{Prettytable|style=margin-top:0;}}
|constants={{{!}} class="sortable collapsible" {{Prettytable|style=margin-top:0;}}
{{!}}-{{Hl2}}
{{!}}-{{Hl2}}
Line 67: Line 69:
{{!}}}
{{!}}}
|examples=
|examples=
This slides a texture smoothly and loops it when it gets to the end.
This slides a texture smoothly, along the horizontal U-axis, and loops it when it gets to the end. Note - the texture's rotation for each side affects the apparent motion.  So if the texture is rotated 90 degrees by use of the edit box, the texture may not flow in the direction expected.
<lsl>llSetLinkTextureAnim(LINK_THIS, ANIM_ON | SMOOTH | LOOP , ALL_SIDES, 1, 1, 1, 1, 1);</lsl>
 
<source lang="lsl2">llSetLinkTextureAnim(LINK_THIS, ANIM_ON | SMOOTH | LOOP , ALL_SIDES, 1, 1, 1, 1, 1);</source>


This slides a texture smoothly in the opposite direction
This slides a texture smoothly, along the horizontal U-axis, in the opposite direction
<lsl>llSetLinkTextureAnim(LINK_THIS, ANIM_ON | SMOOTH | LOOP , ALL_SIDES, 1, 1, 1, 1, -1);</lsl>
<source lang="lsl2">llSetLinkTextureAnim(LINK_THIS, ANIM_ON | SMOOTH | LOOP , ALL_SIDES, 1, 1, 1, 1, -1);</source>


This divides a texture into 64 "cells", 8 across, and 8 down, and flips through them, left to right, top to bottom. This is useful for cell animation.
This divides a texture into 64 "cells", 8 across, and 8 down, and flips through them, left to right, top to bottom. This is useful for cell animation.
<lsl>llSetLinkTextureAnim(LINK_THIS, ANIM_ON | LOOP, ALL_SIDES, 8, 8, 0, 64, 6.4 );</lsl>
<source lang="lsl2">llSetLinkTextureAnim(LINK_THIS, ANIM_ON | LOOP, ALL_SIDES, 8, 8, 0, 64, 6.4 );</source>


This rotates a texture counter-clockwise at 2 revolutions per second. Change the last value to -2*TWO_PI to rotate clockwise.
This rotates a texture counter-clockwise at 2 revolutions per second. Change the last value to -2*TWO_PI to rotate clockwise.
<lsl>llSetLinkTextureAnim(LINK_THIS, ANIM_ON | SMOOTH | ROTATE | LOOP, ALL_SIDES,1,1,0, TWO_PI, 2*TWO_PI);</lsl>
<source lang="lsl2">llSetLinkTextureAnim(LINK_THIS, ANIM_ON | SMOOTH | ROTATE | LOOP, ALL_SIDES,1,1,0, TWO_PI, 2*TWO_PI);</source>


This scales a texture larger and smaller.
This scales a texture larger and smaller.
<lsl>llSetLinkTextureAnim(LINK_THIS, ANIM_ON | SMOOTH | SCALE | PING_PONG | LOOP, ALL_SIDES, 1, 1, 1, 3, 2);</lsl>
<source lang="lsl2">llSetLinkTextureAnim(LINK_THIS, ANIM_ON | SMOOTH | SCALE | PING_PONG | LOOP, ALL_SIDES, 1, 1, 1, 3, 2);</source>


This turns off all texture animations
This turns off all texture animations
<lsl>llSetLinkTextureAnim(LINK_THIS, FALSE, ALL_SIDES, 0, 0, 0.0, 0.0, 1.0);</lsl>
<source lang="lsl2">llSetLinkTextureAnim(LINK_THIS, FALSE, ALL_SIDES, 0, 0, 0.0, 0.0, 1.0);</source>


|helpers
|helpers
Line 91: Line 94:
|also_articles
|also_articles
|notes=
|notes=
Texture animation is a property of the prim (i.e., you can remove the script that started the animation, and the prim will remember the settings anyway.) Note, though, that as of Jan 2009, texture animation is still one of the prim properties that are lost when using the rezzed in world copy method of shift-drag. Originally brought up in {{Jira|VWR-640}}, it got it's own issue in [[#SVC-3925|SVC-3925]]
Texture animation is a property of the prim (i.e., you can remove the script that started the animation, and the prim will remember the settings anyway.) Note, though, that as of Jan 2009, texture animation is still one of the prim properties that are lost when using the rezzed in world copy method of shift-drag. Originally brought up in {{Jira|VWR-640}}, it got its own issue in [[#SVC-3925|SVC-3925]]


An online-tool for rough and ready conversion of moving gifs to animated textures is here: http://www.peregrinesalon.com/anim/ (link valid as of Jan 2009.)
An online-tool for rough and ready conversion of moving gifs to animated textures is here: http://www.peregrinesalon.com/anim/ (link valid as of Jan 2009.)
Line 100: Line 103:
|cat5
|cat5
|cat6
|cat6
|history= *Date of release [[ Release_Notes/Second_Life_Server/1.38#New_Features | 29-03-2010 ]]
}}
}}

Revision as of 17:00, 14 January 2022

Summary

Function: llSetLinkTextureAnim( integer link, integer mode, integer face, integer sizex, integer sizey, float start, float length, float rate );

Animate the texture on the specified face/faces of the specified prim/prims by setting the texture scale and offset. Identical to llSetTextureAnim except able to modify any prim in the link set.

• integer link Link number (0: unlinked, 1: root prim, >1: child prims and seated avatars) or a LINK_* flag to effect
• integer mode bit field of Mode flags
• integer face face number or ALL_SIDES
• integer sizex horizontal frames (ignored for ROTATE and SCALE)
• integer sizey vertical frames (ignored for ROTATE and SCALE)
• float start Start position/frame number (or radians for ROTATE)
• float length number of frames to display (or radians for ROTATE)
• float rate Frames per second, or radians per second when ROTATE is set, or UV coordinates when SMOOTH is set (must not be zero)

If face is ALL_SIDES then the function works on all sides. start supports negative indexes. Frames are numbered from left to right, top to bottom, starting at 0.
If rate is negative, it has the same effect as using the REVERSE flag.[2]

Specification

Index Positive Negative
First 0 -length
Last length - 1 -1

Indexes

  • Positive indexes count from the beginning, the first item being indexed as 0, the last as (length - 1).
  • Negative indexes count from the far end, the first item being indexed as -length, the last as -1.

Frames

Frames are sub-rectangles within the texture. A set of frames with 2 horizontal (sizex) and 3 vertical (sizey) means the overall texture is divided into 3 rows of 2 columns of images, each of which is a frame. llSetLinkTextureAnim will animate across these 6 starting with the top left image and going across and down, optionally repeating. If SMOOTH is set the frames slide smoothly from one to the next, if off, each frame is displayed in turn centered on the face.

Flag Description
LINK_ROOT 1 refers to the root prim in a multi-prim linked set[1]
LINK_SET -1 refers to all prims
LINK_ALL_OTHERS -2 refers to all other prims
Flag Description
LINK_ALL_CHILDREN -3 refers to all children, (everything but the root)
LINK_THIS -4 refers to the prim the script is in

Modes Description
ANIM_ON 0x01 Texture animation is on. This must be set to start the animation, cleared to stop it.
LOOP 0x02 Loop the texture animation.
REVERSE 0x04 Play animation in reverse direction.
PING_PONG 0x08 Play animation going forwards, then backwards.
SMOOTH 0x10 Slide in the X direction, instead of playing separate frames.
In both SCALE and ROTATE modes, causes smooth transitions.
ROTATE 0x20 Animate texture rotation.
Does not work with SCALE
SCALE 0x40 Animate the texture scale.
Does not work with ROTATE

Caveats

  • The function silently fails if its face value indicates a face that does not exist.
  • If start is out of bounds the script continues to execute without an error message.
  • You can only have one texture animation on a prim
    • Calling llSetLinkTextureAnim more than once on a prim will reset it.
    • Calling llSetLinkTextureAnim again with exact same values will not reset animation (a small difference in rate will suffice).
  • You cannot combine ROTATE and SCALE flags.
  • sizex & sizey are both limited to a range of 0 to 255
  • llSetLinkTextureAnim, when on, shows the texture with 1 repeat in X and Y and 0 rotation and offset.
  • Selecting and un-selecting a prim with animation will reset animation from beginning.

Important Issues

~ All Issues ~ Search JIRA for related Bugs
   Some persistent prim properties lost when duplicated
   Texture Animation is not copied (llSetTextureAnim)
   Texture animations ignore repeats per face

Examples

This slides a texture smoothly, along the horizontal U-axis, and loops it when it gets to the end. Note - the texture's rotation for each side affects the apparent motion. So if the texture is rotated 90 degrees by use of the edit box, the texture may not flow in the direction expected.

llSetLinkTextureAnim(LINK_THIS, ANIM_ON | SMOOTH | LOOP , ALL_SIDES, 1, 1, 1, 1, 1);

This slides a texture smoothly, along the horizontal U-axis, in the opposite direction

llSetLinkTextureAnim(LINK_THIS, ANIM_ON | SMOOTH | LOOP , ALL_SIDES, 1, 1, 1, 1, -1);

This divides a texture into 64 "cells", 8 across, and 8 down, and flips through them, left to right, top to bottom. This is useful for cell animation.

llSetLinkTextureAnim(LINK_THIS, ANIM_ON | LOOP, ALL_SIDES, 8, 8, 0, 64, 6.4 );

This rotates a texture counter-clockwise at 2 revolutions per second. Change the last value to -2*TWO_PI to rotate clockwise.

llSetLinkTextureAnim(LINK_THIS, ANIM_ON | SMOOTH | ROTATE | LOOP, ALL_SIDES,1,1,0, TWO_PI, 2*TWO_PI);

This scales a texture larger and smaller.

llSetLinkTextureAnim(LINK_THIS, ANIM_ON | SMOOTH | SCALE | PING_PONG | LOOP, ALL_SIDES, 1, 1, 1, 3, 2);

This turns off all texture animations

llSetLinkTextureAnim(LINK_THIS, FALSE, ALL_SIDES, 0, 0, 0.0, 0.0, 1.0);

Notes

Link Numbers

Each prim that makes up an object has an address, a link number. To access a specific prim in the object, the prim's link number must be known. In addition to prims having link numbers, avatars seated upon the object do as well.

  • If an object consists of only one prim, and there are no avatars seated upon it, the (root) prim's link number is zero.
  • However, if the object is made up of multiple prims or there is an avatar seated upon the object, the root prim's link number is one.

When an avatar sits on an object, it is added to the end of the link set and will have the largest link number. In addition to this, while an avatar is seated upon an object, the object is unable to link or unlink prims without unseating all avatars first.

Counting Prims & Avatars

There are two functions of interest when trying to find the number of prims and avatars on an object.

integer GetPrimCount() { //always returns only the number of prims
    if(llGetAttached())//Is it attached?
        return llGetNumberOfPrims();//returns avatars and prims but attachments can't be sat on.
    return llGetObjectPrimCount(llGetKey());//returns only prims but won't work on attachments.
}
See llGetNumberOfPrims for more about counting prims and avatars.

Errata

If a script located in a child prim erroneously attempts to access link 0, it will get or set the property of the linkset's root prim. This bug (BUG-5049) is preserved for broken legacy scripts. Texture animation is a property of the prim (i.e., you can remove the script that started the animation, and the prim will remember the settings anyway.) Note, though, that as of Jan 2009, texture animation is still one of the prim properties that are lost when using the rezzed in world copy method of shift-drag. Originally brought up in VWR-640, it got its own issue in SVC-3925

An online-tool for rough and ready conversion of moving gifs to animated textures is here: http://www.peregrinesalon.com/anim/ (link valid as of Jan 2009.)

See Also

Functions

•  llGetLinkNumber Returns the link number of the prim the script is in.
•  llSetTextureAnim Set texture animation for the prim the script is on.

Articles

•  Negative Index

Deep Notes

History

All Issues

~ Search JIRA for related Issues
   Some persistent prim properties lost when duplicated
   Texture Animation is not copied (llSetTextureAnim)
   Texture animations ignore repeats per face

Footnotes

  1. ^ LINK_ROOT does not work on single prim objects. Unless there is an avatar sitting on the object.
  2. ^ Though if rate is negative and the REVERSE flag is used, they cancel each other out.

Signature

function void llSetLinkTextureAnim( integer link, integer mode, integer face, integer sizex, integer sizey, float start, float length, float rate );