1 // galaxy.h
2 //
3 // Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 
10 #ifndef _GALAXY_H_
11 #define _GALAXY_H_
12 
13 #include <celengine/deepskyobj.h>
14 
15 
16 struct Blob
17 {
18     Point3f        position;
19     unsigned int   colorIndex;
20     float          brightness;
21 };
22 
23 struct GalacticForm
24 {
25     std::vector<Blob>* blobs;
26     Vec3f scale;
27 };
28 
29 class Galaxy : public DeepSkyObject
30 {
31  public:
32     Galaxy();
33     virtual const char* getType() const;
34     virtual void setType(const std::string&);
35     virtual size_t getDescription(char* buf, size_t bufLength) const;
36     virtual std::string getCustomTmpName() const;
37     virtual void setCustomTmpName(const std::string&);
38 
39     float getDetail() const;
40     void setDetail(float);
41     //    float getBrightness() const;
42     //    void setBrightness();
43 
44     virtual bool pick(const Ray3d& ray,
45                       double& distanceToPicker,
46                       double& cosAngleToBoundCenter) const;
47     virtual bool load(AssociativeArray*, const std::string&);
48     virtual void render(const GLContext& context,
49                         const Vec3f& offset,
50                         const Quatf& viewerOrientation,
51                         float brightness,
52                         float pixelSize);
53     virtual void renderGalaxyPointSprites(const GLContext& context,
54                                           const Vec3f& offset,
55                                           const Quatf& viewerOrientation,
56                                           float brightness,
57                                           float pixelSize);
58     virtual void renderGalaxyEllipsoid(const GLContext& context,
59                                        const Vec3f& offset,
60                                        const Quatf& viewerOrientation,
61                                        float brightness,
62                                        float pixelSize);
63 
64     GalacticForm* getForm() const;
65 
66     static void  increaseLightGain();
67     static void  decreaseLightGain();
68     static float getLightGain();
69     static void  setLightGain(float);
70 
71     virtual unsigned int getRenderMask() const;
72     virtual unsigned int getLabelMask() const;
73 
74     virtual const char* getObjTypeName() const;
75 
76  public:
77     enum GalaxyType {
78         S0   =  0,
79         Sa   =  1,
80         Sb   =  2,
81         Sc   =  3,
82         SBa  =  4,
83         SBb  =  5,
84         SBc  =  6,
85         E0   =  7,
86         E1   =  8,
87         E2   =  9,
88         E3   = 10,
89         E4   = 11,
90         E5   = 12,
91         E6   = 13,
92         E7   = 14,
93         Irr  = 15
94     };
95 
96  private:
97     float detail;
98     std::string* customTmpName;
99     //    float brightness;
100     GalaxyType type;
101     GalacticForm* form;
102 
103     static float lightGain;
104 };
105 
106 //std::ostream& operator<<(std::ostream& s, const Galaxy::GalaxyType& sc);
107 
108 #endif // _GALAXY_H_
109