Time and Again

  • warning: Parameter 1 to theme_field() expected to be a reference, value given in /home/e3d/public_html/includes/theme.inc on line 171.
  • warning: Parameter 1 to theme_field() expected to be a reference, value given in /home/e3d/public_html/includes/theme.inc on line 171.
  • warning: Parameter 1 to theme_field() expected to be a reference, value given in /home/e3d/public_html/includes/theme.inc on line 171.
  • warning: Parameter 1 to theme_field() expected to be a reference, value given in /home/e3d/public_html/includes/theme.inc on line 171.
  • warning: Parameter 1 to theme_field() expected to be a reference, value given in /home/e3d/public_html/includes/theme.inc on line 171.
  • : Function ereg() is deprecated in /home/e3d/public_html/includes/file.inc on line 649.
  • : Function ereg() is deprecated in /home/e3d/public_html/includes/file.inc on line 649.
  • : Function ereg() is deprecated in /home/e3d/public_html/includes/file.inc on line 649.
  • : Function ereg() is deprecated in /home/e3d/public_html/includes/file.inc on line 649.
  • : Function ereg() is deprecated in /home/e3d/public_html/includes/file.inc on line 649.
  • : Function ereg() is deprecated in /home/e3d/public_html/includes/file.inc on line 649.
  • : Function ereg() is deprecated in /home/e3d/public_html/includes/file.inc on line 649.
  • : Function ereg() is deprecated in /home/e3d/public_html/includes/file.inc on line 649.
  • : Function ereg() is deprecated in /home/e3d/public_html/includes/file.inc on line 649.
  • : Function ereg() is deprecated in /home/e3d/public_html/includes/file.inc on line 649.
Stumble Upon Del.icio.us Digg It Technorati reddit

Subtitle

A tutorial

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.

The time enters the initialization procedure from a ProximitySensor. It is of type SFTime, but can be used in numeric computations like SFFloat. The key to determining the time of day is to compute the time modulo 86400 (the number of seconds in a day). (This is done is JavaScript with the '%' operator.) The positions of the clock hands are set based on a standard computation of the hours and minutes from seconds. The source of the clock can be found at here. The initial view shows Greenwich Mean Time. The various viewpoints select from different time zones. The sky color is light from 6AM to 6PM and dark the other 12 hours.

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).

Last Updated (Friday, 24 July 2009 09:47)
 

Syndicate

Syndicate content

About the Author

Advertisments