Time is a key element in any virtual world. It controls the interpolators, which trigger events, perform animations, and move viewpoints. Nearly all references to time are relative to a recent world event. Typical time durations are measured in seconds. Absolute time or long-time extents are rarely used. The examples featured in this month's tip measure long periods of time. The first example is a clock with a second hand.
The second example illustrates a calendar and the proper lighting of a Menorah for Chanukah .
Absolute time is obtained from a number of sources. These include TouchSensors, TimeSensors, ProximitySensors, and any event. The clock needs to track time over a 24-hour period. The initial value is set on world startup. A TimeSensor is used to move the second hand.
Absolute time is used to determine the date during Chanukah. This particular example is set for 1999. Chanukah starts at sundown on Saturday, 4 December. The calendar displays the current date. The number of candles that are lit is determined by the date on the calendar. You can change the date on the calendar to see lighting sequence on the various dates of Chanukah. The source for the date calculation for the Menorah world can be found here.
The absolute time is determined from the 'time' parameter that is passed with every event. It is also of type SFTime. An adjustment is made to convert the time to Mountain Standard Time (GMT+7), and the number of days since the epoch (1 January 1970) is computed. This is compared to the number of days from the beginning of (computer) time to 1 December 1999 (10925 days for those who are curious).