Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

switch textures on two sides of prim

Hylee Bekkers
Registered User
Join date: 30 Apr 2007
Posts: 47
01-14-2009 12:20
I'm sure this is very simple but I have not been able to figure out how to do this. I would like to put several textures in a prim and have the prim display each of those textures one at a time on the front and back of the prim at the same time. I want to leave the top, bottom and sides of the prim transparent. I don't want to animate the texture or have it move at all. Any ideas? Thanks!
Quixotic Hermit
Registered User
Join date: 9 Nov 2008
Posts: 65
01-14-2009 12:23
Your edit menu has an option called SELECT TEXTURE. Enabling this feature will allow you to click on specific faces of a prim for individual texture options. Clicking on a face will show you a cross-hair icon indicating that side is selected. You can also shift-click multiple faces too. So, you can have one or two faces showing your texture, another face transparent, another face full bright only. Whatever your pleasure.
Hylee Bekkers
Registered User
Join date: 30 Apr 2007
Posts: 47
Thanks for the response, but that is not what I am trying to accomplish
01-14-2009 12:26
I probably did not explain it well.
I need a script to automatically cycle through textures on two sides of a prim like a slide show. I know how to do one side of a prim and all sides, but for the life of me I can not figure out how to do just two sides. Thanks :)
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
01-14-2009 12:30
Have you tried http://wiki.secondlife.com/wiki/LlGetTexture ?

edit: maybe something like...

SwapSides (integer sideA, integer sideB)
{
string texA = llGetTexture (sideA);

llSetTexture (llGetTexture (sideB), sideA);
llSetTexture (texA, sideB);
}
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
01-14-2009 12:31
If you are using llSetTexture(), you just need to add a second line which sets the texture of the other face as well. You can only address a single face (or ALL_FACES) with a single call to llSetTexture()

The same applies to llSetPrimitiveParams(), you need to add another set of parameters to address the second face.

~Boss
Quixotic Hermit
Registered User
Join date: 9 Nov 2008
Posts: 65
01-14-2009 12:33
From: Hylee Bekkers
I probably did not explain it well.
I need a script to automatically cycle through textures on two sides of a prim like a slide show. I know how to do one side of a prim and all sides, but for the life of me I can not figure out how to do just two sides. Thanks :)


Sorry "script" was not mentioned at all. But, looks like you've got the help you needed! :)
Hylee Bekkers
Registered User
Join date: 30 Apr 2007
Posts: 47
I think we are getting close
01-14-2009 12:41
Boss, it's the second line that I am not sure about. What would the second line look like and how is it formatted. I am not very good at scripting so it would be helpful if you could "dumb" it down a little for me. Thanks! ;)

This is for a Christmas Tree. I have a one texture that shows the tree with Red lights on, another with Green lights on, and nother with yellow lights on. I want the Christmas tree to look lik the lights are flashing different colors by cycling through the textures.

That's why I only want the texture to show up on the two sides and the others need to be transparent.

:)
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
01-14-2009 13:34
I apolgize for my brevity, I was answering based on your statement "I know how to do one side of a prim and all sides..." and assuming that you could just copy the line of a script twice.

Offhand I can think of two simple ways to do what you have described. Using llSetPrimitiveParams() might be more efficient but requires you to supply the texure offset as well as the name. I will demonstrate this with a third script at the bottom.

One would be the way you are thinking, which requires the script to address the two faces separately, with each call addressing one of the two faces. This version will work with more than just two faces, by adding them to the list as in list faces = [ 0, 2, 4 ];

CODE

integer texture_index = -1; // the index (in prim inventory) of the last texture shown

list faces = [ 2, 4 ]; // the face numbers to update

default
{
state_entry()
{
llSetTimerEvent(3.0); // 3 seconds per texture
}

timer()
{
integer count = llGetInventoryNumber(INVENTORY_TEXTURE);
if (count > 0)
{
texture_index = (texture_index + 1) % count;
string texture_name = llGetInventoryName(INVENTORY_TEXTURE, texture_index);
integer i = llGetListLength(faces);
while (i-- > 0) // count down the faces CLEVERNESS: post-decrement
llSetTexture(texture_name, llList2Integer(faces, i));
}
}

}


There seems to be some size limit posting so I will continue my reply in the next post.
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
01-14-2009 13:50
Alternately, you could simply set the faces you wish to hide to 100% transparent alpha, and set all faces with one call.
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
01-14-2009 13:51
CODE

integer texture_index = -1;

list faces = [ 2, 4 ];

default
{
state_entry()
{
llSetTimerEvent(3.0);

llSetAlpha(0.0, ALL_SIDES); // all faces clear
integer i = llGetListLength(faces);
while (i-- > 0) // count down the faces CLEVERNESS: post-decrement
llSetAlpha(1.0, llList2Integer(faces, i)); // set to visible
}

timer()
{
integer count = llGetInventoryNumber(INVENTORY_TEXTURE);
if (count > 0)
{
texture_index = (texture_index + 1) % count;
string texture_name = llGetInventoryName(INVENTORY_TEXTURE, texture_index);
llSetTexture(texture_name, ALL_SIDES); // apply texture
}
}
}
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
01-14-2009 13:53
This third version relates to the first, using llSetPrimtiveParams() with a list containing all the faces to update, so they all update at once leaving the other faces unchanged:

CODE

integer texture_index = -1; // the index (in prim inventory) of the last texture shown

list faces = [ 2, 4 ]; // the face numbers to update

default
{
state_entry()
{
llSetTimerEvent(3.0); // 3 seconds per texture
}

timer()
{
integer count = llGetInventoryNumber(INVENTORY_TEXTURE);
if (count > 0)
{
texture_index = (texture_index + 1) % count;
string texture_name = llGetInventoryName(INVENTORY_TEXTURE, texture_index);
integer i = llGetListLength(faces);
list output = [];
list repeats = [<1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0 ]; // repeats, offsets, rotation

while (i-- > 0) // build the list of faces
output = (output = []) + output + PRIM_TEXTURE + llList2Integer(faces, i) + texture_name + repeats;

if (output) // skip if output is empty
llSetPrimitiveParams(output);
}
}
}


For your purposes I think the second version would give the results you seek with the least amount of complexity.

~Boss
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
Discovering Prim Face Numbers
01-14-2009 14:10
In order to discover the face numbers for the script, you can enable the Advanced Menu with ctl-alt-D (if not already enabled); then in edit, check Select Textures and choose the faces in question; then press ctl-alt-shift-T or pick Advanced->Rendering->Selected Texture Info and you should see in chat something like:

Texture info for: Object
512x512 alpha on face 2 4

The face numbers (2 4) are listed there for you to use in the script.

~Boss
Hylee Bekkers
Registered User
Join date: 30 Apr 2007
Posts: 47
Boss! You are my Hero! :)
01-15-2009 13:20
Thanks!