JackRipper666 Posted May 30, 2018 Share Posted May 30, 2018 Hello again, I've never tried this before so not sure how it works. Would someone be able to enlighten me if it's possible to use a script to adjust the glossiness only of a prim? I tried prim_specular as with llSetPrimitiveParamsFast but it always wants a texture in the inventory. Is there another way? Link to comment Share on other sites More sharing options...
Klytyna Posted May 31, 2018 Share Posted May 31, 2018 // Materials applier basis integer primnum = 1; integer facenum = 1; integer gloss = 150; integer env = 25; vector speccolour = < 1.00, 1.00, 1.00>; vector diffcolour = < 0.95, 0.95, 0.95>; float alpha = 1.0; // diffuse / normal / specular maps string texdiff = "<put the UUID of the diffuse texture map here>"; string texnorm = "<put the UUID of the normals texture map here>"; string texspec = "<put the UUID of the speculat texture map here>"; default{ state_entry() { // Here we go... delete the sub lines you don't need for diff texture, colour normals etc. llSetLinkPrimitiveParamsFast( primnum, [ PRIM_TEXTURE, ALL_SIDES, texdiff, <1.0, 1.0, 0.0>, ZERO_VECTOR,0.0, PRIM_COLOR, ALL_SIDES, diffcolour, alpha, PRIM_NORMAL, ALL_SIDES, texnorm, <1.0, 1.0, 0.0>, ZERO_VECTOR,0.0, PRIM_SPECULAR, ALL_SIDES, texspec, <1.0, 1.0, 0.0>, ZERO_VECTOR,0.0, speccolour, gloss, env ]); // ...or llSetLinkPrimitiveParamsFast( 6, [ PRIM_TEXTURE, faenum, texdiff, <1.0, 1.0, 0.0>, ZERO_VECTOR,0.0, PRIM_COLOR, facenum, diffcolour, alpha, PRIM_NORMAL, facenum, texnorm, <1.0, 1.0, 0.0>, ZERO_VECTOR,0.0, PRIM_SPECULAR, facenum, texspec, <1.0, 1.0, 0.0>, ZERO_VECTOR,0.0, speccolour, gloss, env ]); } } There... You just use the UUID's of the textures you want to set for spec (say a blank white texture for example, or the spec map you made for the item), 2 Link to comment Share on other sites More sharing options...
Rolig Loon Posted May 31, 2018 Share Posted May 31, 2018 In other words, yes, you always need to supply a specular texture. How else would you propose to adjust its parameters? If you don't have a custom texture, use TEXTURE_BLANK. 1 Link to comment Share on other sites More sharing options...
JackRipper666 Posted May 31, 2018 Author Share Posted May 31, 2018 (edited) Thanks for the help Klytna and Rolig. Unfortunately that won't work for what I'm trying to accomplish. I have two meshes that are cut in many pieces linked together. I don't want to have to script each small piece with their correct spec map. I was hoping with the spec maps that I have applied before I linked them together that I would be able to adjust only the glossiness parameter with a script. If I use TEXTURE_BLANK, would that take off the applied spec map? I can try that at least see if it keeps what's there but only adjusts glossiness. Edited May 31, 2018 by JackRipper666 Link to comment Share on other sites More sharing options...
Rolig Loon Posted May 31, 2018 Share Posted May 31, 2018 Yes, it would replace your custom spec map. Since you already have the spec maps, though, just use their UUIDs. Making a SLPPF statement that addresses all of the child mesh elements is not terribly difficult, especially since you want to apply the same spec parameters to each one. You can create a single brief list variable with those params in it and then just paste it into the SLPPF statement following the link number and texture UUID for each link. That's what I normally do. 1 Link to comment Share on other sites More sharing options...
KT Kingsley Posted May 31, 2018 Share Posted May 31, 2018 (edited) If you have the correct permissions for the specular map texture you could use llGetLinkPrimitiveParams to get the key for the texture – indeed all the parameters – and just replace the glossiness parameter in the resulting list before feeding it back through to llSetLinkPrimitiveParamsFast. Something like… llSetLinkPrimitiveParamsFast (link_number, [PRIM_SPECULAR, face] + llListReplaceList (llGetLinkPrimitiveParams (link_number, [PRIM_SPECULAR, face]), [glossiness], 5, 5)); where link_number, face and glossiness are your specified parameters, and 5 is the position of glossiness in the list of parameters for PRIM_SPECULAR. WARNING: not tested inworld, and posted after a glass or two of wine. There's long been a desire, and maybe even a JIRA or two, for a LEAVE_IT_ALONE parameter to use in llSetLinkPrimitiveParams. Edited May 31, 2018 by KT Kingsley 1 Link to comment Share on other sites More sharing options...
Rolig Loon Posted May 31, 2018 Share Posted May 31, 2018 That should work as long as you have the spec textures in your own inventory, but that will probably not be true if you intend to give the scripted item to someone else. However, it's easy enough to put the UUIDs into a list in your script and then refer to it as necessary when you create the SLPPF statement. 1 Link to comment Share on other sites More sharing options...
Xiija Posted May 31, 2018 Share Posted May 31, 2018 (edited) if it is just for yourself, you could mebbe do a user function with something like this in it? ( untested snippet) integer new_Gloss = 250; SET_GLOSS() // user func { integer prims = llGetObjectPrimCount( llGetKey() ); integer curr_link; for( curr_link = 1; curr_link <= prims; ++curr_link) // cycle thru prims { integer numOfSides = llGetLinkNumberOfSides( curr_link ); integer curr_face; for(curr_face = 0; curr_face <= numOfSides; ++curr_face) // cycle thru faces per prim { list params = llGetLinkPrimitiveParams( curr_link, [ PRIM_SPECULAR, curr_face ]); string S_texture = llList2String( params,0 ); vector V_repeats = llList2Vector( params,1 ); vector V_offsets = llList2Vector( params,2 ); float F_rotation_in_radians = llList2Float( params,3 ); vector V_color = llList2Vector( params,4 ); integer I_glossiness = llList2Integer( params,5 ); integer I_environment = llList2Integer( params,6 ); I_glossiness = new_Gloss; llSetLinkPrimitiveParamsFast( curr_link, [ PRIM_SPECULAR, curr_face, S_texture, V_repeats, V_offsets, F_rotation_in_radians, V_color, I_glossiness, I_environment ]); } } } Edited May 31, 2018 by Xiija 1 Link to comment Share on other sites More sharing options...
Rolig Loon Posted May 31, 2018 Share Posted May 31, 2018 Because most of those params are simply repeated for each link, you can compress them into a single list ... list params = [<1,1,1>,ZERO_VECTOR,0.0,<1,1,1>,51,2]; Then your SLPPF statement looks something like llSetLinkPrimitiveParamsFast(LINK_SET,[34,1,PRIM_SPECULAR,texture1]+params+[34,2,PRIM_SPECULAR,texture2]+params+ ...); and so on. I'm sure that I left out a param (I am away from home and creating this from memory) , but that's the general idea. 1 Link to comment Share on other sites More sharing options...
Klytyna Posted June 1, 2018 Share Posted June 1, 2018 11 hours ago, JackRipper666 said: Unfortunately that won't work for what I'm trying to accomplish. I have two meshes that are cut in many pieces linked together. I don't want to have to script each small piece with their correct spec map. I was hoping with the spec maps that I have applied before I linked them together that I would be able to adjust only the glossiness parameter with a script. Check the lsl wiki for llSetLinkOrimitiveParamsFast, you'll find that there's syntax for specifying "blocks" for different prims, so ... llSetLinkPrimitiveParamsFast( [block for prim 1 all faces using list entry texturespec(1)] [block for prim 1 face 4 using list entry texturespec()2)] //if say 6 faces on a prim use 1 texture and 1 uses a different texture, its faster to set all_sides first then set thye odd one out separately afterwards, than setting all 6 one at a time <snip> [block for prim 36 using list entry texturespec(36)] ); And Xiija's code shows how to grab the existing prim/face spec textures, so you grab the textures for the linkset prims, stick them in a list, and then your multi block llSetLinkPrimitiveParamsFast command can set the specular glossiness with the current textures for each prim/face, all in one go, This is how mesh body appliers change all the pieces together rather than one at a time with a 0.2 second delay between pieces as you "mosaic" into a different skin, or tattoo or clothing layer. However, while you can get the textures on your own stuff, if it's for a product you intend to give or sell to others, just use a list definition line at the top of the script with the uuid ofeach texture in the order you'll apply them. list texturespec = ; 1 Link to comment Share on other sites More sharing options...
JackRipper666 Posted June 1, 2018 Author Share Posted June 1, 2018 On 5/31/2018 at 10:18 AM, KT Kingsley said: If you have the correct permissions for the specular map texture you could use llGetLinkPrimitiveParams to get the key for the texture – indeed all the parameters – and just replace the glossiness parameter in the resulting list before feeding it back through to llSetLinkPrimitiveParamsFast. Something like… llSetLinkPrimitiveParamsFast (link_number, [PRIM_SPECULAR, face] + llListReplaceList (llGetLinkPrimitiveParams (link_number, [PRIM_SPECULAR, face]), [glossiness], 5, 5)); where link_number, face and glossiness are your specified parameters, and 5 is the position of glossiness in the list of parameters for PRIM_SPECULAR. WARNING: not tested inworld, and posted after a glass or two of wine. There's long been a desire, and maybe even a JIRA or two, for a LEAVE_IT_ALONE parameter to use in llSetLinkPrimitiveParams. Thanks everyone for your help! Much appreciated! I am going to give this a try as I'm really trying to just target the glossiness only as I have spec maps manually plugged in. Link to comment Share on other sites More sharing options...
Recommended Posts
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