caelum::UniversalClock Class Reference

#include <UniversalClock.h>

List of all members.

Public Member Functions

 UniversalClock ()
void setTimeScale (const Ogre::Real scale)
Ogre::Real getTimeScale () const
void setUpdateRate (const Ogre::Real rate)
Ogre::Real getUpdateRate () const
bool update (const Ogre::Real time)
void setJulianDay (LongReal value)
void setGregorianDateTime (int year, int month, int day, int hour, int minute, double second)
LongReal getJulianDay () const
LongReal getJulianDayDifference () const
LongReal getJulianSecond () const
LongReal getJulianSecondDifference () const

Static Public Attributes

static const LongReal SECONDS_PER_DAY = 86400.0


Detailed Description

The system's time model. This class is responsible of keeping track of current astronomical time and syncronising with ogre time.

It maintains a snapshot point: At mCurrentTime == 0 julian day was mJulianDayBase. At any time the julian day can be calculated from mCurrentTime and mJulianDayBase. This increases precission; mCurrentTime is tracked in seconds while mJulianDayBase uses days. It would be silly to track the current time in days.

Definition at line 37 of file UniversalClock.h.


Constructor & Destructor Documentation

caelum::UniversalClock::UniversalClock (  ) 

Constructor.

Definition at line 29 of file UniversalClock.cpp.

References caelum::Astronomy::J2000, setJulianDay(), setTimeScale(), and setUpdateRate().


Member Function Documentation

void caelum::UniversalClock::setTimeScale ( const Ogre::Real  scale  ) 

Sets the time scale.

Parameters:
scale The new time scale. If negative, time will move backwards; 2.0 means double speed...

Definition at line 75 of file UniversalClock.cpp.

Referenced by UniversalClock().

Ogre::Real caelum::UniversalClock::getTimeScale (  )  const

Gets the time scale.

Returns:
The current time scale. Defaults to 1.

Definition at line 79 of file UniversalClock.cpp.

void caelum::UniversalClock::setUpdateRate ( const Ogre::Real  rate  ) 

Sets the update rate.

Parameters:
rate A positive number representing the number of seconds to be elapsed (in real time) since the last update. Negative numbers will be clamped to 0 (update every frame).

Definition at line 83 of file UniversalClock.cpp.

Referenced by UniversalClock().

Ogre::Real caelum::UniversalClock::getUpdateRate (  )  const

Gets the update rate.

Returns:
The amount of time to be elapsed (at least) between updates.

Definition at line 93 of file UniversalClock.cpp.

bool caelum::UniversalClock::update ( const Ogre::Real  time  ) 

Updates the clock.

Parameters:
time The time to be added to the clock. Note this will be affected by the time scale.
Returns:
True if an update has been fired (depending on the update rate).

Definition at line 97 of file UniversalClock.cpp.

Referenced by caelum::CaelumSystem::updateSubcomponents().

void caelum::UniversalClock::setJulianDay ( caelum::LongReal  value  ) 

Set the current time as a julian day. Set the current time as a julian day, which you build using one of the static getJulianDayFromXXX functions. Defaults to J2000 (noon january 1st)

Definition at line 37 of file UniversalClock.cpp.

Referenced by UniversalClock().

caelum::LongReal caelum::UniversalClock::getJulianDay (  )  const

caelum::LongReal caelum::UniversalClock::getJulianDayDifference (  )  const

Get the difference in julian day between this and the last update. This is most likely very small and unprecise.

Definition at line 60 of file UniversalClock.cpp.

caelum::LongReal caelum::UniversalClock::getJulianSecond (  )  const

Get the current julian second (getJulianDay * SECONDS_PER_DAY) This is most likely very very large and unprecise.

Definition at line 64 of file UniversalClock.cpp.

References caelum::Astronomy::enterHighPrecissionFloatingPointMode(), and caelum::Astronomy::restoreFloatingPointMode().

caelum::LongReal caelum::UniversalClock::getJulianSecondDifference (  )  const

Get the difference in seconds between this and the last update. This is what you want for per-frame updates.

Definition at line 71 of file UniversalClock.cpp.

Referenced by caelum::CaelumSystem::updateSubcomponents().


The documentation for this class was generated from the following files:

Generated on Fri Jul 11 09:24:53 2008 for Caelum by  doxygen 1.5.6