llSetTextureAnim(integer mode, integer side, integer x_frames, integer y_frames, float start, float length, float rate);
Animates the
texture on
side of a
prim. Only one animation can be run per prim, although all sides of a prim can be animated at the same time by setting
side to
ALL_SIDES.
mode is a
mask made up of the following
parameters:
Mode | Description | Hex |
ANIM_ON | enable texture animation | 0x01 |
LOOP | loop when animating textures | 0x02 |
REVERSE | animate in reverse direction | 0x04 |
PING_PONG | animate forward then reverse | 0x08 |
SMOOTH | slide texture smoothly instead of frame-stepping | 0x10 |
ROTATE | rotate texture instead of using frames | 0x20 |
SCALE | scale texture instead of using frames | 0x40 |
Notes:
- Setting mode to FALSE (or just leaving out ANIM_ON) will stop the previous animation.
- ROTATE and SCALE define two 'special' modes of the texture animation, and are mutually exclusive--they cannot be used together.
- ROTATE and SCALE interpret the animation parameters differently from the standard animation mode, and also from each other, as detailed below.
'Standard' Animation Mode
(ie. neither ROTATE nor SCALE)
The "standard" animation
mode divides the texture up into frames, then steps through these frames in sequence.
x_frames and
y_frames describe how the texture is to be broken into frames:
- x_frames defines the number of horizontal frames.
- y_frames defines the number of vertical frames.
start and
length specify which frames of the texture are to be animated:
- start specifies the frame number to begin animating from (frames are numbered from left to right, top to bottom, starting at 0).
- length specifies the total number of frames to animate ( setting length to 0 means animate all frames).
rate controls the animation speed:
- rate sets the animation speed, in frames per second, eg. setting rate to 10.0 means ten frames per second.
Notes:
- x_frames and y_frames are each limited to a range of 0 to 255, due to the fact that only the first byte of each integer is transmitted; the values transmitted are (x_frames & 0xFF) and (y_frames & 0xFF).
- The SMOOTH flag will cause the animation to scroll between the frames instead of jumping frame-by-frame. The frames will still be played in the normal sequence, however.
- Setting rate to a negative value is exactly equivalent to using a positive value and the REVERSE flag.
- Textures cannot be animated beyond a 1x1 tiling.
ROTATE Animation Mode
This
mode causes the texture to rotate on the side(s) of the prim, instead of stepping through frames.
x_frames and
y_frames are ignored in this
mode.
start and
length specify how the texture is to rotate:
- start specifies the beginning rotation of the texture, in radians. Eg. setting start to PI will cause the animation to begin with the texture rotated 90 degrees from its default orientation.
- length specifies the total amount the texture should rotate, in radians. Eg. setting length to TWO_PI will animate a full, 360-degree rotation. Setting length to less than TWO_PI will cause the texture to rotate the amount specified, then jump back to it's beginning rotation.
rate controls the animation speed:
- without the SMOOTH flag, rate specifies the animation speed in frames per second. There seems to be no way to control the number of frames in a non-SMOOTH ROTATE animation, and appears to be fixed at six frames.
- with the SMOOTH flag, rate specifies the animation speed in radians per second.
Note: setting
rate to a negative value will cause the texture to rotate in the opposite direction.
SCALE Animation Mode
This
mode causes the texture to scale up or down on the side(s) of the prim, causing a 'zoom in' or 'zoom out' effect.
x_frames and
y_frames are ignored in this
mode.
start and
length specify the scaling of the texture through its animation:
- start specifies the number of repeats-per-face of the texture at the beginning of the animation.
- length specifies the total increase in repeats-per-face of the texture over the course of the animation.
rate controls the animation speed:
- rate specifies the animation speed in integer scale changes per second; this does not work well for non-integer values of start and length, unless the SMOOTH flag is also being used.
Notes:
- This mode seems to treat start and length as integers, not floats, dropping all decimals.
- Setting start to a negative value will apply the absolute value of start as the beginning repeats-per-face, but will decrease the repeats-per-face by length-1 over the course of the animation, instead of increasing it (ie. zoom in).
- Setting length to a negative value ignores the negative sign; it's an absolute value.
- Another way to state this is that starting_repeats_per_face = llAbs( start ), and the end_repeats_per_face = llAbs( start + llAbs( length ) ), or llAbs( start + llAbs( length ) -1 ) for negative values of start.
- Setting rate to a negative value is exactly equivalent to using a positive value and the REVERSE flag.
SMOOTH Animation Mode
This
mode causes the texture to be moved smoothly between one frame and the next in the X direction.
It can be used for scrolling smoothly from one end of a texture to another. To do this set
Y frames to 1, and set
X frames to a value which sets the proportion of the texture which will be seen at any one time. To avoid over-running the end of the texture and repeating at the end of the loop, set
length to one less than the number of
X frames and
start to zero.
Notes:
- for smooth scrolling in the vertical direction on a prim, simply use the Texure tab on the Edit window to rotate the texture +/- 90 degrees, and the animation will follow.
General Note: llSetTextureAnim works by overriding the texture's scale and offset on the
client side which makes this function incompatable with
llScaleTexture and the
PRIM_TEXTURE and
PRIM_GLOW components of
llSetPrimitiveParams. However, due to this implementation approach it will not affect your bandwidth or a
sim's performance.
Example:
This article wasn't helpful for you? Maybe the
related article at the LSL Portal is able to bring enlightenment.
Functions |
Texture |
Animation