Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cMapTime.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cMapTime_H
7 #define _INC_cMapTime_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "GrayMapData.h"
14 
15 namespace GrayMapData
16 {
18  {
21  public:
22  cMapOrbit() noexcept
23  : m_vPosStart(0, 0, 0)
24  , m_vOrbitAxis(0, 1, 0)
25  , m_fOrbitOffset(0.0f)
26  , m_fOrbitSpeed(0)
27  {
28  }
29  void GetOrbitMatrix(cMatrix4x4f& mOrbit, float fTimeOfCycle) const
30  {
31  // fTimeOfCycle = radians. 0 to INF
32  float fBodyPos = m_fOrbitOffset + (fTimeOfCycle*m_fOrbitSpeed); // radians
33  mOrbit.InitRotationAxis(m_vOrbitAxis, fBodyPos);
34  }
35  public:
36  cVector3f m_vPosStart; // starting pos.
39  float m_fOrbitSpeed; // Faster or slower than day rotation?
40  };
41 
43  {
49 
50  // time scales from 0.0 to PI2 each day.
51 #define MAPTIME_CYCLE ( cTypeF<float>::k_PI2) // 0 = dusk, full length of day.
52 #define MAPTIME_DAWN (MAPTIME_CYCLE*0.0f)
53 #define MAPTIME_NOON (MAPTIME_CYCLE*0.25f)
54 #define MAPTIME_DUSK (MAPTIME_CYCLE*0.50f)
55 #define MAPTIME_MIDNI (MAPTIME_CYCLE*0.75f)
56 
57  public:
58  cMapTime(TIMESECD_t dwDayLenSec = (3 * 60 * 60), float fDayLightPercent = 0.7f);
59  ~cMapTime();
60 
61  float get_MapTime() const; // from the real time clock get the time of day.
62  void put_MapTime(float fMapTime); // set the m_nTimeOffset to make it a certain Time
63 
64  DWORD get_MapDays() const;
65  void CheckMapParams();
66 
67  static bool isTimeNight(float fMapTime)
68  {
69  // Is the sun under the horizon?
70  if (Calc::WrapRadians(fMapTime) > MAPTIME_DUSK)
71  return true;
72  return false;
73  }
74  static bool isTimeDay(float fMapTime)
75  {
76  // Is the sun above the horizon?
77  return !isTimeNight(fMapTime);
78  }
79  static float ConvertHoursToRadians(float fHours);
80  static float ConvertRadiansToHours(float fRadians);
81 
83 
84  protected:
85  static TIMESYS_t get_SystemTime();
86 
87  public:
88  static TIMESYS_t sm_TimeSysFirst; // Compute total days past.
89  TIMESECD_t m_nDayLenSec; // Full day cycle (in real world seconds)
90  float m_fDayLightPercent; // What percent of the day is light? 0-1. 0.5 = default?
91 
92  public:
93  TIMESYSD_t m_nTimeOffset; // An arbitrary offset to match the server or just offset time. %m_nDayLenSec
94  };
95 }
96 
97 #endif
#define GRAYMAPDATA_LINK
Definition: GrayMapData.h:13
#define MAPTIME_DUSK
Definition: cMapTime.h:54
Definition: cMatrix.h:194
void InitRotationAxis(const cVector3f &vAxis, RADIANf_t fAngle)
Definition: cMatrix.h:543
Definition: cVector.h:94
Definition: cMapTime.h:18
float m_fOrbitSpeed
Definition: cMapTime.h:39
cVector3f m_vOrbitAxis
Definition: cMapTime.h:37
void GetOrbitMatrix(cMatrix4x4f &mOrbit, float fTimeOfCycle) const
Definition: cMapTime.h:29
cVector3f m_vPosStart
Definition: cMapTime.h:36
cMapOrbit() noexcept
Definition: cMapTime.h:22
float m_fOrbitOffset
Definition: cMapTime.h:38
Definition: cMapTime.h:43
static TIMESYS_t sm_TimeSysFirst
Definition: cMapTime.h:88
float m_fDayLightPercent
Definition: cMapTime.h:90
static bool isTimeDay(float fMapTime)
Definition: cMapTime.h:74
TIMESECD_t m_nDayLenSec
Definition: cMapTime.h:89
TIMESYSD_t m_nTimeOffset
Definition: cMapTime.h:93
static bool isTimeNight(float fMapTime)
Definition: cMapTime.h:67
Definition: GrayMapData.cpp:12
INT32 TIMESYSD_t
Time delta. signed milli-Seconds Span. cTimeSys::k_DMAX, cTimeSys::k_INF = MAILSLOT_WAIT_FOREVER.
Definition: cTimeSys.h:28
int TIMESECD_t
signed delta seconds. like TIMESEC_t. redefined in TimeUnits.h.
Definition: cTimeSys.h:19
UINT32 TIMESYS_t
TIMESYS_t = The normal system tick timer. milli-seconds since start of system/app ?
Definition: cTimeSys.h:27
static TYPE WrapRadians(TYPE nRadians) noexcept
Definition: Calc.h:363