Caelum  0.6.4
Public Member Functions | Static Public Attributes | List of all members
Caelum::UniversalClock Class Reference

The system's time model. More...

#include <UniversalClock.h>

Public Member Functions

 UniversalClock ()
 Constructor.
 
void setTimeScale (const Ogre::Real scale)
 Sets the time scale. More...
 
Ogre::Real getTimeScale () const
 Gets the time scale. More...
 
void update (const Ogre::Real time)
 Updates the clock. More...
 
void setJulianDay (LongReal value)
 Set the current time as a julian day. More...
 
void setGregorianDateTime (int year, int month, int day, int hour, int minute, double second)
 Set the current time as a gregorian date. More...
 
LongReal getJulianDay () const
 Get current julian day.
 
LongReal getJulianDayDifference () const
 Get the difference in julian day between this and the last update. More...
 
LongReal getJulianSecond () const
 Get the current julian second (getJulianDay * SECONDS_PER_DAY) This is most likely very very large and unprecise.
 
LongReal getJulianSecondDifference () const
 Get the difference in seconds between this and the last update. More...
 

Static Public Attributes

static const LongReal SECONDS_PER_DAY
 Number of seconds per day; exactly 60*60*24.
 

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.

Member Function Documentation

◆ setTimeScale()

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

Sets the time scale.

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

◆ getTimeScale()

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

Gets the time scale.

Returns
The current time scale. Defaults to 1.

◆ update()

void Caelum::UniversalClock::update ( const Ogre::Real  time)

Updates the clock.

Parameters
timeThe time to be added to the clock. It will beaffected by the time scale.

◆ setJulianDay()

void Caelum::UniversalClock::setJulianDay ( 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)

◆ setGregorianDateTime()

void Caelum::UniversalClock::setGregorianDateTime ( int  year,
int  month,
int  day,
int  hour,
int  minute,
double  second 
)

Set the current time as a gregorian date.

This is here as an easy to use function.

◆ getJulianDayDifference()

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.

◆ getJulianSecondDifference()

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.