Help with llGetSunDirection
|
|
Holocluck Henly
Holographic Clucktor
Join date: 11 Apr 2008
Posts: 552
|
09-06-2008 09:36
Yes, the scripting moron is back. I suppose if my needs were simple, my probs with scripting wouldnt be so tough.
I have a building, and I want certain prims on it to go fullbright at night to effect neon. I have a piece of script which is supposed to achieve this and I need it checked since - well, because I'm a scripting moron.
**** script **** integer night=0; // 0 = daytime, 1 = nighttime
default { state_entry() { llSetTimerEvent(300); // Check every 5 minutes } timer() { vector sun = llGetSunDirection(); if (sun.z <= 0) night = 1; // Sun is below the horizon else if (sun.z > 0) night = 0; // Sun is above the horizon } touch_start(integer total_number) { if (night == 1) llSetPrimitiveParams(PRIM_FULLBRIGHT=TRUE, 1); else if (night == 0) llSetPrimitiveParams(PRIM_FULLBRIGHT=FALSE, 1); } }
***first script ***
I'm a little confused about there being a touch_start in this. Why would it be touch start?
Also some basic questions:
1. if the prims were part of a linked set, will those prims alone glow, or will the entire linked set glow? 2. how can one specify a face versus the entire prim? Are all faces of the prim fullbright by default?
Meanwhile, I also want the building inside to be illuminated at night. This wiki site script is supposed to achieve that:
*** wiki script ***
integer lightsOn = -1;//not TRUE or FALSE CheckSun() { vector sun = llGetSunDirection(); integer turnLightsOn = (sun.z < 0); if(turnLightsOn != lightsOn) { lightsOn = turnLightsOn; llSetPrimitiveParams([ PRIM_FULLBRIGHT, ALL_SIDES, lightsOn ]); } }
*** end wiki script ***
I noticed in a cottage I bought that there is an invisible object in the room. Is it customary to have an invisible phantom object for a lightsource at night?
Why does one script have CheckSun but not the other?
Thanks!
_____________________
 Photostream: www.flickr.com/photos/holocluck Holocluck's Henhouse: New Eyes on the Grid: holocluck@blogspot
|
|
Beezle Warburton
=o.O=
Join date: 10 Nov 2006
Posts: 1,169
|
09-06-2008 09:40
From: Holocluck Henly Yes, the scripting moron is back. I suppose if my needs were simple, my probs with scripting wouldnt be so tough.
I have a building, and I want certain prims on it to go fullbright at night to effect neon. I have a piece of script which is supposed to achieve this and I need it checked since - well, because I'm a scripting moron.
**** script **** integer night=0; // 0 = daytime, 1 = nighttime
default { state_entry() { llSetTimerEvent(300); // Check every 5 minutes } timer() { vector sun = llGetSunDirection(); if (sun.z <= 0) night = 1; // Sun is below the horizon else if (sun.z > 0) night = 0; // Sun is above the horizon } touch_start(integer total_number) { if (night == 1) llSetPrimitiveParams(PRIM_FULLBRIGHT=TRUE, 1); else if (night == 0) llSetPrimitiveParams(PRIM_FULLBRIGHT=FALSE, 1); } }
***first script ***
I'm a little confused about there being a touch_start in this. Why would it be touch start?
Also some basic questions:
1. if the prims were part of a linked set, will those prims alone glow, or will the entire linked set glow? 2. how can one specify a face versus the entire prim? Are all faces of the prim fullbright by default?
Meanwhile, I also want the building inside to be illuminated at night. This wiki site script is supposed to achieve that:
*** wiki script ***
integer lightsOn = -1;//not TRUE or FALSE CheckSun() { vector sun = llGetSunDirection(); integer turnLightsOn = (sun.z < 0); if(turnLightsOn != lightsOn) { lightsOn = turnLightsOn; llSetPrimitiveParams([ PRIM_FULLBRIGHT, ALL_SIDES, lightsOn ]); } }
*** end wiki script ***
I noticed in a cottage I bought that there is an invisible object in the room. Is it customary to have an invisible phantom object for a lightsource at night?
Why does one script have CheckSun but not the other?
Thanks! I use a single invisible prim for the real light source if there are multiple lamps. For example, I have four torches in a square, but the real light source is in the center of them and a bit higher than the top of the torches. This allows a lot more leeway for the maddening 6-light limit.
_____________________
Though this be madness, yet there is method in't. -- William Shakespeare Warburton's Whimsies: In SLApez.biz
|
|
Alicia Sautereau
if (!social) hide;
Join date: 20 Feb 2007
Posts: 3,125
|
09-06-2008 09:56
default { state_entry() { llSetTimerEvent(300); // Check every 5 minutes }
timer() { vector sun = llGetSunDirection(); if (sun.z <= 0) llSetPrimitiveParams(PRIM_FULLBRIGHT=FALSE, 1); if (sun.z > 0) llSetPrimitiveParams(PRIM_FULLBRIGHT=TRUE, 1); } }
not loggedin so might have an error but this should give an idea the touch in the first script on the wiki is so you can see if it`s day or night what the script regards (sim time, not client)
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
09-06-2008 10:50
From: Alicia Sautereau default { state_entry() { llSetTimerEvent(300); // Check every 5 minutes }
timer() { vector sun = llGetSunDirection(); if (sun.z <= 0) llSetPrimitiveParams(PRIM_FULLBRIGHT=FALSE, 1); if (sun.z > 0) llSetPrimitiveParams(PRIM_FULLBRIGHT=TRUE, 1); } }
not loggedin so might have an error but this should give an idea the touch in the first script on the wiki is so you can see if it`s day or night what the script regards (sim time, not client) Here and in Alicias initial example llSetPrimitiveParams([]) is used wrongly, should be: llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, TRUE]); if you want full bright on all sides. The second parameter is substtuted with a number for the face if you want just one side full bright. TRUE is substituted with FALSE if you want it off. This should answer the question about sides. llSetPrimitiveParams([]) only affects the prim it is in. (So easy to test!) 
_____________________
From Studio Dora
|
|
Beezle Warburton
=o.O=
Join date: 10 Nov 2006
Posts: 1,169
|
09-06-2008 10:52
integer which_side = ALL_SIDES;
// light parameters vector light_color = <1,1,0.75>; float intensity = 1.0; // 0.0 to 1.0 float radius = 12.0; // 0.0 to 20.0 float falloff = 0.1; // 0.0 to 2.0
// prim color and alpha vector color_on = <1,1,0.5>; vector color_off = <0.75,0.75,0.25>;
float alpha_on = 0.75; // 0.0 to 1.0 float alpha_off = 1.0;
vector sun; default { state_entry() { llSetPrimitiveParams([ PRIM_POINT_LIGHT, FALSE, light_color, intensity, radius, 0.1, PRIM_GLOW, which_side, 0.0, PRIM_FULLBRIGHT, which_side, FALSE, PRIM_COLOR, which_side, color_off, alpha_off ]); sun = llGetSunDirection(); // check in case it's rezzed in this state if (sun.z < 0) { state night; } llSetTimerEvent(600); } timer() { sun = llGetSunDirection(); if (sun.z < 0) { state night; } } } state night { state_entry() { llSetPrimitiveParams([ PRIM_POINT_LIGHT, TRUE, light_color, intensity, radius, 0.1, PRIM_GLOW, which_side, 0.05, PRIM_FULLBRIGHT, which_side, TRUE, PRIM_COLOR, which_side, color_on, alpha_on ]); sun = llGetSunDirection(); // check in case it's rezzed in this state if (sun.z >= 0) { state default; } llSetTimerEvent(600); } timer() { sun = llGetSunDirection(); if (sun.z >= 0) { state default; } } }
Also dropped a copy in-world because the forum borks formatting. You don't have to declare parameters at the top, just did it for versatility, and ease of other's use.
_____________________
Though this be madness, yet there is method in't. -- William Shakespeare Warburton's Whimsies: In SLApez.biz
|
|
Holocluck Henly
Holographic Clucktor
Join date: 11 Apr 2008
Posts: 552
|
09-06-2008 11:49
thanks all...
Still questions...
1- Re the linked set? Will the entire link be prone to this or just the prims containing the script re fullbright?
2- So if I wanted one or more faces on a prim to be subject to this change (I dont, but), how is that specified?
3 - Beez, yours looks considerably more detailed. Is it just that the script engine can take "abbreviations" and fill in missing parameters and you've written everything out? What is "float falloff"?
_____________________
 Photostream: www.flickr.com/photos/holocluck Holocluck's Henhouse: New Eyes on the Grid: holocluck@blogspot
|
|
Beezle Warburton
=o.O=
Join date: 10 Nov 2006
Posts: 1,169
|
09-06-2008 11:57
From: Holocluck Henly thanks all...
Still questions...
1- Re the linked set? Will the entire link be prone to this or just the prims containing the script re fullbright?
2- So if I wanted one or more faces on a prim to be subject to this change (I dont, but), how is that specified?
3 - Beez, yours looks considerably more detailed. Is it just that the script engine can take "abbreviations" and fill in missing parameters and you've written everything out? What is "float falloff"? 1 - just the prim with the script in 2 - for one face, just replace ALL_SIDES with the face number. I've never done more than one face, that would likely take multiple calls, for expample: PRIM_FULLBRIGHT, 2, TRUE, PRIM_FULLBRIGHT, 4, TRUE, experiment with it, I guess. 3 - I used variables at the top instead of putting the numbers directly in the script. I often hand out my scripts so I set them up to be as self-explanatory as possible. I allowed for two different colors for the on/off state -- sometimes it looks better if you use a slightly darker color than the lit state. Falloff is how fast the light dims the further you get from the source.
_____________________
Though this be madness, yet there is method in't. -- William Shakespeare Warburton's Whimsies: In SLApez.biz
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
09-06-2008 13:06
From: Holocluck Henly thanks all...
Still questions...
1- Re the linked set? Will the entire link be prone to this or just the prims containing the script re fullbright?
2- So if I wanted one or more faces on a prim to be subject to this change (I dont, but), how is that specified? Did you read my posting? and why not?
_____________________
From Studio Dora
|
|
Holocluck Henly
Holographic Clucktor
Join date: 11 Apr 2008
Posts: 552
|
09-06-2008 14:05
Thanks
I would probably leave out the color change specs, only because I can't convert colors. I actually do have an alternative choice for the fullbright.
I've always wanted to know how to convert RGB to vector. Is there a conversion form somewhere on a site?
Also: why are there "alpha" specs? Isnt that for transparency?
_____________________
 Photostream: www.flickr.com/photos/holocluck Holocluck's Henhouse: New Eyes on the Grid: holocluck@blogspot
|
|
Beezle Warburton
=o.O=
Join date: 10 Nov 2006
Posts: 1,169
|
09-06-2008 21:32
From: Holocluck Henly Thanks
I would probably leave out the color change specs, only because I can't convert colors. I actually do have an alternative choice for the fullbright.
I've always wanted to know how to convert RGB to vector. Is there a conversion form somewhere on a site?
Also: why are there "alpha" specs? Isnt that for transparency? You can set alpha (transparency) with the same command. RGB to vector just divide by 255
_____________________
Though this be madness, yet there is method in't. -- William Shakespeare Warburton's Whimsies: In SLApez.biz
|
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
09-07-2008 02:29
From: Beezle Warburton
RGB to vector just divide by 255
Which can be done by using this function from http://www.lslwiki.net/lslwiki/wakka.php?wakka=colorvector rgb2sl( vector rgb ) { return rgb / 255; //Scale the RGB color down by 255 }
|
|
Holocluck Henly
Holographic Clucktor
Join date: 11 Apr 2008
Posts: 552
|
09-07-2008 03:30
That's all? Just divide by 255? Wish they told me back when I was doing vrml LOL Anyway I took assorted advice and made a script for the full bright, and with Beezle's debugging help, it's starting to look good  Now to work toward the inside illumination. My chief regret at this point is that the commands toggle soon enough by Environmental standards. It should stop at its 6-6:30am and they dont come off until 7:29am. Since the build faces east, it does not need to wait for the sun to be full up. I can reduce the time it takes to check sun position, but I don't know whether that's enough. Thanks again for all your help 
_____________________
 Photostream: www.flickr.com/photos/holocluck Holocluck's Henhouse: New Eyes on the Grid: holocluck@blogspot
|
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
09-07-2008 04:27
From: Holocluck Henly My chief regret at this point is that the commands toggle soon enough by Environmental standards. It should stop at its 6-6:30am and they dont come off until 7:29am. Since the build faces east, it does not need to wait for the sun to be full up. I can reduce the time it takes to check sun position, but I don't know whether that's enough. You could try playing with { vector sun = llGetSunDirection(); if (sun.z <= 0) night = 1; // Sun is below the horizon else if (sun.z > 0) night = 0; // Sun is above the horizon } to change how far above or below the horizon the sun needs to be to in order to trigger the events. Try something like vector pos = llGetSunDirection(); if ( pos.z > -0.12 ) { //it's daytime } else { //it's night}
|
|
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
|
09-07-2008 22:37
You can use this, the threshold is the angle above/below the horizion. float Threshold = 5.0;
default { state_entry() { llSetTimerEvent(300); } timer() { vector sun = llGetSunDirection(); if(sun.z <= llSin(Threshold * DEG_TO_RAD)) { //blah } else { //blah } } }
|