Jump to content
MSTRPLN

HUD toggle

Recommended Posts

Sorry to be a pain, im running into a issue to a point where im totally clueless, things that make sense won't even work anymore. Unfortunately there isn't any information or documentation on these type of things but yet ther are everywhere in sl (Texture changer for clothing, meshbody HUDS etc)

I started with 2 linksets

1. Target: 2 objects of which textures will be changable
2.  Sender: 6 objects with each a different function when clicked.

The target is simple the catch is as follows:
[5] [6]
[3] [4]
[2] [1]

5 = All function (sets all target cubes to enable textures being changed). (Also changes buttons "Left" & "Right" to green = enabled)
6 = None function (ets all target cubes to disable textures being changed). (Also changes buttons "Left" & "Right" to white = disabled)
3 = Changes to texture #1.
4 = Changes to texture #2.
2 = Toggles left cube to enable textures being changed. (also toggles colors on button itself green = enabled, white = disabled)
1 = Toggles right cube to enable textures being changed. (also toggles colors on button itself green = enabled white = disabled)

i only got 2 cubes for now but it might be more.

Receive Script:

// Script for texture changer receiver
integer channel = -50508;
// Channel is the integer for reception (number mus the same as a transmission channel otherwise script will not work)

default
{
        state_entry()
        {
            llListen(channel, "", NULL_KEY, "");
        }
        
        listen(integer channel, string name, key id, string msg)
        {
            
            if (llGetOwner() == llGetOwnerKey(id))
            // Checks if the owner of the object who is sending a message its the same owner of the receiver
            {
                // Front Face
                if (msg == "tex1Left")
                {
                        llSetLinkTexture(1, "2433879f-6116-1521-38c0-eb86f2ce607a", 4);
                }
                if (msg == "tex1Right")
                {
                        llSetLinkTexture(2, "2433879f-6116-1521-38c0-eb86f2ce607a", 4);
                }
                if (msg == "tex2Left")
                {
                        llSetLinkTexture(1, "df50ac59-b871-b00f-e3c5-2633c4f1cb6e", 4);
                }
                if (msg == "tex2Right")
                {
                        llSetLinkTexture(2, "df50ac59-b871-b00f-e3c5-2633c4f1cb6e", 4);
                }
                // Else
            }
        }    
}

Transmit Script:

// Choose any number up for 1024 as the channel for the transmission
integer channel = -50508;

integer toggle;

integer Left;
integer Right;

default
{
    on_rez(integer star_param)
    {
    }
    
     touch_start(integer tn)
    {
        toggle = !toggle; 
        if (llDetectedLinkNumber(0) == 3)
        {
            if(Left == toggle && Right != toggle)
            {
                llOwnerSay("Left tex1");
                llRegionSay(channel, "tex1Left");
            }
            else if(Right == toggle && Left != toggle)
            {
                llOwnerSay("Right tex1");
                llRegionSay(channel, "tex1Right");
            }
        }
        else if (llDetectedLinkNumber(0) == 4)
        {
            if(Left == toggle && Right != toggle)
            {
                llOwnerSay("Left tex2");
                llRegionSay(channel, "tex2Left");
            }
            if(Right == toggle && Left != toggle)
            {
                llOwnerSay("Right tex2");
                llRegionSay(channel, "tex2Right");
            }
        }
        else if (llDetectedLinkNumber(0) == 2)
        {
            if(toggle)
            {
               llSetLinkColor(2, <0.0, 1.0, 0.0>, 4);
            }
            else
            {
                llSetLinkColor(2, <1.0, 1.0, 1.0>, 4);
            }
        }
        else if (llDetectedLinkNumber(0) == 1)
        {
            if(toggle)
            {
               llSetLinkColor(1, <0.0, 1.0, 0.0>, 4); 
            }
            else
            {
                llSetLinkColor(1, <1.0, 1.0, 1.0>, 4);
            }
        }
        else if (llDetectedLinkNumber(0) == 5)
        {
            llSetLinkColor(2, <0.0, 1.0, 0.0>, 4);
            llSetLinkColor(1, <0.0, 1.0, 0.0>, 4);
        }
        else if (llDetectedLinkNumber(0) == 6)
        {
            llSetLinkColor(2, <1.0, 1.0, 1.0>, 4);
            llSetLinkColor(1, <1.0, 1.0, 1.0>, 4);
        }
    }
}

The llOwnerSay(Left tex1); etc is just for debugging to see if that part is working

Right now im not too worried about making the scripts "validatable" my main concern is making it work and then perfecting it

i've tried a list, string list2string but i can't seem to get it to work, i tink a list of objects available (specially for the "ALL" button) would be more effective and less code

 

If it's too hard to understand what i want is:

1. being able to change the textures of different linknumbers & faces (for now only linknumbers)
2. toggle which linknumber a texture would be changed for (including a ALL & NONE button)

Screenshot_1.png

Screenshot_2.png

Edited by MSTRPLN

Share this post


Link to post
Share on other sites

I am not at home now, so I can't log in to test this.  Off the top of my head, though, something like this ought to work:

list lColors = [1,1];
integer channel = -50508;

default
{
    touch_start(integer num)
    {
        integer iButton = llDetectedLinkNumber(0);
        if (iButton == 5 )
        {
            lColors = [0,0];
            llSetLinkColor(5,<0,1,0>,ALL_SIDES);
            llSetLinkColor(1,<0,1,0>,ALL_SIDES);
            llSetLinkColor(2,<0,1,0>,ALL_SIDES);
        }
        else if (iButton == 6)
        {
            lColors = [1,1];
            llSetLinkColor(5,<1,1,1>,ALL_SIDES);
            llSetLinkColor(1,<1,1,1>,ALL_SIDES);
            llSetLinkColor(2,<1,1,1>,ALL_SIDES);
        }
        else if ( iButton == 1 )
        {
            lColors = llListReplaceList(lColors, [!llList2Integer(lColors,0)],0,0);
            integer ON = llList2Integer(lColors,0);
            llSetLinkColor(1,<ON,1,ON>,ALL_SIDES);
        }
        else if ( iButton == 2 )
        {
            lColors = llListReplaceList(lColors,[!llList2Integer(lColors,1)],1,1);
            integer ON = llList2Integer(lColors,1);
            llSetLinkColor(2,<ON,1,ON>,ALL_SIDES);
        }
        else if ( iButton == 3 )
        {
            if ( llList2Integer(lColors,0) == 0)
            {
                llOwnerSay("Left tex2");
                llRegionSay(channel, "tex2Left");
            }
            if ( llList2Integer(lColors,1) == 0)
            {
                llOwnerSay("Right tex2");
                llRegionSay(channel, "tex2Right");
            }
        }
        else if ( iButton == 4 )
        {
            if ( llList2Integer(lColors,0) == 0)
            {
                llOwnerSay("Left tex1");
                llRegionSay(channel, "tex1Left");
            }
            if ( llList2Integer(lColors,1) == 0)
            {
                llOwnerSay("Right tex1");
                llRegionSay(channel, "tex1Right");
            }
        }
        llOwnerSay(llList2CSV(lColors));
    }
}

That is, if I have understood what you are trying to do.  :)

Share this post


Link to post
Share on other sites

I'm still away from home, but it occurs to me that you may want to add a couple more llSetLinkColor statements in obvious places so that either button 5 and 6, when clicked, will set the other one white.  Do the same to set buttons 5 and 6 both white if you click either button 1 or 2.  Those are easy, small additions.  Again, I haven't been able to log in and test my script, but its logic looks correct to me.  It shouldn't take much banging on it to make it into something you can use.

Share this post


Link to post
Share on other sites

Thank you, this works as i wanted (although when changign textures with "ALL" toggled there seem to be a little delay between them but i might aswell remove that function and just have the "none" (for my purpose)

a little question about impact/memory/load, i have a little example here done in the beta grid, would it be smarter to have every face (the different 6 colored faces) be a empty texture or toggle the llSetAlpha between 1.0 and 0.0 ? The decal faces lay on top of the road so they are not part of the road texture (seperate mesh)

 

 

Screenshot_3.png

Screenshot_4.png

Edited by MSTRPLN

Share this post


Link to post
Share on other sites

I suspect that the little delay is due to the time it takes your graphics card to recognize and render the new texture.  You can beat that by "preloading" the texture the sam way that it's commonly done in slide shows. Put both textures on hidden faces of your object (underneath, perhaps or on small child prims ...). As long as they are somewhere within a visitor's draw distance, they will be loaded by his viewer and thus immediately available for rendering when you apply them later on visible faces.

I'm not quite sure what you are asking about the 6 colored faces but in general, as soon as you display any texture within a visitor's draw distance, the texture is cached in his graphics card's memory.  If you are concerned about how much memory that is taking, you can help the person out by using the smallest practical pixel density (256 x 256 instead of 512 x 512, for example) or (if you are not planning to have the user display the texture right away) you can choose not to display it at all.  Wait and display it only when it's actually needed.  As noted above, that will mean a slight delay in rendering time, but you may be comfortable with that delay as a trade-off.   Once you have displayed a texture, making it disappear with alpha won't release any memory, if that's what you are asking.  The graphics card already knows that it's there.

 

 

Share this post


Link to post
Share on other sites

I understand, i just noticed that the "fatpack HUD" (texture changer) of Valekoer's Hoodie changed textures rather fast (even with multiple parts selected (sleeve, torso etc) but that might be because those textures were in my cache aready.

well to make it simple, would it be best to hide the non-used faces with a empty png texture or just set the alpha to 0 (clicking  "None" would set all faces alpha to 0 untill a texture is applied to one of them then it will change it's alpha back to 1)

i tested 2 exact same copies with the prim info tab open, the one with unused faces set to alpha 0 (no textures) had a slightly less Display value than the one with all faces set to alpha 1 and non used faces texture empty png

Share this post


Link to post
Share on other sites
6 minutes ago, MSTRPLN said:

well to make it simple, would it be best to hide the non-used faces with a empty png texture or just set the alpha to 0 (clicking  "None" would set all faces alpha to 0 untill a texture is applied to one of them then it will change it's alpha back to 1)

There is no such thing as an "empty" texture.  The BLANK texture, UUID 5748decc-f629-461c-9a36-a35a221fe21f , is still a texture and so is the full transparent texture, UUID 8dcd4a48-2d37-4909-9f78-f7a9eb4ef90 , in your inventory's Library folder any other image that you want to use as a dummy placeholder.  Any of them will use graphics memory as soon as they are within a visitor's viewing range.  And alpha = 0.0 (or any other value) has no meaning except in the context of a texture. You can't set alpha on "nothing".

Share this post


Link to post
Share on other sites

Okay that made things clear, because i uploaded a png with "nothing" in it because else the face would be white (or whatever color it's set to) thats the reason of my question, a transparent texture or setting the "transparency" by script

Share this post


Link to post
Share on other sites

OK, so we're back to the answer I posted above.  If you expect a texture to be used, you might as well display it and then make it visible or transparent as needed.  Once it's displayed, changing transparency isn't going to affect how much cache memory it's using for whoever is viewing it.  If it's only one of several possible textures that might be used sometime but  visitors aren't likely to change very often, it probably makes sense to load just one texture -- whether it's a full transparent texture or one of your set of six -- as a default and then load any others as needed later.  If you expect users to keep changing the textures all the time, or if you want to reduce their rendering time by "preloading" as I described above, then it makes sense to display all six of them.

Share this post


Link to post
Share on other sites

Yes, it's probably going to be used once, so i thought a "empty" transparent texture would be better than to toggle the alpha in the script for each face, unless im wrong i thought that was havier on performance than a transparent texture

Share this post


Link to post
Share on other sites

Rather than using 8 different textures, why not try using one single large texture, divided into 8, and moving it by changing the texture offset?   That way, it loads only once, when the visitor first arrives in the region and sees the road, no matter which part of the texture is displayed at the time.   

  • Like 1

Share this post


Link to post
Share on other sites
7 hours ago, Innula Zenovka said:

Rather than using 8 different textures, why not try using one single large texture, divided into 8, and moving it by changing the texture offset?   That way, it loads only once, when the visitor first arrives in the region and sees the road, no matter which part of the texture is displayed at the time.   

I don't even know why when i thought about that i was thinking "how could i change uv positions like sprites" ut yeah texture offset is how,  thanks!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...