00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef CAELUM__POINT_STARFIELD_H
00022 #define CAELUM__POINT_STARFIELD_H
00023
00024 #include "CaelumPrerequisites.h"
00025 #include "CameraBoundElement.h"
00026 #include "PrivatePtr.h"
00027 #include "FastGpuParamRef.h"
00028
00029 namespace Caelum
00030 {
00034 struct BrightStarCatalogueEntry {
00035 signed char rasc_hour;
00036 signed char rasc_min;
00037 float rasc_sec;
00038 signed char decl_deg;
00039 signed char decl_min;
00040 float decl_sec;
00041 float magn;
00042 };
00043
00045 const int BrightStarCatalogueSize = 9110;
00046
00048 extern const BrightStarCatalogueEntry BrightStarCatalogue[BrightStarCatalogueSize];
00049
00060 class CAELUM_EXPORT PointStarfield:
00061 public CameraBoundElement
00062 {
00063 public:
00068 PointStarfield (
00069 Ogre::SceneManager *sceneMgr,
00070 Ogre::SceneNode *caelumRootNode,
00071 bool initWithCatalogue = true);
00072
00074 virtual ~PointStarfield ();
00075
00077 struct Star {
00078 Ogre::Degree RightAscension;
00079 Ogre::Degree Declination;
00080 Ogre::Real Magnitude;
00081 };
00082
00084 typedef std::vector<Star> StarVector;
00085
00089 inline StarVector& getStarVector () { return mStars; }
00090
00093 void notifyStarVectorChanged ();
00094
00096 void clearAllStars ();
00097
00100 void addRandomStars (int count);
00101
00104 void addStar (const BrightStarCatalogueEntry &entry);
00105
00109 void addBrightStarCatalogue (int count = BrightStarCatalogueSize);
00110
00111 private:
00113 PrivateMaterialPtr mMaterial;
00114
00116 PrivateSceneNodePtr mNode;
00117
00119 PrivateManualObjectPtr mManualObj;
00120
00122 std::vector<Star> mStars;
00123
00124 Ogre::Real mMinPixelSize, mMaxPixelSize, mMag0PixelSize;
00125 Ogre::Real mMagnitudeScale;
00126
00127 Ogre::Degree mObserverLatitude, mObserverLongitude;
00128
00129 bool mValidGeometry;
00130 void invalidateGeometry();
00131 void ensureGeometry();
00132
00133 public:
00137 void _update (float time);
00138
00144 inline void setMagnitudeScale (Ogre::Real value) { mMagnitudeScale = value; }
00145 inline Ogre::Real getMagnitudeScale () const { return mMagnitudeScale; }
00146
00147 inline void setMag0PixelSize (Ogre::Real value) { mMag0PixelSize = value; }
00148 inline Ogre::Real getMag0PixelSize () const { return mMag0PixelSize; }
00149
00150 inline void setMinPixelSize (Ogre::Real value) { mMinPixelSize = value; }
00151 inline Ogre::Real getMinPixelSize () const { return mMinPixelSize; }
00152
00153 inline void setMaxPixelSize (Ogre::Real value) { mMaxPixelSize = value; }
00154 inline Ogre::Real getMaxPixelSize () const { return mMaxPixelSize; }
00155
00156 void setObserverLatitude (Ogre::Degree value);
00157 inline Ogre::Degree getObserverLatitude () const { return mObserverLatitude; }
00158
00159 void setObserverLongitude (Ogre::Degree value);
00160 inline Ogre::Degree getObserverLongitude () const { return mObserverLongitude; }
00161
00162 private:
00163 Ogre::Degree mObserverPositionRebuildDelta;
00164
00165 public:
00173 inline Ogre::Degree getObserverPositionRebuildDelta () const {
00174 return mObserverPositionRebuildDelta;
00175 }
00176 inline void setObserverPositionRebuildDelta (Ogre::Degree value) {
00177 mObserverPositionRebuildDelta = value;
00178 }
00179
00180 static const Ogre::Degree DEFAULT_OBSERVER_POSITION_REBUILD_DELTA;
00181
00183 static const Ogre::String STARFIELD_MATERIAL_NAME;
00184
00186 virtual void notifyCameraChanged (Ogre::Camera *cam);
00187
00188 protected:
00190 virtual void setFarRadius (Ogre::Real radius);
00191
00192 public:
00193 void setQueryFlags (uint flags) { mManualObj->setQueryFlags (flags); }
00194 uint getQueryFlags () const { return mManualObj->getQueryFlags (); }
00195 void setVisibilityFlags (uint flags) { mManualObj->setVisibilityFlags (flags); }
00196 uint getVisibilityFlags () const { return mManualObj->getVisibilityFlags (); }
00197
00198 private:
00199 struct Params {
00200 void setup(Ogre::GpuProgramParametersSharedPtr vpParams);
00201
00202 Ogre::GpuProgramParametersSharedPtr vpParams;
00203 FastGpuParamRef mag_scale;
00204 FastGpuParamRef mag0_size;
00205 FastGpuParamRef min_size;
00206 FastGpuParamRef max_size;
00207 FastGpuParamRef aspect_ratio;
00208 } mParams;
00209 };
00210 }
00211
00212 #endif // CAELUM__POINT_STARFIELD_H