Difference between revisions of "User:Dora Gustafson/sundirection and time of day"

From Second Life Wiki
Jump to navigation Jump to search
(looks nicer - last I had heard was that llGetSunDirection was broken but that was several years ago. Possible that they fixed it.)
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 42: Line 44:
</lsl>
</lsl>
</div>
</div>
{{LSLC|Library}}
</div>

Revision as of 22:26, 24 January 2012

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.

<lsl> // 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);
   }

} </lsl>