Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

star.h

Go to the documentation of this file.
00001 // star.h
00002 //
00003 // Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 
00010 #ifndef _STAR_H_
00011 #define _STAR_H_
00012 
00013 #include <celutil/basictypes.h>
00014 #include <celutil/reshandle.h>
00015 #include <celutil/color.h>
00016 #include <celmath/vecmath.h>
00017 #include <celengine/univcoord.h>
00018 #include <celengine/celestia.h>
00019 #include <celengine/stellarclass.h>
00020 #include <celengine/rotation.h>
00021 #include <celengine/multitexture.h>
00022 
00023 class Orbit;
00024 class Star;
00025 
00026 class StarDetails
00027 {
00028     // TODO: This class really needs an assignment operator and
00029     // copy constructor.  We need to do some management tracking of
00030     // orbits and StarDetails objects.  Currently, it's assumed that they
00031     // have lifetimes that continue until program termination.
00032  public:
00033     StarDetails::StarDetails();
00034 
00035     inline float getRadius() const;
00036     inline float getTemperature() const;
00037     inline ResourceHandle getModel() const;
00038     inline MultiResTexture getTexture() const;
00039     inline Orbit* getOrbit() const;
00040     inline float getOrbitalRadius() const;
00041     inline const char* getSpectralType() const;
00042     inline float getBolometricCorrection() const;
00043     inline Star* getOrbitBarycenter() const;
00044     inline bool getVisibility() const;
00045     inline const RotationElements& getRotationElements() const;
00046     inline Vec3f getEllipsoidSemiAxes() const;
00047 
00048     void setRadius(float);
00049     void setTemperature(float);
00050     void setSpectralType(const std::string&);
00051     void setBolometricCorrection(float);
00052     void setTexture(const MultiResTexture&);
00053     void setModel(ResourceHandle);
00054     void setOrbit(Orbit*);
00055     void setOrbitBarycenter(Star*);
00056     void setOrbitalRadius(float);
00057     void computeOrbitalRadius();
00058     void setVisibility(bool);
00059     void setRotationElements(const RotationElements&);
00060     void setEllipsoidSemiAxes(const Vec3f&);
00061     
00062     enum
00063     {
00064         KnowRadius   = 0x1,
00065         KnowRotation = 0x2,
00066     };
00067     inline uint32 getKnowledge() const;
00068     inline bool getKnowledge(uint32) const;
00069     void setKnowledge(uint32);
00070     void addKnowledge(uint32);
00071 
00072  private:
00073     float radius;
00074     float temperature;
00075     float bolometricCorrection;
00076 
00077     uint32 knowledge;
00078     bool visible;
00079     char spectralType[8];
00080 
00081     MultiResTexture texture;
00082     ResourceHandle model;
00083 
00084     Orbit* orbit;
00085     float orbitalRadius;
00086     Star* barycenter;
00087 
00088     RotationElements rotationElements;
00089 
00090     Vec3f semiAxes;
00091 
00092  public:
00093     static StarDetails* GetStarDetails(const StellarClass&);
00094     static StarDetails* CreateStandardStarType(const std::string& _specType,
00095                                                float _temperature,
00096                                                float _rotationPeriod);
00097 
00098     static StarDetails* GetNormalStarDetails(StellarClass::SpectralClass specClass,
00099                                              unsigned int subclass,
00100                                              StellarClass::LuminosityClass lumClass);
00101     static StarDetails* GetWhiteDwarfDetails(StellarClass::SpectralClass specClass,
00102                                              unsigned int subclass);
00103     static StarDetails* GetNeutronStarDetails();
00104     static StarDetails* GetBlackHoleDetails();
00105     static StarDetails* GetBarycenterDetails();
00106 
00107     static void InitializeStarTextures();
00108     static ResourceHandle starTexB;
00109     static ResourceHandle starTexA;
00110     static ResourceHandle starTexG;
00111     static ResourceHandle starTexM;
00112     static ResourceHandle starTexL;
00113 };
00114 
00115 
00116 float
00117 StarDetails::getRadius() const
00118 {
00119     return radius;
00120 }
00121 
00122 float
00123 StarDetails::getTemperature() const
00124 {
00125     return temperature;
00126 }
00127 
00128 ResourceHandle
00129 StarDetails::getModel() const
00130 {
00131     return model;
00132 }
00133 
00134 MultiResTexture
00135 StarDetails::getTexture() const
00136 {
00137     return texture;
00138 }
00139 
00140 Orbit*
00141 StarDetails::getOrbit() const
00142 {
00143     return orbit;
00144 }
00145 
00146 float
00147 StarDetails::getOrbitalRadius() const
00148 {
00149     return orbitalRadius;
00150 }
00151 
00152 uint32
00153 StarDetails::getKnowledge() const
00154 {
00155     return knowledge;
00156 }
00157 
00158 bool
00159 StarDetails::getKnowledge(uint32 knowledgeFlags) const
00160 {
00161     return ((knowledge & knowledgeFlags) == knowledgeFlags);
00162 }
00163 
00164 const char*
00165 StarDetails::getSpectralType() const
00166 {
00167     return spectralType;
00168 }
00169 
00170 float
00171 StarDetails::getBolometricCorrection() const
00172 {
00173     return bolometricCorrection;
00174 }
00175 
00176 Star*
00177 StarDetails::getOrbitBarycenter() const
00178 {
00179     return barycenter;
00180 }
00181 
00182 bool
00183 StarDetails::getVisibility() const
00184 {
00185     return visible;
00186 }
00187 
00188 const RotationElements&
00189 StarDetails::getRotationElements() const
00190 {
00191     return rotationElements;
00192 }
00193 
00194 Vec3f
00195 StarDetails::getEllipsoidSemiAxes() const
00196 {
00197     return semiAxes;
00198 }
00199 
00200 
00201 class Star
00202 {
00203 public:
00204     inline Star();
00205 
00206     // Accessor methods for members of the star class
00207     inline uint32 getCatalogNumber() const;
00208     inline Point3f getPosition() const;
00209     inline float getAbsoluteMagnitude() const;
00210     float getApparentMagnitude(float) const;
00211     float getLuminosity() const;
00212 
00213     // Return the exact position of the star, accounting for its orbit
00214     UniversalCoord getPosition(double t) const;
00215 
00216     void setCatalogNumber(uint32);
00217     void setPosition(float, float, float);
00218     void setPosition(Point3f);
00219     void setAbsoluteMagnitude(float);
00220     void setLuminosity(float);
00221 
00222     void setDetails(StarDetails*);
00223     void setOrbitBarycenter(Star*);
00224     void computeOrbitalRadius();
00225 
00226     void setRotationElements(const RotationElements&);
00227 
00228     // Accessor methods that delegate to StarDetails
00229     float getRadius() const;
00230     inline float getTemperature() const;
00231     inline const char* getSpectralType() const;
00232     inline float getBolometricMagnitude() const;
00233     MultiResTexture getTexture() const;
00234     ResourceHandle getModel() const;
00235     inline Orbit* getOrbit() const;
00236     inline float getOrbitalRadius() const;
00237     inline Star* getOrbitBarycenter() const;
00238     inline bool getVisibility() const;
00239     inline uint32 getKnowledge() const;
00240     inline const RotationElements& getRotationElements() const;
00241     inline Vec3f getEllipsoidSemiAxes() const;
00242 
00243     enum {
00244         MaxTychoCatalogNumber = 0xf0000000,
00245         InvalidCatalogNumber = 0xffffffff,
00246     };
00247 
00248 private:
00249     uint32 catalogNumber;
00250     Point3f position;
00251     float absMag;
00252     StarDetails* details;
00253 };
00254 
00255 
00256 Star::Star() :
00257     catalogNumber(InvalidCatalogNumber),
00258     position(0, 0, 0),
00259     absMag(4.83f),
00260     details(NULL)
00261 {
00262 }
00263 
00264 uint32
00265 Star::getCatalogNumber() const
00266 {
00267     return catalogNumber;
00268 }
00269 
00270 float
00271 Star::getAbsoluteMagnitude() const
00272 {
00273     return absMag;
00274 }
00275 
00276 
00277 // This getPosition() method returns the approximate star position; that is,
00278 // star position without any orbital motion taken into account.  For a
00279 // star in an orbit, the position should be set to the 'root' barycenter
00280 // of the system.
00281 Point3f
00282 Star::getPosition() const
00283 {
00284     return position;
00285 }
00286 
00287 float
00288 Star::getTemperature() const
00289 {
00290     return details->getTemperature();
00291 }
00292 
00293 const char*
00294 Star::getSpectralType() const
00295 {
00296     return details->getSpectralType();
00297 }
00298 
00299 float
00300 Star::getBolometricMagnitude() const
00301 {
00302     return absMag + details->getBolometricCorrection();
00303 }
00304 
00305 Orbit*
00306 Star::getOrbit() const
00307 {
00308     return details->getOrbit();
00309 }
00310 
00311 float
00312 Star::getOrbitalRadius() const
00313 {
00314     return details->getOrbitalRadius();
00315 }
00316 
00317 Star*
00318 Star::getOrbitBarycenter() const
00319 {
00320     return details->getOrbitBarycenter();
00321 }
00322 
00323 bool
00324 Star::getVisibility() const
00325 {
00326     return details->getVisibility();
00327 }
00328 
00329 const RotationElements&
00330 Star::getRotationElements() const
00331 {
00332     return details->getRotationElements();
00333 }
00334 
00335 Vec3f
00336 Star::getEllipsoidSemiAxes() const
00337 {
00338     return details->getEllipsoidSemiAxes();
00339 }
00340 
00341 #endif // _STAR_H_

Generated on Sat Jan 14 22:30:28 2006 for Celestia by  doxygen 1.4.1