Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need Help W/ Animated Texture Simple

Exocet Kungler
Registered User
Join date: 5 Jun 2007
Posts: 7
07-15-2007 13:19
Question for ya guys. I just downloaded the Animated Texture Script Simple for the fact that i can read scripting and understand what its trying to do but cant really right it for the reason of not understanding the language. But got a quick question on this script. My switchtime is set to 0.000 and its set for seconds. But if im trying to make the texture scan faster each second, how would that be done since my switchtime is already set to 0.000 i tried negative numbers but that didnt seem to work. Any help would be appreciated.

Thanks

// SCRIPT_NAME = "animated texture-simple";
// DESCRIPTION = "animated the texture my offseting the texture at intervals";

// global variables
integer gCellsAcross = 72;
integer gCellsDown = 1;
// seconds between cells
float gSwitchTime = 0.000;
float gOffsetU;
float gOffsetV;
float gScaleU;
float gScaleV;

key gKey;
vector gScale;


// all scripts start in the default state
default
{
//this state will allow colors to be set
state_entry()
{

gScaleU = 1/(float)gCellsAcross;
gScaleV = 1/(float)gCellsDown;
// U range is -0.5 to 0.5 left to right
// V range is 0.5 to -0.5 top to bottom
// divided by 2 to put focus at the center of the cell
gOffsetU = -0.5 + gScaleU / 2;
gOffsetV = 0.5 - gScaleV / 2;
// next line automatically scales the texture
// llScaleTexture(gScaleU, gScaleV, -1);

// next line focuses the texture on the last cell - for use if this is a click-started animation
// llOffsetTexture(0.5-gScaleU/2, -0.5+gScaleV/2, -1);

state Movie;
}

}

state Movie
{
state_entry()
{
integer i;
integer j;
integer k;
float OffsetU;
float OffsetV;
@Loophere;
// set local offset variables equal to global offset constants
OffsetU = gOffsetU;
OffsetV = gOffsetV;

for (i=0; i<gCellsDown; i++)
{

for (j=0; j<gCellsAcross; j++)
{

llOffsetTexture(OffsetU, OffsetV, -1);
llSleep(gSwitchTime);
OffsetU = OffsetU + gScaleU;
}
OffsetU = OffsetU - 1.0;
OffsetV = OffsetV - gScaleV;

}

jump Loophere;
}

}
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
07-15-2007 19:14
llOffsetTexture() delays the script by 0.2 secs each call--and for good reason it would seem, since it must be doing server-side texture animation. The best one might hope for with this approach, then, is 5 frames per second (per script--theoretically you could have multiple slave scripts, invoked by llMessageLinked in round-robin from a central script). For smoother, faster animation, it will be a lot less laggy if the requirements can fit within the constraints of llSetTextureAnim, so it will all run client-side.
Mr Greggan
Registered User
Join date: 5 Mar 2007
Posts: 5
llOffsetTexture Question
05-05-2009 17:08
Here is an update to that script, which will display random cells of a random texture.

--------------------------------------------------
// SCRIPT_NAME = "animated texture-simple";
// DESCRIPTION = "animated the texture by offseting the texture at intervals";
// UPDATE BY MR GREGGAN = "Displays random cell from random texture on prim face 2."

//by bUTTONpUSHER Jones
//Mod by BuhBuhCuh Fairchild
//Mod by Mr Greggan 5-5-2009

//Global Variables
integer gCellsAcross = 4;
integer gCellsDown = 16;
float gSwitchTime = 3.0;
float gPositionHoriz;
float gPositionVert;
float gCellWidth;
float gCellHeight;

default
{
state_entry()
{

gCellWidth = 1/(float)gCellsAcross;
gCellHeight = 1/(float)gCellsDown;
llScaleTexture(gCellWidth, gCellHeight, 2);

gPositionHoriz = -0.5 + gCellWidth / 2;
gPositionVert = 0.5 - gCellHeight / 2;

//llOwnerSay( "DEBUGGING\n-----\ngCellWidth: " + (string)gCellWidth + "\ngCellHeight: " + (string)gCellHeight + "\ngPositionHoriz:" + (string)gPositionHoriz + "\ngPositionVert:" + (string)gPositionVert );

state Movie;
}

}

state Movie
{
state_entry()
{
integer h;
integer v;
float i;
float PositionHoriz;
float PositionVert;

@Loophere;
PositionHoriz = gPositionHoriz;
PositionVert = gPositionVert;

integer choice = (integer)llFrand(llGetInventoryNumber(INVENTORY_TEXTURE));
string name = llGetInventoryName(INVENTORY_TEXTURE, choice);
if (name != "";)
{
h = (integer)llFrand(gCellsAcross);
v = (integer)llFrand(gCellsDown);

for (i=0; i<h; i+=1)
{ PositionHoriz += gCellWidth; }
for (i=0; i<v; i+=1)
{ PositionVert -= gCellHeight; }
llSleep(gSwitchTime);
llOffsetTexture(PositionHoriz, PositionVert, 2);
llSleep(gSwitchTime);
llSetTexture(name, 2);
}

//llOwnerSay( "DEBUGGING\n-----\nTxtr: " + name + "\nh: " + (string)h + "\nv: " + (string)v + "\nPositionHoriz:" + (string)PositionHoriz + "\nPositionVert:" + (string)PositionVert );

jump Loophere;

}
}