2
This file is part of Caelum.
3
See http://www.ogre3d.org/wiki/index.php/Caelum
5
Copyright (c) 2008 Caelum team. See Contributors.txt for details.
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.
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.
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/>.
21
#ifndef CAELUM__POINT_STARFIELD_H
22
#define CAELUM__POINT_STARFIELD_H
24
#include "CaelumPrerequisites.h"
25
#include "CameraBoundElement.h"
30
/** POD for bright star catalogue entries.
31
* Only J2000 position and magnitude included.
33
struct BrightStarCatalogueEntry {
34
signed char rasc_hour;
43
/// There are exactly 9110 stars in our version of the BSC.
44
const int BrightStarCatalogueSize = 9110;
46
/// Hardcoded bright star catalogue (BrightStarCatalogue.cpp)
47
extern const BrightStarCatalogueEntry BrightStarCatalogue[BrightStarCatalogueSize];
49
/** Point starfield class.
50
* An Ogre::BillboardSet is used internally; but it doesn't do much.
51
* The data is not kept inside the billboardset; but externally. Custom
52
* hardware buffers would probably work better.
54
* Stars are sized in pixels; this seems to work a lot better than relative sizes.
55
* Stars could be made even smaller but it would require hinting (nudging pixel
56
* coordinates to match actual screen pixels). Points are hard.
58
* Loading a bright-star catalogue is supported but star positions are
59
* likely only correct relative to each other. External rotation is probably wrong.
61
class CAELUM_EXPORT PointStarfield : public CameraBoundElement
65
* By default this loads some reasonable defaults and the
66
* bright star catalogue.
69
Ogre::SceneManager *sceneMgr,
70
Ogre::SceneNode *caelumRootNode,
71
bool initWithCatalogue = true);
74
virtual ~PointStarfield ();
76
/// Struct representing one star.
78
Ogre::Degree RightAscension;
79
Ogre::Degree Declination;
83
typedef std::vector<Star> StarVector;
85
/** Get a reference to the vector of stars.
86
* You can freely modify this; but you need to updateStars when you're done.
88
inline StarVector& getStarVector () { return mStars; }
90
/** You must call this if you change the star vector by hand.
92
void notifyStarVectorChanged ();
94
/// Clear any and all stars.
95
void clearAllStars ();
97
/** Add a bunch of random stars.
99
void addRandomStars (int count);
101
/** Add one star from the bright star catalogue.
103
void addStar (const BrightStarCatalogueEntry &entry);
105
/** Add stars from the bright star catalogue.
106
* @param count Number of stars to add (in order of brightness).
108
void addBrightStarCatalogue (int count = BrightStarCatalogueSize);
112
/// Node for the starfield
113
Ogre::SceneNode *mNode;
115
Ogre::ManualObject *mManualObj;
117
/// Billboard material
118
Ogre::MaterialPtr mMaterial;
121
std::vector<Star> mStars;
123
Ogre::Real mMinPixelSize, mMaxPixelSize, mMag0PixelSize;
124
Ogre::Real mMagnitudeScale;
126
Ogre::Degree mObserverLatitude, mObserverLongitude;
129
void invalidateGeometry();
130
void ensureGeometry();
133
/** Update function; called from CaelumSystem::updateSubcomponents
134
@param time Time of the day.
136
void _update (float time);
138
/** Magnitude power scale.
139
* Star magnitudes are logarithming; one magnitude difference
140
* means a star is 2.512 times brighter.
141
* This property allows tweaking that value.
143
inline void setMagnitudeScale (Ogre::Real value) { mMagnitudeScale = value; }
144
inline Ogre::Real getMagnitudeScale () { return mMagnitudeScale; }
146
inline void setMag0PixelSize (Ogre::Real value) { mMag0PixelSize = value; }
147
inline Ogre::Real getMag0PixelSize () { return mMag0PixelSize; }
149
inline void setMinPixelSize (Ogre::Real value) { mMinPixelSize = value; }
150
inline Ogre::Real getMinPixelSize () { return mMinPixelSize; }
152
inline void setMaxPixelSize (Ogre::Real value) { mMaxPixelSize = value; }
153
inline Ogre::Real getMaxPixelSize () { return mMaxPixelSize; }
155
void setObserverLatitude (Ogre::Degree value);
156
inline Ogre::Degree getObserverLatitude () { return mObserverLatitude; }
158
void setObserverLongitude (Ogre::Degree value);
159
inline Ogre::Degree getObserverLongitude () { return mObserverLongitude; }
161
/// Material used on billboards
162
static const Ogre::String BILLBOARD_MATERIAL_NAME;
164
/// Handle camera change.
165
virtual void notifyCameraChanged (Ogre::Camera *cam);
168
/// Handle far radius.
169
virtual void setFarRadius (Ogre::Real radius);
173
#endif // CAELUM__POINT_STARFIELD_H