Difference between revisions of "User:Dora Gustafson/sundirection and time of day"
Jump to navigation
Jump to search
m (adding category LSL library) |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{LSL Header}}{{LSLC|Library}} | |||
<div id="box"> | <div id="box"> | ||
== Show Sun Direction and compare to Time of Day == | == Show Sun Direction and compare to Time of Day == | ||
<div style="padding: 0.5em;"> | |||
Conclusion when compared to the ''Windlight default day cycle'': | Conclusion when compared to the ''Windlight default day cycle'': | ||
* When the SunDirection vector is confined to the X-Z plane(Ecliptic) the result matches fairly well what is seen. | * When the SunDirection vector is confined to the X-Z plane(Ecliptic) the result matches fairly well what is seen. | ||
Line 6: | Line 8: | ||
* When the east point in Windlight is moved the SunDirection vector doesn't move with it. | * When the east point in Windlight is moved the SunDirection vector doesn't move with it. | ||
* The often used method of using the Z component to separate day from night is very rough. Sunset and sunrise are both (equivalent)hours from where the sign of Z changes. | * The often used method of using the Z component to separate day from night is very rough. Sunset and sunrise are both (equivalent)hours from where the sign of Z changes. | ||
< | <source lang="lsl2"> | ||
// sun pointer script by Dora Gustafson, Studio Dora 2012 | // sun pointer script by Dora Gustafson, Studio Dora 2012 | ||
// Will point the prim's FWD in the SunDirection | // Will point the prim's FWD in the SunDirection | ||
Line 14: | Line 16: | ||
float sd_Rate=10.0; | float sd_Rate=10.0; | ||
integer vertical=TRUE; // vertical ecliptic | integer vertical=TRUE; // vertical ecliptic | ||
rotation Vec2Rot( vector FWD ) | rotation Vec2Rot( vector FWD ) | ||
Line 34: | Line 35: | ||
timer() | timer() | ||
{ | { | ||
llSetRot( | llSetRot( Vec2Rot( llGetSunDirection())); | ||
float secs = 6.0*llGetTimeOfDay(); // multiply by 6 to show the equivalent real day hour | float secs = 6.0*llGetTimeOfDay(); // multiply by 6 to show the equivalent real day hour | ||
integer minutes = ((integer)secs/60)%60; | integer minutes = ((integer)secs/60)%60; | ||
Line 41: | Line 42: | ||
} | } | ||
} | } | ||
</ | </source> | ||
</div> | |||
</div> | </div> | ||
Latest revision as of 12:52, 22 January 2015
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Show Sun Direction and compare to Time of Day
Conclusion when compared to the Windlight default day cycle:
- When the SunDirection vector is confined to the X-Z plane(Ecliptic) the result matches fairly well what is seen.
- The moon direction is not always opposite the sun direction.
- When the east point in Windlight is moved the SunDirection vector doesn't move with it.
- The often used method of using the Z component to separate day from night is very rough. Sunset and sunrise are both (equivalent)hours from where the sign of Z changes.
// sun pointer script by Dora Gustafson, Studio Dora 2012
// Will point the prim's FWD in the SunDirection
// Will show the SunDirection vector and the equivalent real day hour
// vertical ecliptic matches the default day cycle sun in windlight
float sd_Rate=10.0;
integer vertical=TRUE; // vertical ecliptic
rotation Vec2Rot( vector FWD )
{
FWD = llVecNorm( FWD );
vector UP = < 0.0, 1.0, 0.0 >;
vector LEFT = llVecNorm(UP%FWD);
if (vertical) FWD = llVecNorm(LEFT%UP);
else UP = llVecNorm(FWD%LEFT);
return llAxes2Rot(FWD, LEFT, UP);
}
default
{
state_entry()
{
llSetTimerEvent(sd_Rate);
}
timer()
{
llSetRot( Vec2Rot( llGetSunDirection()));
float secs = 6.0*llGetTimeOfDay(); // multiply by 6 to show the equivalent real day hour
integer minutes = ((integer)secs/60)%60;
integer hours = (integer)secs/3600;
llSetText("Sundirection: "+(string)llGetSunDirection()+"\nSim Time: "+(string)hours+"H "+(string)minutes+"M", <1.0,1.0,1.0>, 1.0);
}
}