Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Texture Organizer Texture Organizer  

Texture Organizer

You basically lay out 22 box prims and link them.
Then you put the textures in it and install the script,
and you have an instant low-lag 20-pane texture organizer.
It has texture mode and sculpty mode, it checks for perms and
advises how many textures were not loaded due to perms issues
so you can deal with them, it assigns access to all, owner, or group,
and it can display sculpties.

Category: Texture Organizer
By : Solo Mornington
Created: 2013-09-06 Edited: 2013-09-04
Worlds: Second Life

the Zip file

Download all files for Texture Organizer
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Main Script.lsl
Get file # 2. [9928 bytes] owner-group-all.png
Get file # 3. Readme.txt
Get file # 4. [12202 bytes] sculpty-give-all.png
Get file # 5. [12954 bytes] sculpty-texture-give.png
Get file # 6. [7954 bytes] Texture Organizer Buttons.png
1
2 // Texture Organizer
3 // by
4 // Solo Mornington
5
6 // THIS NOTICE MUST REMAIN INTACT:
7 // Copyright 2011, Solo Mornington
8 // License: Use freely in any way you want. Modified versions
9 // may be used in any way. No credit or acknowledgement required.
10 // Definitive source and updates available here:
11 // https://github.com/SoloMornington/TextureOrganizer
12 // ** end notice
13
14
15 // Assumes the object has 22 prims: base, max 20 images, closebox.
16
17 // constant for which prim is the base.
18 integer BUTTON_PRIM = 1;
19 // These are constants for the controls on the faces of the base
20 integer BUTTON_CONFIG = 4;
21 integer BUTTON_NEXT = 7;
22 integer BUTTON_PREV = 6;
23
24 // Constants for gSecurityMode.
25 integer SECURITY_ALL = 1;
26 integer SECURITY_GROUP = 2;
27 integer SECURITY_OWNER = 3;
28 // Which security mode are we in?
29 integer gSecurityMode = 2;
30
31 integer gSculptMode = FALSE; // if this is true, show all textures as sculpties.
32
33 integer gFirstTextureIndex = 0; // The first texture for the current page of textures being browsed.
34
35 integer gZoomTextureIndex = -1; // index of zoomed texture
36 integer gZoomTexturePrimIndex = -1; // which prim has this texture on it?
37
38 list gTilePositions; // pre-calculated list of tile positions
39 float gCubeSize = 0.5;
40 float gTileMargin = 0.1; // fraction of cube size
41 integer gRows = 5;
42 integer gColumns = 4;
43 float gMargin = 0.1; // margin is calculated as fraction of cube size
44
45 // The base/root prim
46 list gBase = [
48 <0.0, 0.5, 0.0>, // cut
49 0.35, //hollow
50 ZERO_VECTOR, // twist
51 <1.0, 0.1, 0.0>, // hole size
52 ZERO_VECTOR, // top shear
53 <0.25, 1.0, 0.0>, // profile cut
54 ZERO_VECTOR, // taper
55 1.0, // revolutions
56 0.0, // offset
57 0.0, // skew
58 PRIM_SIZE, <2.5, 0.5, 0.5>,
59 // blank textures for all sides
60 PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, <1.0, 1.0, 0.0>, ZERO_VECTOR, 0.0,
62 PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 1.0,
63 // control textures for the control faces
64 PRIM_TEXTURE, 6, "b6fd4e55-6120-abb5-af43-aa1f223dd4fd", <1.0, 1.0, 0.0>, ZERO_VECTOR, 0.0,
65 PRIM_TEXTURE, 7, "b6fd4e55-6120-abb5-af43-aa1f223dd4fd", <-1.0, 1.0, 0.0>, ZERO_VECTOR, 0.0,
66 PRIM_TEXTURE, 4, "b6fd4e55-6120-abb5-af43-aa1f223dd4fd", <5.0, 1.0, 0.0>, <0.150, -0.5, 0.0>, 0.0
67 ];
68
69 // A default cube....
71 <0.0, 1.0, 0.0>, // cut
72 0.0, //hollow
73 ZERO_VECTOR, // twist
74 <1.0, 1.0, 0.0>, // top size/taper
75 ZERO_VECTOR, // top shear
76 // we add size per application....
77 PRIM_ROT_LOCAL, ZERO_ROTATION,
78 //PRIM_ROT_LOCAL, <0.707107, -0.000000, -0.000000, 0.707107>,
79 PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, <1.0, 1.0, 0.0>, ZERO_VECTOR, 0.0,
81 PRIM_COLOR, ALL_SIDES, <0.5, 0.5, 0.5>, 1.0
82 ];
83
84 // constants for the close button
85 list gCloseButton = [PRIM_TYPE, PRIM_TYPE_CYLINDER, PRIM_HOLE_DEFAULT,
86 <0.0, 1.0, 0.0>, // cut
87 0.0, //hollow
88 ZERO_VECTOR, // twist
89 <1.0, 1.0, 0.0>, // top size/taper
90 ZERO_VECTOR, // top shear
91 // we add size per application....
92 //PRIM_ROT_LOCAL, ZERO_ROTATION,
93 PRIM_ROT_LOCAL, <0.707107, -0.000000, -0.000000, 0.707107>,
94 PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, <1.0, 1.0, 0.0>, ZERO_VECTOR, 0.0,
96 PRIM_COLOR, ALL_SIDES, <0.5, 0.5, 0.5>, 1.0,
97 PRIM_TEXTURE, 0, "b6fd4e55-6120-abb5-af43-aa1f223dd4fd", <0.5, 0.5, 0.0>, <0.25, 0.25, 0.0>, 0.0,
98 PRIM_FULLBRIGHT, 0, 1,
99 PRIM_COLOR, 0, <1, 1, 1>, 1.0,
100 PRIM_TEXTURE, 2, "b6fd4e55-6120-abb5-af43-aa1f223dd4fd", <0.5, 0.5, 0.0>, <0.25, 0.25, 0.0>, 0.0,
101 PRIM_FULLBRIGHT, 2, 1,
102 PRIM_COLOR, 2, <1, 1, 1>, 1.0
103 ];
104
105 list gTextures; // all the textures we can display
106
107 list gHiddenPrims; // list of prims that are already hidden. add to this when you hide one.
108
109 // PRIMS IN SPACE!!!
110
111 // This will all be refactored.
112
113 vector gOrigin = ZERO_VECTOR; // top-left coordinate
114
115 key gConfigOperator; // Who clicked on the config button? state config needs this.
116 integer gConfigSculptModePrim; // which prim is the sculpt mode button?
117 integer gConfigGiveAllPrim; // which prim is the give all button?
118 integer gConfigSecurityOwnerPrim;
119 integer gConfigSecurityGroupPrim;
120 integer gConfigSecurityAllPrim;
121
122 // the textures we like.
123 string gModeTexture = "c6ece822-b257-9dbd-a583-1111ca9cb728"; // sculpty/texture mode/give all
124 string gSecurityTexture = "842a2cb2-fd8f-d456-3b30-bbb762f2028f"; // owner/group/all
125
126 // how long should we show the config menu before timing-out
127 // to browse mode?
128 float gConfigTimeout = 360.0; // five minutes long enough?
129
130 repositionPrims()
131 {
132 // This function makes sure that there are enough
133 // tile prims positioned for browsing.
134 // Gathers tile positions from gTilePositions.
135 // In order to prevent unneccesary lag, it will avoid
136 // repositioning prims that are already positioned.
137 // This assumes that non-hidden prims are already in position,
138 // so if you never called zeroAllPrimsExcept(), this function
139 // won't do much.
140 list hiddenPrims;
141 integer row;
142 integer column;
143 integer link = 2; // start at the first child prim
145 float cubeDivisor = 5.0;
146 if(gSculptMode) cubeDivisor = 2.0;
147 for (row=0; row < gRows; ++row)
148 {
149 for (column=0; column < gColumns; ++column)
150 {
151 // if this prim is hidden, we need to un-hide it.
152 // but if it's not, we don't need to do anything.
153 if(llListFindList(gHiddenPrims, [link]) > -1)
154 {
155 vector newPos = llList2Vector(gTilePositions, link - 2);
156 llSetLinkPrimitiveParamsFast(link,
157 gCube +
158 [PRIM_POSITION, newPos,
159 PRIM_SIZE, <gCubeSize, gCubeSize/cubeDivisor, gCubeSize>
160 ]);
161 }
162 ++link;
163 }
164 }
165 // hide any extra prims....
166 while(link <= linked)
167 {
168 if(llListFindList(gHiddenPrims, [link]) <= -1)
169 {
170 llSetLinkPrimitiveParamsFast(link,
172 }
173 hiddenPrims += [link];
174 ++link;
175 }
176 // update the global list of hidden prims with our new one
177 gHiddenPrims = hiddenPrims;
178 }
179
180 calculateTilePositions()
181 {
182 // fill gTilePositions with precalculated positions
183 // so that we can just loop through them to put the
184 // tiles in place.
185 gTilePositions = [];
186 integer row;
187 integer column;
188 float halfCube = gCubeSize / 2.0;
189 for (row=0; row < gRows; ++row)
190 {
191 for (column=0; column < gColumns; ++column)
192 {
193 vector newPos = <
194 gOrigin.x + gMargin + halfCube + ((float)column) * (gCubeSize + gMargin), // x
195 gOrigin.y, // y
196 gOrigin.z + gMargin + halfCube + (((float)row) * (gCubeSize + gMargin)) //z
197 >;
198 gTilePositions += [newPos];
199 }
200 }
201 }
202
203 gatherTextures()
204 {
205 // clear the list...
206 gTextures = [];
207 // loop through all the textures,
208 // see if they have proper perms
209 // add them to the list if they do.
211 string textureName;
212 integer ownerPerms;
214 integer i;
215 for (i=0; i<count; ++i)
216 {
217 textureName = llGetInventoryName(INVENTORY_TEXTURE, i);
218 ownerPerms = llGetInventoryPermMask(textureName, MASK_OWNER);
219 if((ownerPerms & PERM_COPYTRANS) == PERM_COPYTRANS)
220 {
221 gTextures += [textureName];
222 }
223 }
224 // compare inventory count to list count. this will tell us
225 // if there are any textures that didn't pass muster
226 // and we can tell the user.
227 if(llGetListLength(gTextures) != count)
228 {
229 llSay(0,"Some textures in this organizer have restrictive permissions and will not be displayed.");
230 }
231 }
232
233 showTextures()
234 {
235 // display the textures
236 // one per prim, face 1.
237 // We assume that there are 20 textures max, and that the first child prim
238 // is the first texture prim.
239 if(gSculptMode)
240 {
241 showSculpts();
242 return;
243 }
244 list blankParams = [PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, <1.0, 1.0, 0.0>, ZERO_VECTOR, 0.0];
245 list params; // primitive params
246 integer texturesRemaining =
247 llGetListLength(gTextures) - gFirstTextureIndex;
248 integer i;
249 integer numTextures = gRows * gColumns;
250 for (i=0; i<numTextures; ++i)
251 {
252 integer linkNum = i+2;
253 if(texturesRemaining <= i)
254 {
255 params = gCube + blankParams + [PRIM_POSITION, ZERO_VECTOR, PRIM_SIZE, ZERO_VECTOR];
256 gHiddenPrims += [linkNum];
257 }
258 else
259 {
260 string textureName = llList2String(gTextures, i+gFirstTextureIndex);
261 params = blankParams + [
262 PRIM_TEXTURE, 1, textureName, <1.0, 1.0, 0.0>, ZERO_VECTOR, 0.0,
263 PRIM_TEXTURE, 3, textureName, <1.0, 1.0, 0.0>, ZERO_VECTOR, 0.0,
264 PRIM_COLOR, 1, <1.0, 1.0, 1.0>, 1.0,
265 PRIM_COLOR, 3, <1.0, 1.0, 1.0>, 1.0,
266 PRIM_FULLBRIGHT, 1, 1,
267 PRIM_FULLBRIGHT, 3, 1
268 ];
269 }
270 llSetLinkPrimitiveParamsFast(linkNum, params);
271 }
272 }
273
274 showSculpts()
275 {
276 list blankParams = [PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, <1.0, 1.0, 0.0>, ZERO_VECTOR, 0.0];
277 list params; // primitive params
278 integer texturesRemaining =
279 llGetListLength(gTextures) - gFirstTextureIndex;
280 integer i;
281 for (i=0; i<20; ++i)
282 {
283 integer linkNum = i+2;
284 if(texturesRemaining <= i)
285 {
286 params = gCube + blankParams + [PRIM_POSITION, ZERO_VECTOR, PRIM_SIZE, ZERO_VECTOR];
287 gHiddenPrims += [linkNum];
288 }
289 else
290 {
291 string textureName = llList2String(gTextures, i+gFirstTextureIndex);
292 params = blankParams + [
293 PRIM_TYPE, PRIM_TYPE_SCULPT,
294 textureName, PRIM_SCULPT_TYPE_SPHERE,
295 PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, <1.0, 1.0, 0.0>, ZERO_VECTOR, 0.0,
296 PRIM_COLOR, ALL_SIDES, <0.5, 0.5, 0.5>, 1.0,
298 ];
299 }
300 llSetLinkPrimitiveParamsFast(linkNum, params);
301 }
302 }
303
304 //featureTexture(integer primLink)
305 //{
306 // prominently display gZoomTextureIndex if it's not -1
307 // if(gZoomTextureIndex > -1)
308 //{
309 // llOwnerSay(llList2String(gTextures, gZoomTextureIndex));
310 //}
311 //}
312
313 setupTileGeometry()
314 {
315 // how many rows and columns?
316 integer textureCount = llGetListLength(gTextures);
317 if(textureCount < 1)
318 {
319 // there are no textures, so return.
320 gColumns = 0;
321 gRows = 0;
322 return;
323 }
324 gColumns = llCeil(llSqrt(textureCount));
325 // no more than 4 columns.
326 if(gColumns > 4) gColumns = 4;
327 // convert and store because we use it a few times
328 float columns = (float)gColumns;
329 // how many rows needed for this many columns?
330 gRows = llCeil((float)textureCount / columns);
331 // no more than 5 rows.
332 if(gRows > 5) gRows = 5;
333 // how big is the base?
334 list params = llGetLinkPrimitiveParams(LINK_ROOT, [PRIM_SIZE]);
335 vector baseSize = llList2Vector(params,0);
336 float marginsPerTile = 1.0 / gTileMargin;
337 // common denominator....
338 float marginsPerDisplay = (marginsPerTile * columns) + columns + 1.0;
339 gMargin = baseSize.x / marginsPerDisplay;
340 gCubeSize = gMargin * marginsPerTile;
341
342 gTilePositions = [];
343
344 // setup gOrigin
345 gOrigin.x = 0.0 - (baseSize.x / 2.0);
346 gOrigin.y = 0.0;
347 gOrigin.z = baseSize.z;
348 }
349
350 integer security(key avatar)
351 {
352 // given an avatar, figure out if they pass the security set
353 // for the object in preferences
354 if(gSecurityMode == SECURITY_ALL) return TRUE;
355 if(gSecurityMode == SECURITY_GROUP) return llSameGroup(avatar);
356 if(gSecurityMode == SECURITY_OWNER) return (avatar == llGetOwner());
357 return FALSE;
358 }
359
360 base_browsePrevNext()
361 {
362 // show if there are prev or next buttons available
363 vector nextColor = <0.0, 0.0, 0.0>;
364 vector prevColor = <0.0, 0.0, 0.0>;
365 if(gFirstTextureIndex > 0) prevColor = <1.0, 1.0, 1.0>;
366 if(llGetListLength(gTextures) > gFirstTextureIndex + (gRows * gColumns)) nextColor = <1.0, 1.0, 1.0>;
367 llSetLinkPrimitiveParamsFast(LINK_ROOT, [PRIM_COLOR, 7, nextColor, 1.0,
368 PRIM_COLOR, 6, prevColor, 1.0]);
369 }
370
371 base_noPrevNext()
372 {
373 // hide both prev and next buttons
374 vector nextColor = <0.0, 0.0, 0.0>;
375 vector prevColor = <0.0, 0.0, 0.0>;
376 llSetLinkPrimitiveParamsFast(LINK_ROOT, [PRIM_COLOR, 7, nextColor, 1.0,
377 PRIM_COLOR, 6, prevColor, 1.0]);
378 }
379
380 integer base_processTouch(integer face)
381 {
382 // given that the user has touched the base prim, we need to figure
383 // out what control they hit.
384 // This is factored out so we can change it easily if we need to.
385 if(face == BUTTON_CONFIG) return BUTTON_CONFIG;
386 if(face == BUTTON_PREV) return BUTTON_PREV;
387 if(face == BUTTON_NEXT) return BUTTON_NEXT;
388 return 0; // no-op
389 }
390
391 zeroAllPrimsExcept(integer exception)
392 {
393 // put all non-root prims into a zeroed state, at ZERO_VECTOR and as small as possible
394 // leave the textures/sculpts, so they don't have to reload.
395 // ...Except of course the given exception link number. :-)
396 // Also, keep track of which prims are hidden (zeroed) in gHiddenPrims.
397 integer i;
399 gHiddenPrims = [];
400 for (i=2; i<count; ++i)
401 {
402 if(i != exception)
403 {
404 llSetLinkPrimitiveParamsFast(i,
406 gHiddenPrims += [i];
407 }
408 }
409 }
410
411 reportSculptMode(key avatar)
412 {
413 if(avatar == NULL_KEY) avatar = llGetOwner();
414 string message = "Organizer set to normal texture mode.";
415 if(gSculptMode) message = "Organizer set to sculpty mode.";
416 // llRegionSayTo has a strange way of reporting chat to an avatar.
417 // it says 'objectname say, message'. This is acceptable but not ideal.
418 // we'll use it anyway because llInstantMessage eats a 2-second delay.
419 llRegionSayTo(avatar, 0, message);
420 }
421
422 reportSecurity(key avatar)
423 {
424 if(avatar == NULL_KEY) avatar = llGetOwner();
425 string message = "Organizer will only respond to the owner.";
426 if(gSecurityMode == SECURITY_GROUP) message = "Organizer will respond to users in its group.";
427 if(gSecurityMode == SECURITY_ALL) message = "Organizer will respond to all users.";
428 // llRegionSayTo has a strange way of reporting chat to an avatar.
429 // it says 'objectname say, message'. This is acceptable but not ideal.
430 // we'll use it anyway because llInstantMessage eats a 2-second delay.
431 llRegionSayTo(avatar, 0, message);
432 }
433
434
435 giveAllTextures(key avatar)
436 {
437 llGiveInventoryList(avatar, llGetObjectName(), gTextures);
438 }
439
440 default
441 {
443 {
444 // Set up the base prim's geometry.
445 llSetLinkPrimitiveParamsFast(LINK_ROOT, gBase);
446 // zero all the prims, or the accounting will be completely off
447 // for the other states.
448 zeroAllPrimsExcept(-1);
449 state browse;
450 }
451 }
452
453 state browse
454 {
456 {
457 gZoomTextureIndex = -1; // nothing zoomed.
458 gZoomTexturePrimIndex = -1;
459 llSetTimerEvent(0.1);
460 }
461
462 changed(integer change)
463 {
464 // did the user add some textures?
465 if(change & CHANGED_INVENTORY)
466 {
467 // yes, so update the object, after an acceptable delay.
468 llSetTimerEvent(5.0);
469 }
470 }
471
472 timer()
473 {
474 // we do all this on a timer so that there's some slack in the system
475 // and we don't have to re-update for each texture added en-masse.
476 gatherTextures();
477 setupTileGeometry();
478 calculateTilePositions();
479 repositionPrims();
480 showTextures();
481 base_browsePrevNext();
482 llSetTimerEvent(0.0);
483 }
484
485 touch_start(integer count)
486 {
487 // CLICKY CLICKY!
488 integer i;
489 // loop through all the detected*
490 for (i=0; i<count; ++i)
491 {
492 // check security on each touch.....
493 if(security(llDetectedKey(i)))
494 {
495 integer touchLink = llDetectedLinkNumber(i);
496 // did the user click the base control button prim?
497 if(touchLink == BUTTON_PRIM)
498 {
499 // yes, they did, so which button/face was it?
500 integer button = base_processTouch(llDetectedTouchFace(i));
501 if(button == BUTTON_PREV) // previous
502 {
503 if(gFirstTextureIndex <= 0) jump next;
504 else
505 {
506 gFirstTextureIndex -= gRows * gColumns;
507 if(gFirstTextureIndex < 0) gFirstTextureIndex = 0;
508 }
509 repositionPrims();
510 showTextures();
511 jump next;
512 }
513 if(button == BUTTON_NEXT) // next
514 {
515 integer textureCount = llGetListLength(gTextures);
516 integer tileCount = gRows * gColumns;
517 if(gFirstTextureIndex >= (textureCount - tileCount)) jump next;
518 else
519 {
520 gFirstTextureIndex += tileCount;
521 }
522 repositionPrims();
523 showTextures();
524 jump next;
525 }
526 if(button == BUTTON_CONFIG) // menu
527 {
528 // store the key of the avatar that clicked, so
529 // state config will know.
530 gConfigOperator = llDetectedKey(i);
531 state config;
532 }
533 }
534 else
535 {
536 // figure out which tile the user clicked on
537 integer currentTexture = gFirstTextureIndex + touchLink - 2;
538 if(currentTexture < llGetListLength(gTextures))
539 {
540 gZoomTextureIndex = currentTexture;
541 gZoomTexturePrimIndex = touchLink;
542 state zoom;
543 }
544 }
545 }
546 @next; // next for()....
547 }
548 // make sure the base shows the proper prev/next arrows
549 base_browsePrevNext();
550 }
551 }
552
553 state zoom
554 {
555 // this is where we zoom in on a given texture
557 {
558 // sanity check: if we don't have a current texture then go back to browsing.
559 if(gZoomTextureIndex == -1) state browse;
560 // first we hide all the non-zoom prims
561 zeroAllPrimsExcept(gZoomTexturePrimIndex);
562 // now we get the base size so we can figure out the zoom prim size
563 list params = llGetLinkPrimitiveParams(LINK_ROOT, [PRIM_SIZE]);
564 vector baseSize = llList2Vector(params, 0);
565 // set the zoom prim size. It should already have the texture on it.
566 float zoomDivisor = 15.0;
567 // wider prim for scupt mode
568 if(gSculptMode) zoomDivisor = 2.0;
569 llSetLinkPrimitiveParamsFast(gZoomTexturePrimIndex, [PRIM_SIZE,
570 <baseSize.x, baseSize.x/zoomDivisor, baseSize.x>,
572 <0.0, 0.0, (baseSize.x/2.0) + baseSize.z>
573 ]);
574 // and set the close button prim, which is always the last prim.
575 llSetLinkPrimitiveParamsFast(llGetObjectPrimCount(llGetKey()), gCloseButton +
576 [PRIM_SIZE, <baseSize.x * gTileMargin, baseSize.x * gTileMargin, baseSize.x/12.0>,
577 PRIM_POSITION, <baseSize.x / 2.0, 0.0, baseSize.z>
578 ]);
579 // turn off the prev/next buttons...
580 base_noPrevNext();
581 }
582
583 touch_start(integer count)
584 {
585 integer i;
586 // store this because we'll likely need it.
588 // cycle through per touch....
589 for (i=0; i<count; ++i)
590 {
591 // check security on each touch....
592 if(security(llDetectedKey(i)))
593 {
594 integer touchLink = llDetectedLinkNumber(i);
595 if(touchLink == BUTTON_PRIM)
596 {
597 integer baseButton = base_processTouch(llDetectedTouchFace(i));
598 if(baseButton == BUTTON_CONFIG)
599 {
600 gConfigOperator = llDetectedKey(i);
601 state config;
602 }
603 }
604 if(touchLink == gZoomTexturePrimIndex)
605 {
606 llGiveInventory(llDetectedKey(i), llList2String(gTextures, gZoomTextureIndex));
607 jump next;
608 }
609 if(touchLink == primCount)
610 {
611 llSetLinkPrimitiveParamsFast(primCount - 1, gCube + [PRIM_SIZE, ZERO_VECTOR, PRIM_POSITION, ZERO_VECTOR]);
612 state browse;
613 }
614 }
615 @next;
616 }
617 }
618
619 changed(integer what)
620 {
621 if(what & CHANGED_INVENTORY)
622 {
623 // the user updated the inventory in some way, so we
624 // go back to browsing.
625 state browse;
626 }
627 }
628
630 {
631 // force the other states to update the zoomed prim
632 gHiddenPrims += [gZoomTexturePrimIndex];
633 }
634 }
635
636 state config
637 {
638 // config is where we hide all the tiles,
639 // allow the user to get all of the textures in one folder, and sculpt mode.
640 // also let the owner set the security mode (owner, group, all)
642 {
643 key owner = llGetOwner();
644 // put away all the prims
645 zeroAllPrimsExcept(-1);
646
647 // put together the buttons
648 // which prims do we use for the buttons?
649 // we start at the highest prim and go backwards to preserve
650 // the textures on as many prims as possible. This way the
651 // viewer doesn't have to reload them.
653 gConfigSculptModePrim = count;
654 gConfigGiveAllPrim = count - 1;
655 gConfigSecurityOwnerPrim = count - 2;
656 gConfigSecurityGroupPrim = count - 3;
657 gConfigSecurityAllPrim = count - 4;
658
659 // now we get the base size so we can figure out the control prim sizes
660 list params = llGetLinkPrimitiveParams(LINK_ROOT, [PRIM_SIZE]);
661 vector baseSize = llList2Vector(params, 0);
662 // buttonSize is for the give-all and sculpty/texture-mode buttons.
663 vector buttonSize = <baseSize.x/2.5, baseSize.x/15.0, baseSize.x/2.5>;
664 // securityButtonSize is for the owner/group/all buttons
665 vector securityButtonSize = ZERO_VECTOR;
666 // if the user isn't also the owner, then don't show the security buttons.
667 if(gConfigOperator == llGetOwner())
668 {
669 float securityWidth = baseSize.x/3.05;
670 securityButtonSize = <securityWidth, baseSize.x/15.0, securityWidth/1.5>;
671 }
672
673 list buttonParams = gCube + [PRIM_SIZE, buttonSize,
674 PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, <1.0, 1.0, 0.0>, ZERO_VECTOR, 0.0,
676 PRIM_COLOR, ALL_SIDES, <0.5, 0.5, 0.5>, 1.0,
677 PRIM_FULLBRIGHT, 1, 1,
678 PRIM_COLOR, 1, <1, 1, 1>, 1.0,
679 PRIM_FULLBRIGHT, 3, 1,
680 PRIM_COLOR, 3, <1, 1, 1>, 1.0
681 ];
682
683 // set the sculpt mode prim....
684 vector sculptTextureOffset = <0.0, 0.333, 0.0>; // 'sculpt mode'
685 if(gSculptMode) sculptTextureOffset = <0,0,0>; // 'texture mode'
686 llSetLinkPrimitiveParamsFast(gConfigSculptModePrim, buttonParams +
687 [PRIM_POSITION, <0.0, 0.0, buttonSize.z + securityButtonSize.z>,
688 PRIM_TEXTURE, 1, gModeTexture, <1.0, 0.333, 0.0>, sculptTextureOffset, 0.0,
689 PRIM_TEXTURE, 3, gModeTexture, <1.0, 0.333, 0.0>, sculptTextureOffset, 0.0
690 ]);
691 // set the give-all prim
692 llSetLinkPrimitiveParamsFast(gConfigGiveAllPrim, buttonParams +
693 [PRIM_POSITION, <0.0, 0.0, (buttonSize.z * 2.1) + securityButtonSize.z>,
694 PRIM_TEXTURE, 1, gModeTexture, <1.0, 0.333, 0.0>, <0.0, -0.333, 0.0>, 0.0,
695 PRIM_TEXTURE, 3, gModeTexture, <1.0, 0.333, 0.0>, <0.0, -0.333, 0.0>, 0.0
696 ]);
697
698 // Owner security
699 llSetLinkPrimitiveParamsFast(gConfigSecurityOwnerPrim, buttonParams +
700 [PRIM_POSITION, <securityButtonSize.x * 1.1, 0.0, securityButtonSize.z * 1.2>,
701 PRIM_SIZE, securityButtonSize,
702 PRIM_TEXTURE, 1, gSecurityTexture, <1.0, 0.333, 0.0>, <0.0, 0.333, 0.0>, 0.0,
703 PRIM_TEXTURE, 3, gSecurityTexture, <1.0, 0.333, 0.0>, <0.0, 0.333, 0.0>, 0.0
704 ]);
705 // Group security
706 llSetLinkPrimitiveParamsFast(gConfigSecurityGroupPrim, buttonParams +
707 [PRIM_POSITION, <0.0, 0.0, securityButtonSize.z * 1.2>,
708 PRIM_SIZE, securityButtonSize,
709 PRIM_TEXTURE, 1, gSecurityTexture, <1.0, 0.333, 0.0>, <0.0, 0, 0.0>, 0.0,
710 PRIM_TEXTURE, 3, gSecurityTexture, <1.0, 0.333, 0.0>, <0.0, 0, 0.0>, 0.0
711 ]);
712 // All security
713 llSetLinkPrimitiveParamsFast(gConfigSecurityAllPrim, buttonParams +
714 [PRIM_POSITION, <0.0 - (securityButtonSize.x * 1.1), 0.0, securityButtonSize.z * 1.2>,
715 PRIM_SIZE, securityButtonSize,
716 PRIM_TEXTURE, 1, gSecurityTexture, <1.0, 0.333, 0.0>, <0.0, -0.333, 0.0>, 0.0,
717 PRIM_TEXTURE, 3, gSecurityTexture, <1.0, 0.333, 0.0>, <0.0, -0.333, 0.0>, 0.0
718 ]);
719 // turn off the prev/next controls
720 base_noPrevNext();
721 llSetTimerEvent(gConfigTimeout);
722 }
723
724 timer()
725 {
726 // We want to go back to browsing from config mode
727 // after a certain time. If the timer ever makes it here,
728 // then boom.
729 state browse;
730 }
731
732 touch_start(integer count)
733 {
734 llSetTimerEvent(gConfigTimeout);
735 integer i;
736 // cycle through per touch....
737 for (i=0; i<count; ++i)
738 {
739 // check security on each touch....
740 key av = llDetectedKey(i);
741 if(security(av))
742 {
743 integer touchLink = llDetectedLinkNumber(i);
744 if(touchLink == BUTTON_PRIM)
745 {
746 integer baseButton = base_processTouch(llDetectedTouchFace(i));
747 if(baseButton == BUTTON_CONFIG)
748 {
749 state browse;
750 }
751 }
752 if(touchLink == gConfigSculptModePrim)
753 {
754 if(gSculptMode) gSculptMode = FALSE;
755 else gSculptMode = TRUE;
756 vector sculptTextureOffset = <0.0, 0.333, 0.0>; // 'sculpt mode'
757 if(gSculptMode) sculptTextureOffset = <0,0,0>; // 'texture mode'
758 llSetLinkPrimitiveParamsFast(gConfigSculptModePrim, [
759 PRIM_TEXTURE, 1, gModeTexture, <1.0, 0.333, 0.0>, sculptTextureOffset, 0.0,
760 PRIM_TEXTURE, 3, gModeTexture, <1.0, 0.333, 0.0>, sculptTextureOffset, 0.0
761 ]);
762 reportSculptMode(av);
763 jump next;
764 }
765 if(touchLink == gConfigGiveAllPrim)
766 {
767 giveAllTextures(av);
768 jump next;
769 }
770 // only let the owner do these....
771 if(gConfigOperator == llGetOwner())
772 {
773 if(touchLink == gConfigSecurityOwnerPrim)
774 {
775 gSecurityMode = SECURITY_OWNER;
776 reportSecurity(av);
777 jump next;
778 }
779 if(touchLink == gConfigSecurityGroupPrim)
780 {
781 gSecurityMode = SECURITY_GROUP;
782 reportSecurity(av);
783 jump next;
784 }
785 if(touchLink == gConfigSecurityAllPrim)
786 {
787 gSecurityMode = SECURITY_ALL;
788 reportSecurity(av);
789 jump next;
790 }
791 }
792 }
793 @next;
794 }
795 }
796
797 changed(integer what)
798 {
799 if(what & CHANGED_INVENTORY)
800 {
801 // the user updated the inventory in some way, so we
802 // go back to browsing.
803 state browse;
804 }
805 }
806
808 {
809 // hide all the prims so browse will re-init them
810 zeroAllPrimsExcept(-1);
811 }
812 }

Texture Organizer

License

Category: Texture Organizer
By : Solo Mornington
Created: 2013-09-06 Edited: 2013-09-04
Worlds: Second Life

1
2
3
4 Texture Organizer
5
6 by Solo Mornington
7
8 Originally created for the Linden Endowment for the Arts sandbox, in Second Life. Visit sometime! http://slurl.com/secondlife/LEA5/122/129/24
9
10 This is a single-script texture organizer that does some fancy prim animating because I thought it might be neat.
11
12 FEATURES:
13
14 * Fancy prim animations. Woot.
15 * Totally free, open-source, FOSS-happy license.
16 * Security modes: Owner, group, or everyone can use the organizer.
17 * Sculpty mode: Have it show you all the textures as sculpties.
18 * 'Give All' button: Everyone knows how handy that is.
19 * Low lag, minimal prims...
20 * Notification of restrictive permissions on textures.
21
22 HOW TO USE THE SCRIPT:
23
24 1) Make an object with 22 prims.
25 2) Put the script in the object's root prim.
26 3) Add textures.
27 4) You're done.
28
29 RESOURCES:
30
31 Included in this repository is a set of images used to create the user interface of the texture organizer. The script refers to these textures in Second Life by UUID, so there is no need to upload them, as long as Solo Mornington has an inventory. :-)
32
33 LICENSE:
34
35 See the source code file for definitive licensing information.

Back to the Best Free Tools in Second Life and OpenSim.