Jump to content

Is it possible to "grab" the UUID of a specular texture on a worn item?


forensixpert
 Share

You are about to reply to a thread that has been inactive for 449 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi All,

I am relatively new to the scripting and design bit of SL. 

What I am trying to do is to make a hud that changes the color, texture and specular  of an item, user is wearing. I am using something like this;

integer channel = 00000;                                    // THE CHANNEL NUMBER ITEM IS LISTENING TO

integer tp      = LINK_THIS;                                // (TP = TargetPrim)
integer face    = ALL_SIDES;                                // This dress has  two faces but we want them both to change
vector r        = <1.0, 1.0, 0.0>;                          // repeat
vector o        = <0.0, 0.0, 0.0>;                          // offset
float rot       = 0.0;                                      // rotation
vector w    	= <1.000, 1.000, 1.000>;                    // color white
vector s   		= <0.749, 0.749, 0.749>;                    // color silver
vector g     	= <0.502, 0.502, 0.502>;                    // color grey
integer m       = 51;                                       // medium glosiness
integer h       = 71;                                       // high glosiness
integer e       = 0;                                        // environment

string st       = "a1a1a1a1-b1b1-c1c1-d1d1-e1e1e1e1e1e1";   // UUID of the specular texture (ST = SpecularTexture)

default
{
    state_entry()
    {
    llListen(channel,"",NULL_KEY,"");
    }

    listen(integer channel, string name, key id, string msg)
    {
    if (llGetOwner() == llGetOwnerKey(id))
        
        // ************* RESPOND TO TEXTURE CHANGE REQUEST
        
        if (msg == "DT1" )
        {
        llSetLinkPrimitiveParamsFast(tp,[ PRIM_TEXTURE, face, "0000000-0000-0000-0000-000000000", r, o, rot]);
        llSetLinkPrimitiveParamsFast(tp,[ PRIM_NORMAL, face, "0000000-0000-0000-0000-000000000", r, o, rot]);
        llSetLinkPrimitiveParamsFast(tp,[ PRIM_SPECULAR, face, "0000000-0000-0000-0000-000000000", r, o, rot, w, m, e]);

However, as you might appreciate I am using different specular maps for each diffuse texture. And currently I am only able to use the string, defined as st (as shown above). IS there any way I can pull the current specular texture so I can play with it's colors and shine levels? Below are the lines to set the shine options for the worn item (they also run under the same script)

// ************* RESPOND TO SHINE LEVEL CHANGE REQUEST
        
        else if (msg == "DS01" )
        {
        llSetLinkPrimitiveParamsFast(tp,[ PRIM_SPECULAR, face, st, r, o, rot, g, m, e]);
        }
        else if (msg == "DS02" )
        {
        llSetLinkPrimitiveParamsFast(tp,[ PRIM_SPECULAR, face, st, r, o, rot, g, h, e]);
        }
        else if (msg == "DS03" )
        {
        llSetLinkPrimitiveParamsFast(tp,[ PRIM_SPECULAR, face, st, r, o, rot, s, m, e]);
        }
        else if (msg == "DS04" )
        {
        llSetLinkPrimitiveParamsFast(tp,[ PRIM_SPECULAR, face, st, r, o, rot, w, m, e]);
        }
        else if (msg == "DS05" )
        {
        llSetLinkPrimitiveParamsFast(tp,[ PRIM_SPECULAR, face, st, r, o, rot, w, h, e]);
        }

Thank you so much if anybody can help and show me the way

Edited by forensixpert
Typonese
Link to comment
Share on other sites

  • forensixpert changed the title to Is it possible to "grab" the UUID of a specular texture on a worn item?

Get the specular date like this:

state_entry() {
    integer face = ALL_SIDES; // or whatever face you need the sspecular date for.
    list params = llGetLinkPrimitiveParams(LINK_THIS, [PRIM_SPECULAR, face]);
    string texture = llList2String(params, 0); 
    vector repeats = llList2Vector(params, 1);
    vector offsets = llList2Vector(params, 2);
    float rotation_in_radians = llList2Float(params, 3);
    vector color = llList2Vector(params, 4);
    integer glossiness = llList2Integer(params, 5);
    integer environment = llList2Integer(params, 6);
}

 

  • Like 1
Link to comment
Share on other sites

Please note that this won't work for other people unless the object has the right permissions that allow pulling the specular keys off it. I think it has to be transferrable and modifiable, but someone check me on that.

 

I ran into this exact same issue and ended up having to store the specular keys in a list in the receiver object.

Link to comment
Share on other sites

On 1/29/2023 at 2:41 PM, forensixpert said:

Below are the lines to set the shine options for the worn item (they also run under the same script)

// ************* RESPOND TO SHINE LEVEL CHANGE REQUEST
        
        else if (msg == "DS01" )
        {
        llSetLinkPrimitiveParamsFast(tp,[ PRIM_SPECULAR, face, st, r, o, rot, g, m, e]);
        }
        else if (msg == "DS02" )
        {
        llSetLinkPrimitiveParamsFast(tp,[ PRIM_SPECULAR, face, st, r, o, rot, g, h, e]);
        }
        else if (msg == "DS03" )
        {
        llSetLinkPrimitiveParamsFast(tp,[ PRIM_SPECULAR, face, st, r, o, rot, s, m, e]);
        }
        else if (msg == "DS04" )
        {
        llSetLinkPrimitiveParamsFast(tp,[ PRIM_SPECULAR, face, st, r, o, rot, w, m, e]);
        }
        else if (msg == "DS05" )
        {
        llSetLinkPrimitiveParamsFast(tp,[ PRIM_SPECULAR, face, st, r, o, rot, w, h, e]);
        }

Thank you so much if anybody can help and show me the way

Tangential, but y'all know how seeing lots of literal lists make me itch 😆

An alternative, less-memory-using way to implement your tests here:

else if (!llSubStringIndex(msg, "DS")) {
    msg = llGetSubString(msg, 2, -1);
    vector clr;
    integer gloss;
    if (msg == "01") {
        clr = g; gloss = m;
    }
    else if (msg == "02") {
        clr = g; gloss = h;
    }
    else if (msg == "03") {
        clr = s; gloss = m;
    }
    else if (msg == "04") {
        clr = w; gloss = m;
    }
    else if (msg == "05") {
        clr = w; gloss = h;
    }
    llSetLinkPrimitiveParamsFast(tp, [PRIM_SPECULAR, face, st, r, o, rot, clr, gloss, e]);
    // If no more possible processing
    return; 
}

Memory saving:

  • 1 list (as opposed to 5)
  • 3 func calls (as opposed to 5)
  • At the cost of 2 temporary variables (1 vector and 1 integer)
  • Sliiiightly slower since it involves 2 func calls before the decision tree

 

 

 

Link to comment
Share on other sites

On 1/31/2023 at 6:29 AM, primerib1 said:

Tangential, but y'all know how seeing lots of literal lists make me itch 😆

An alternative, less-memory-using way to implement your tests here:

else if (!llSubStringIndex(msg, "DS")) {
    msg = llGetSubString(msg, 2, -1);
    vector clr;
    integer gloss;
    if (msg == "01") {
        clr = g; gloss = m;
    }
    else if (msg == "02") {
        clr = g; gloss = h;
    }
    else if (msg == "03") {
        clr = s; gloss = m;
    }
    else if (msg == "04") {
        clr = w; gloss = m;
    }
    else if (msg == "05") {
        clr = w; gloss = h;
    }
    llSetLinkPrimitiveParamsFast(tp, [PRIM_SPECULAR, face, st, r, o, rot, clr, gloss, e]);
    // If no more possible processing
    return; 
}

Memory saving:

  • 1 list (as opposed to 5)
  • 3 func calls (as opposed to 5)
  • At the cost of 2 temporary variables (1 vector and 1 integer)
  • Sliiiightly slower since it involves 2 func calls before the decision tree

 

 

 

More tidy too :) Thanks

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 449 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...