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

From Second Life Wiki
Jump to navigation Jump to search
(Script to show the value of llGetSunDirection)
 
m (adding category LSL library)
Line 43: Line 43:
</lsl>
</lsl>
</div>
</div>
{{LSLC|Library}}

Revision as of 06:36, 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 refFrame=<0.0, 0.0, 0.0, 1.0>;

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( refFrame*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>