Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
SkyDome.h
1 //
2 // SkyDome.h
3 //
4 // Copyright (c) 2001-2011 Virtual Terrain Project
5 // Free for all uses, see license.txt for details.
6 //
7 
8 #ifndef VTLIB_SKYDOMEH
9 #define VTLIB_SKYDOMEH
10 
11 #include <vtdata/vtTime.h>
12 
15 
23 class vtStarDome : public vtGroup
24 {
25 public:
26  vtStarDome();
27  ~vtStarDome();
28 
29  void Create(const char *starfile, float brightness,
30  const char *moon_texture = NULL);
31 
32  void SetTime(const vtTime &time);
33  void SetStarFile(char *starpath);
34 
35  struct Star
36  {
37  float ra; // Right Ascension
38  float dec; // Declination
39  float mag; // Magnitude
40  float relmag;
41  FPoint3 cartpt; // Cartesian coordinate
42  };
43 
44 private:
45  vtGeode *m_pStarGeom;
46  vtMesh *m_pStarMesh;
47  vtMovGeode *m_pMoonGeom;
48  vtMaterialArrayPtr m_pMats;
49  ImagePtr m_pMoonImage;
50 
51  vtTime m_time;
52  float RelativeBrightness;
53 
55  int NumStars;
56  Star *Starfield;
57  char StarFile[100];
58  float HighMag, LowMag, MagRange;
59 
61  bool ReadStarData(const char *starfile);
62  void ConvertStarCoord(Star *star);
63 
64  void AddStars(vtMesh *geo);
65  void AddConstellation(vtMesh *geo);
66  void FadeStars();
67 
68 };
69 
80 class vtSkyDome : public vtTransform
81 {
82 public:
83  vtSkyDome();
84  ~vtSkyDome();
85 
86  void Create(const char *starfile, int depth, float radius,
87  const char *sun_texture = NULL, const char *moon_texture = NULL);
88 
89  void SetGeoLocation(const DPoint2 &geo) { m_geo = geo; }
90  void SetTime(const vtTime &time);
91  void SetDayColors(const RGBf &horizon, const RGBf &azimuth);
92  void SetSunsetColor(const RGBf &sunset);
93  void SetInterpCutoff(float cutoff);
94  void SetSunLight(vtTransform *light) { m_pSunLight = light; }
95  void SetSunLightSource(vtLightSource *ls) { m_pSunLightSource = ls; }
96  bool SetTexture(const char *filename);
97  void SetStarAltitude(float fDegrees) { m_fStarAltitude = fDegrees; }
98  void RefreshCelestialObjects();
99 
100  void ShowMarkers(bool bShow);
101  bool MarkersShown();
102 
103 protected:
104  void CreateMarkers();
105  void UpdateSunLight();
106  void ApplyDomeColors();
107  void ConvertVertices();
108 
109  DPoint2 m_geo; // The earth location in lon-lat
110  vtTime m_time; // Local time at this location
111 
112  float m_fSunAlt, m_fSunAzi; // in Degrees
113  float m_fStarAltitude; // Cutoff for when stars should be displayed
114 
115  vtStarDome *m_pStarDome;
116  vtTransform *m_pSunLight;
117  vtLightSource *m_pSunLightSource;
118 
119  // day dome colors (when not textured)
120  RGBf DayHorizonCol, DayAzimuthCol, SunsetCol;
121  float Cutoff;
122 
123  int NumVertices;
124  FPoint3 *SphVertices;
125 
126  vtTransform *m_pCelestial;
127  vtGeode *m_pDomeGeom;
128 
129  vtMaterialArrayPtr m_pMats;
130  vtMaterial *m_pMat;
131  vtMaterial *m_pTextureMat;
132  vtMesh *m_pDomeMesh;
133 
134  vtMovGeode *m_pSunGeom;
135  vtMaterial *m_pSunMat;
136  ImagePtr m_pSunImage;
137 
138  bool m_bHasTexture;
139 
140  // Test markers:
141  vtGeode *m_pTicks;
142  vtGeode *m_pWireSphere;
143  vtTransform *m_pGreenMarker;
144  vtTransform *m_pRedMarker;
145 };
146 
147 // Helper: creates a movable cross-hair for pointing out something on the sky
148 vtTransform *CreateMarker(vtMaterialArray *pMats, const RGBf &color);
149  // terrain
151 
152 #endif // VTLIB_SKYDOMEH
153