Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need help with Random 'Gif' animating prim

Amariah Francis
Registered User
Join date: 20 Dec 2006
Posts: 33
08-12-2008 22:13
Here is the problem, I have a bunch of prims next to each other, all animated with the same 'gif.' Okay it's not a real gif but a one texture that is scripted so that it jumps to the next 'frame' within the same texture. This is the script I am using to achieve this:
CODE
    
default

{

state_entry()

{

llSetTextureAnim(ANIM_ON | LOOP, ALL_SIDES, 1, 4, 0.0, 0.0, 4);

}

}



The problem is that when the prims that are all running the same texture with the same script, they look like they are synchronized. I don't want this, I want it to look random . . . is there a way to randomize the speed and sequence?
Amariah Francis
Registered User
Join date: 20 Dec 2006
Posts: 33
08-12-2008 23:56
Could I maybe use this?

http://wiki.secondlife.com/wiki/Pseudo-random_Number_Generator

Anyone? I really don't know how to code at all, if someone can help that would be great!
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-13-2008 00:38
I believe that synchronization is a "feature" of the client. You may have to upload additional versions of the animation with the frames rotated from each other:

1, 2, 3, 4, 5, 6
2, 3, 4, 5, 6, 1
3, 4, 5, 6, 1, 2
4, 5, 6, 1, 2, 3
5, 6, 1, 2, 3, 4
6, 1, 2, 3, 4, 5

(And if you truly want a random sequence, also other orders like:

3, 6, 1, 4, 2, 5)

Then choose a random texture for each face. While you can randomize the overall speed, the animation parameters must be the same for all the faces, so I don't think you can make one go faster or slower than the other.
Amariah Francis
Registered User
Join date: 20 Dec 2006
Posts: 33
08-13-2008 03:05
Thanks yes I was thinking it was something that was set on the server/client. What I did was just change the script for them so they were different, like instead of 0.0, 0.0, 16 I used 1, 0.0, 15, and then change every other one, made it look more random, time consuming changing them all but less expensive than uploading new images. What I was hoping for was instead of having a numerical number in the script I could have an integer such as 'n' with 'n' being equal to a random number. I'm not familiar with SL script yet but I've done similar things in the past with javascript with Math.random, and I was hoping there was an SL equivalent . . . that code that I pasted looked like it might do what I want it but this script language is so different from what I am used to. I'm going to have to really learn this code.
Beverly Ultsch
Registered User
Join date: 6 Sep 2007
Posts: 229
08-13-2008 03:53
llFrand is what you need, something like this.


CODE


//Return float between min and max

float randBetween(float min, float max)
{
return llFrand(max - min) + min;
}

//Integers

{
return (integer)llFrand(n + 1);
}

integer randIntBetween(integer min, integer max)
{
return min + randInt(max - min);
}

default()
{
state_entry()
{
llSetTextureAnim(ANIM_ON | LOOP, ALL_SIDES, 1, 4, 0.0, 0.0, randIntBetween(10, 20);
}
}


As Hewee says all sides of the prim will be the same, but difeeren prims will select there own speed.

You can further randomize other parameters, although what the effects would look like i don't know :)

In addition you can use llSetPrimitiveParams to play around with other parts of the texture eg: rotation to further randomize the effect.

If you then wrap it all up in a timer loop, to constanly change thinks you should end up with a nice random looking diplay.

Edit in this example randBetween is not used, just put in to show how to do it for a float
Debbie Trilling
Our Lady of Peenemünde
Join date: 17 Oct 2006
Posts: 434
08-13-2008 04:58
An effective variation on this idea that we use on 'The Wall'...

...randomise the frames themselves within the texture. That is, in Photoshop, create and upload a number of different textures, all using the same layers but the layers in different positions on each texture.

This ensures each prim displays a different picture/frame at any given moment, altho' in this case the moment that each frame changes is synchronised (because that was the effective we wanted to create)

EDIT:
what I should perhaps add for clarity: we did it this way, rather than using the same texture but simply adjusting the frame start parameter of each prim, because we wanted frame 16 to always show the same picture, and only frames 1 to 15 to be different from each other.
_____________________
http://wiki.secondlife.com/wiki/User:debbie_Trilling
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
08-13-2008 06:35
If I may... What a bad idea! All those textures need to be downloaded by the client and until it's done, you got multiple blurry messes that will slowly rez one by one.

Instead of that, I would rather introduce some randomness in the frame rate. I mean if each texture animation has its own frame rate, several versions of the same animation side by side will just desynchronize themselves.

I used 4 cubes linked together, each containing the same script:

default
{
on_rez(integer param) { llResetScript(); } // So they rez syncronized.

state_entry()
{
llSetTextureAnim( ANIM_ON | LOOP, ALL_SIDES, 10, 10, 0, 100, frame_rate);
}
}

'frame_rate' was 6.0, 6.33, 6.66 and 6.99. They get out of sync pretty fast.

Just my 0.02 L$ of the day...
Beverly Ultsch
Registered User
Join date: 6 Sep 2007
Posts: 229
08-13-2008 07:16
Debbie & Kaluura

I agree with both of you, the best approach is the one that gives you the result you want.

While Debbies solution does incur more overhead, it gives the result required ie: the 16th frame must sync.

For a totaly random effect then Kaluura's solution is much more lag friendly.

Without knowing exactly what the OP is trying to achieve it is hard to give an opinion on the best solution.

But having said that llFrand is still the answer i think, unless like Debbie you nedd it to come back into sync at some point.
Debbie Trilling
Our Lady of Peenemünde
Join date: 17 Oct 2006
Posts: 434
08-13-2008 07:39
From: Kaluura Boa
All those textures need to be downloaded by the client and until it's done, you got multiple blurry messes that will slowly rez one by one


Obviously that is true and we were very much aware of that, and therefore took measures to prevent it.

Texture Pre-Loaders had already delivered these textures to the audiences' cache well in advance of them actually being displayed. This system allowed audiences of 50 avatars on a single sim, and 160 avatars spread over 3 sims to largely avoid a multiple blurry mess...or at least, it not being any worse than SL users are accustomed to.

The solution worked extremely well to create the effect that we wanted to deliver to our audiences. :)
_____________________
http://wiki.secondlife.com/wiki/User:debbie_Trilling
Shaindaman Fiertze
Registered User
Join date: 17 Jul 2008
Posts: 13
08-23-2008 12:40
Yes I was trying to avoid using several different textures, which is why I was only wanting to use one and just randomize the code for it, so only 1 texture, just displayed differently for each prim, so it appears as though they are not using the same.


(LOL, this is Amariah, my husband is logged in, I hate when that happens.) Anyway, (excitedly says) you can use php in SL? :0

Oh and what I am building . . . it's a sequined dress, the sequins are sparkly and animated with 1 texture, now going to try the code posted here to see which one works. For loading purposes, I will only be using 1 texture, or else the outfit would take several minutes to rez, we don't want that!

Ama

-- update thank you to all that posted code! A big thanks goes to Kaluura Boa, her code works perfectly and is simple to use! :)
SuezanneC Baskerville
Forums Rock!
Join date: 22 Dec 2003
Posts: 14,229
08-23-2008 13:02
Pne texture with multiple frame cycles might help produce a random look.

Possibly one texture with frames

1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 1, 3, 4, 5, 6, 1, 2, 4, 5, 6, 1, 2, 3, 5, 6, 1, 2, 3, 4, 6, 1, 2, 3, 4, 5

or something like that, maybe not that long, and each sequin starting from a randomly selected frame, with a somewhat random frame rate.
_____________________
-

So long to these forums, the vBulletin forums that used to be at forums.secondlife.com. I will miss them.

I can be found on the web by searching for "SuezanneC Baskerville", or go to

http://www.google.com/profiles/suezanne

-

http://lindenlab.tribe.net/ created on 11/19/03.

Members: Ben, Catherine, Colin, Cory, Dan, Doug, Jim, Philip, Phoenix, Richard,
Robin, and Ryan

-
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-23-2008 13:12
Oh! A simple sparkle type effect? Have you tried something like a rotating, sliding, or scaling animated texture rather than a framed one? Then I think you MIGHT be able to set the texture scale/rotation/offset such that each sequin "starts" at a different brightness. Or does the texture have more than just simple color?