llSetTextureAnim
|
|
Aakanaar LaSalle
Registered User
Join date: 1 Sep 2006
Posts: 132
|
10-07-2006 10:00
I was playing around with a door script.. that simply is a texture that animates to open.. and would become phantom when the door is open. But I havn't gotten that far yet. I made up a nice texture, 9 frames of an elevator door opening.. Looks great.. uploaded it and made the following script: integer mode;
default { state_entry() { mode = TRUE; } touch_start(integer tnum) { if (mode) { llSetTextureAnim(ANIM_ON, ALL_SIDES, 9, 1, 0, 9, 10.0); mode = FALSE; } else { llSetTextureAnim(ANIM_ON | REVERSE, ALL_SIDES, 9, 1, 0, 9, 10.0); mode = TRUE; } } }
It appears to work, but having one difficulty. Whenever I touch it, it flashes to the entire texture then starts going through the frames. So for a moment, I get the entire texture on the prim, showing all of the doors in various stages then it goes through each frame. What am I doing wrong? I originally had it working in two states, but when the above problem occured I thought it might be because of the state changing so I switched to the above code instead. So, If i can get that first problem fixed, should I go back to using states, or is there an easy way to reverse the direction? E.g. I was going to use integer mode = ANIM_ON; and then add or remove the REVERSE as needed, but i'm not sure how to toggle that. Isn't there a way to have it add the REVERSE if it isn't there, and remove it if it is? would an XOR work? how do i use an XOR in LSL?
|
|
Aakanaar LaSalle
Registered User
Join date: 1 Sep 2006
Posts: 132
|
10-07-2006 10:07
Scratch the part on the xor.. found it on the lsl wiki.. so my biggest problem currently is with the texture animation.. Anyone know what i'm doing wrong?
|
|
Ishtara Rothschild
Do not expose to sunlight
Join date: 21 Apr 2006
Posts: 569
|
10-07-2006 11:01
Just tested your script. Problem is, before starting a new texture animation the texture flips back to the original size and offset. Some additional commands to set the offset + size to the end frame of the previous animation should solve this. Try the following script: integer mode;
default { state_entry() { mode = TRUE; } touch_start(integer tnum) { if (mode) { llScaleTexture(0.111,1,ALL_SIDES); llOffsetTexture(-0.444,0,ALL_SIDES); llSetTextureAnim(ANIM_ON, ALL_SIDES, 9, 1, 0, 9, 10.0); mode = FALSE; } else { llScaleTexture(0.111,1,ALL_SIDES); llOffsetTexture(0.444,0,ALL_SIDES); llSetTextureAnim(ANIM_ON | REVERSE, ALL_SIDES, 9, 1, 0, 9, 10.0); mode = TRUE; } } }
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
10-07-2006 12:11
From: Aakanaar LaSalle integer mode;
default { state_entry() { llSetTextureAnim(FALSE, ALL_SIDES, 9, 1, 0, 9, 10.0); mode = TRUE; } touch_start(integer tnum) { if (mode) { llSetTextureAnim(ANIM_ON, ALL_SIDES, 9, 1, 0, 9, 10.0); mode = FALSE; } else { llSetTextureAnim(ANIM_ON | REVERSE, ALL_SIDES, 9, 1, 0, 9, 10.0); mode = TRUE; } } }
Ought to work too. It should keep the same offsets and just flick from not running to running without resizing the texture. I've not tried it, but it ought to work. It if doesn't the llSetPrimitiveParams() for textures might be neater than the suggested work around.
|
|
Aakanaar LaSalle
Registered User
Join date: 1 Sep 2006
Posts: 132
|
10-07-2006 14:11
The ScaleTexture and OffsetTexture do seem to work, almost. Apparently it's difficult to get the figgures exactly right and a noticable jump is apparent. This is made more noticable by the fact that both of the above functions delay the script by 0.2 seconds.
I'm gonna try using SetPrimitiveParams as I can do both things in one shot, with only a single 0.2 delay. Hopefully the reduced delay makes that jump less noticable.
Edit: Using the Primitive Params instead doesn't seem to help. The jump is still noticable, which it isn't really that bad. I can live with it. It's a lot better than before when it would flip to original texture scale momentarily.
Thanks, I appreciate this.
|
|
Aakanaar LaSalle
Registered User
Join date: 1 Sep 2006
Posts: 132
|
10-07-2006 14:46
ok.. now it's doing all kinds of wierd stuff.. It's on a cube, sized as 0.1, 2.5, 3.5 with the following script. Yea I reworked it a bit. integer mode; list lstParams;
default { state_entry() { state opened; } }
state opened { state_entry() { lstParams = [PRIM_TEXTURE, ALL_SIDES, "e7f95d15-34ba-872d-5faa-25e21684c934"]; lstParams += [<0.111, 1.0, 0>, <-0.444, 0, 0>, 0.0, PRIM_PHANTOM, TRUE]; mode = ANIM_ON; } touch_start(integer tnum) { llSetPrimitiveParams(lstParams); llSetTextureAnim(mode, ALL_SIDES, 9, 1, 0, 9, 10.0); state closed; } }
state closed { state_entry() { lstParams = [PRIM_TEXTURE, ALL_SIDES, "e7f95d15-34ba-872d-5faa-25e21684c934"]; lstParams += [<0.111, 1.0, 0>, <0.444, 0, 0>, 0.0, PRIM_PHANTOM, FALSE]; mode = ANIM_ON | REVERSE; } touch_start(integer tnum) { llSetPrimitiveParams(lstParams); llSetTextureAnim(mode, ALL_SIDES, 9, 1, 0, 9, 10.0); state opened; } }
It appears to be.. i dunno.. something on the offset is suddenly wrong? it wasn't before.. bah.. i'm not having much luck with setting texture animations.. At least the Phantom / Not Phantom part seems to be working
|
|
Ishtara Rothschild
Do not expose to sunlight
Join date: 21 Apr 2006
Posts: 569
|
10-07-2006 18:46
Don't ask me why, but when you add the llSetPrimitiveP. with the same parameters to your old script, it works just fine: integer mode;
default { state_entry() { llSetTextureAnim(FALSE, ALL_SIDES, 9, 1, 0, 9, 10.0); mode = TRUE; } touch_start(integer tnum) { if (mode) { llSetPrimitiveParams([PRIM_TEXTURE, ALL_SIDES, "e7f95d15-34ba-872d-5faa-25e21684c934", <0.111, 1.0, ALL_SIDES>, <-0.444, 0, 0>, 0.0, PRIM_PHANTOM, TRUE]); llSetTextureAnim(ANIM_ON, ALL_SIDES, 9, 1, 0, 9, 10.0); mode = FALSE; } else { llSetPrimitiveParams([PRIM_TEXTURE, ALL_SIDES, "e7f95d15-34ba-872d-5faa-25e21684c934", <0.111, 1.0, ALL_SIDES>, <0.444, 0, 0>, 0.0, PRIM_PHANTOM, FALSE]); llSetTextureAnim(ANIM_ON | REVERSE, ALL_SIDES, 9, 1, 0, 9, 10.0); mode = TRUE; } } } Your state changing script should work just the same way, in theory. I have no idea why it doesn't.
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-07-2006 19:45
Per the wiki on llSetTextureAnim:
"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 component of llSetPrimitiveParams. However, due to this implementation approach it will not affect your bandwidth or a sim's performance."
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Aakanaar LaSalle
Registered User
Join date: 1 Sep 2006
Posts: 132
|
10-07-2006 20:10
The code you provided is having same effect as my state changing version.. I don't understand why it's not working for me. I guess I'll go back to using the llScaleTexture and the llOffsetTexture for now, see if that fixes it. From: someone Per the wiki on llSetTextureAnim:
"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 component of llSetPrimitiveParams. However, due to this implementation approach it will not affect your bandwidth or a sim's performance."
I understand that, but without doing something, the llSetTextureAnim whenever I start it, flips to the original scale and offset momentarily making it flash the entire texture for a moment before starting the animation. There has got to be a fix around that.
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-07-2006 21:16
OK this works , but I have no idea WHY it works. If someone could explain it to me I would be greatful. integer mode; list lstParams;
default { state_entry() { state opened; } }
state opened { state_entry() { lstParams = [PRIM_TEXTURE, ALL_SIDES, "e7f95d15-34ba-872d-5faa-25e21684c934"]; lstParams += [<0.111, 1.0, 0>, <-0.444, 0, 0>, 0.0, PRIM_PHANTOM, TRUE]; mode = ANIM_ON; } touch_start(integer tnum) { llSetPrimitiveParams(lstParams); llSetTextureAnim(mode, ALL_SIDES, 9, 1, 0, 9, 10.0); state closed; } }
state closed { state_entry() { lstParams = [PRIM_TEXTURE, ALL_SIDES, "e7f95d15-34ba-872d-5faa-25e21684c934"]; lstParams += [<0.111, 1.0, 0>, <0.444, 0, 0>, 0.0, PRIM_PHANTOM, FALSE]; mode = ANIM_ON | REVERSE; } touch_start(integer tnum) { //llSetPrimitiveParams(lstParams); llSetTextureAnim(mode, ALL_SIDES, 9, 1, 0, 8, 10.0); state opened; } }
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Ishtara Rothschild
Do not expose to sunlight
Join date: 21 Apr 2006
Posts: 569
|
10-08-2006 01:27
Messed a bit around with that, out of curiosity. When llSetTextureAnim starts, it switches back to the offset/size that was originally applied, before the script started. But that can be any size and offset; it doesn't have to show the whole texture.
What I mean is: if you never opened the Edit window and applied any other texture values, the standard size will be 1, 1 with offset 0, 0. You can tweak this manually to show exactly the first frame of the texture, which makes the texture animation look right at least in one direction (forward will look fine, but reverse will start of with the wrong frame). That's why the script above works; you can do without one of the llSetPrimitiveParams.
To "repair" the standard parameters you can run the animation one time, then edit the prim, go to the texture tab and close the edit window again. Sounds odd, but obviously this already counts as applying the new values (the parameters with which the previously running animation stopped). This gets rid of flashing the complete texture with all frames at once between the animations. Now you only need to switch the offset from 0.444 to -0.444 after playing the forward animation.
In short: Let the animation run one time, then edit the prim and open the texture tab in teh edit window. Close it again - SL will act as if you manually entered the changed size+offset. Means, what you see now is what you'll see between animations. Then change the script to repair the offset only for one animation direction. Or: before adding the animation script, tweak the texture parameters in the edit window to show the first frame only. Will have the same effect.
|