Setting custom colors on primitives
|
Prismatic Penguin
Registered User
Join date: 1 Jul 2005
Posts: 8
|
01-09-2006 18:44
Hello all! i am trying to make a color change script to set custom colors on objects. I have gotten the llsetcolor() function to work fine with the 5 basic colors, red green, blue, white and black, however when i try to do a gray shade (rgb 128, 128, 12  it always ends up white... It seems like it takes a little longer for this to happen like as if white is a default color and my ranges dont match a specific range or something... If anyone can shed some light on this id appreciate it! thanks! P.S. More info available on request
|
Prismatic Penguin
Registered User
Join date: 1 Jul 2005
Posts: 8
|
01-09-2006 18:54
ok i got magenta to work (255, 0, 255)
is there a specific set of RGB integers that SL will only accept?
|
Jora Welesa
Dark Lady of the Sith
Join date: 11 Jul 2005
Posts: 153
|
01-09-2006 19:04
Hiya. Ok. Here's what's happening. Color is only in vectors with RGB values between 0 and 1. So the 128 was treated as 1 in all the values, resulting in white. A solution I found is to divide your vector by 255. That will give you corrected vector value..For instance: vector someColorVec = <128,128,128>; vector someColorRGB = someColorVec / 255; llSetColor(someColorRGB,ALL_SIDES);
This will let you use any standard RGB value, just be sure to divide it by 255 before you set it as the color. Hope that helps some.
|
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
|
01-10-2006 03:10
or divide manually before typing the numbers in. llSetColor( <0.5, 0.5, 0.5> ,ALL_SIDES); that way you do the work once, rather than asking SL to do it every time the colour changes. I know it's a small calculation - but if we all optimise just a little bit - the whole SL world benefits. some examples: <0.5 , 0.0 , 0.0> Dark Red <1.0 , 0.0 , 0.0> Red
<0.0 , 0.5 , 0.0> Dark Green <0.0 , 1.0 , 0.0> Green
<0.0 , 0.0 , 1.0> Blue
<0.5 , 0.5 , 0.0> Brown <1.0 , 1.0 , 0.0> Yellow <0.0 , 1.0 , 1.0> Cyan
|
Prismatic Penguin
Registered User
Join date: 1 Jul 2005
Posts: 8
|
01-10-2006 19:02
ahh yes, thank you for your assistance! These methods work great!
|
Prismatic Penguin
Registered User
Join date: 1 Jul 2005
Posts: 8
|
01-10-2006 19:22
Im pretty new to this scripting, so im now wondering how the best way to store values for a bunch of colrs. I looked into lists, but i really dont like the idea of loading every color value into a variable when i really only want to use one. Can i read data from a notecard or something? I was thinking if i could have my script listen for a color and then search for the string containing the name of the color and then parsing the following vector... Now where it gets that string and vector from is the question. Should i use a list? can i reference an external text (like a notecard or another script) ? Thank you for your patience and assistance, im still learning!
|
Jora Welesa
Dark Lady of the Sith
Join date: 11 Jul 2005
Posts: 153
|
01-10-2006 20:19
You can use a notecard, but the dataserver event required to read it is very slow by comparison to a list. I think what you can do is to have two lists. One list would hold the color name and the other list would hold the color values in the same positions. Alternativly, if you have predefined colors, what you can do is, assuming this is a listen event, have the listen check specifically for the color. For example: listen( integer channel, string name, key id, string message ) { if(msg == "color red") { llSetColor(<1.0,0.0,0.0>,ALL_SIDES); return; } if(msg == "color green") { llSetColor(<0.0,1.0,0.0>,ALL_SIDES); return; } if(msg == "color blue") { llSetColor(<0.0,0.0,1.0>,ALL_SIDES); return; } }
This method is probably the least memory intensive than using list or notecard.
|
Prismatic Penguin
Registered User
Join date: 1 Jul 2005
Posts: 8
|
01-10-2006 20:26
Hmm ok i was doing that and it gave me a syntax error out of the blue after i had entered so many colors, however i was not doing single if statements.... it was if() else. It gave me a syntax error out of the blue even though i was copying and pasting known good code, so i think my if/else statements were too long. I will give it a shot as all if statements and see how it goes! Thanks!!
|
Prismatic Penguin
Registered User
Join date: 1 Jul 2005
Posts: 8
|
01-10-2006 20:32
ok yes it works as a collection of sincle if statement evaluations.. chaining the if else statements fails after about 20 - 30 statements it seems.. but this will do the trick. I thank you again for the support and assistance!!
|
Jora Welesa
Dark Lady of the Sith
Join date: 11 Jul 2005
Posts: 153
|
01-10-2006 21:09
Anytime. 
|