Caelum
PointStarfield.h
1 /*
2 This file is part of Caelum.
3 See http://www.ogre3d.org/wiki/index.php/Caelum
4 
5 Copyright (c) 2008 Caelum team. See Contributors.txt for details.
6 
7 Caelum is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published
9 by the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Caelum is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License
18 along with Caelum. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef CAELUM__POINT_STARFIELD_H
22 #define CAELUM__POINT_STARFIELD_H
23 
24 #include "CaelumPrerequisites.h"
25 #include "CameraBoundElement.h"
26 #include "PrivatePtr.h"
27 #include "FastGpuParamRef.h"
28 
29 namespace Caelum
30 {
35  signed char rasc_hour;
36  signed char rasc_min;
37  float rasc_sec;
38  signed char decl_deg;
39  signed char decl_min;
40  float decl_sec;
41  float magn;
42  };
43 
45  const int BrightStarCatalogueSize = 9110;
46 
49 
60  class CAELUM_EXPORT PointStarfield:
61  public CameraBoundElement
62  {
63  public:
69  Ogre::SceneManager *sceneMgr,
70  Ogre::SceneNode *caelumRootNode,
71  bool initWithCatalogue = true);
72 
74  virtual ~PointStarfield ();
75 
77  struct Star {
78  Ogre::Degree RightAscension;
79  Ogre::Degree Declination;
80  Ogre::Real Magnitude;
81  };
82 
84  typedef std::vector<Star> StarVector;
85 
89  inline StarVector& getStarVector () { return mStars; }
90 
93  void notifyStarVectorChanged ();
94 
96  void clearAllStars ();
97 
100  void addRandomStars (int count);
101 
104  void addStar (const BrightStarCatalogueEntry &entry);
105 
109  void addBrightStarCatalogue (int count = BrightStarCatalogueSize);
110 
111  private:
113  PrivateMaterialPtr mMaterial;
114 
116  PrivateSceneNodePtr mNode;
117 
119  PrivateManualObjectPtr mManualObj;
120 
122  std::vector<Star> mStars;
123 
124  Ogre::Real mMinPixelSize, mMaxPixelSize, mMag0PixelSize;
125  Ogre::Real mMagnitudeScale;
126 
127  Ogre::Degree mObserverLatitude, mObserverLongitude;
128 
129  bool mValidGeometry;
130  void invalidateGeometry();
131  void ensureGeometry();
132 
133  public:
137  void _update (float time);
138 
144  inline void setMagnitudeScale (Ogre::Real value) { mMagnitudeScale = value; }
145  inline Ogre::Real getMagnitudeScale () const { return mMagnitudeScale; }
146 
147  inline void setMag0PixelSize (Ogre::Real value) { mMag0PixelSize = value; }
148  inline Ogre::Real getMag0PixelSize () const { return mMag0PixelSize; }
149 
150  inline void setMinPixelSize (Ogre::Real value) { mMinPixelSize = value; }
151  inline Ogre::Real getMinPixelSize () const { return mMinPixelSize; }
152 
153  inline void setMaxPixelSize (Ogre::Real value) { mMaxPixelSize = value; }
154  inline Ogre::Real getMaxPixelSize () const { return mMaxPixelSize; }
155 
156  void setObserverLatitude (Ogre::Degree value);
157  inline Ogre::Degree getObserverLatitude () const { return mObserverLatitude; }
158 
159  void setObserverLongitude (Ogre::Degree value);
160  inline Ogre::Degree getObserverLongitude () const { return mObserverLongitude; }
161 
162  private:
163  Ogre::Degree mObserverPositionRebuildDelta;
164 
165  public:
173  inline Ogre::Degree getObserverPositionRebuildDelta () const {
174  return mObserverPositionRebuildDelta;
175  }
176  inline void setObserverPositionRebuildDelta (Ogre::Degree value) {
177  mObserverPositionRebuildDelta = value;
178  }
179 
180  static const Ogre::Degree DEFAULT_OBSERVER_POSITION_REBUILD_DELTA;
181 
183  static const Ogre::String STARFIELD_MATERIAL_NAME;
184 
186  virtual void notifyCameraChanged (Ogre::Camera *cam);
187 
188  protected:
190  virtual void setFarRadius (Ogre::Real radius);
191 
192  public:
193  void setQueryFlags (uint flags) { mManualObj->setQueryFlags (flags); }
194  uint getQueryFlags () const { return mManualObj->getQueryFlags (); }
195  void setVisibilityFlags (uint flags) { mManualObj->setVisibilityFlags (flags); }
196  uint getVisibilityFlags () const { return mManualObj->getVisibilityFlags (); }
197 
198  private:
199  struct Params {
200  void setup(Ogre::GpuProgramParametersSharedPtr vpParams);
201 
202  Ogre::GpuProgramParametersSharedPtr vpParams;
203  FastGpuParamRef mag_scale;
204  FastGpuParamRef mag0_size;
205  FastGpuParamRef min_size;
206  FastGpuParamRef max_size;
207  FastGpuParamRef aspect_ratio;
208  } mParams;
209  };
210 }
211 
212 #endif // CAELUM__POINT_STARFIELD_H
const int BrightStarCatalogueSize
There are exactly 9110 stars in our version of the BSC.
const BrightStarCatalogueEntry BrightStarCatalogue[BrightStarCatalogueSize]
Hardcoded bright star catalogue (BrightStarCatalogue.cpp)
std::vector< Star > StarVector
A vector of Star.
Point starfield class.
static const Ogre::String STARFIELD_MATERIAL_NAME
Material used to draw all the points.
void setMagnitudeScale(Ogre::Real value)
Magnitude power scale.
StarVector & getStarVector()
Get a reference to the vector of stars.
Struct representing one star inside PointStarfield.
A camera-bound element.
Ogre::Degree getObserverPositionRebuildDelta() const
Moving the observer position around causes a starfield rebuild.
POD for bright star catalogue entries.
An optimized reference to a gpu shared parameter.
Caelum namespace.
Definition: Astronomy.cpp:24