]> git.mxchange.org Git - simgear.git/blob - simgear/sky/skysun.hxx
Working on ssg-ifying sky.
[simgear.git] / simgear / sky / skysun.hxx
1 // skysun.hxx -- draw a sun object
2 //
3 // Written by Durk Talsma. Originally started October 1997, for distribution  
4 // with the FlightGear project. Version 2 was written in August and 
5 // September 1998. This code is based upon algorithms and data kindly 
6 // provided by Mr. Paul Schlyter. (pausch@saaf.se). 
7 //
8 // Separated out rendering pieces and converted to ssg by Curt Olson,
9 // March 2000
10 //
11 // This program is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU General Public License as
13 // published by the Free Software Foundation; either version 2 of the
14 // License, or (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful, but
17 // WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 // General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 //
25 // $Id$
26
27
28 #ifndef _SKYSUN_HXX_
29 #define _SKYSUN_HXX_
30
31
32 #include <plib/ssg.h>
33 #include <simgear/misc/fgpath.hxx>
34
35 class FGSkySun {
36
37     // scene graph root for the skysun
38     ssgRoot *skysun;
39
40     ssgSelector *sun_selector;
41     ssgTransform *sun_transform;
42     ssgSimpleState *orb_state;
43     ssgSimpleState *halo_state;
44
45     ssgColourArray *cl;
46
47     ssgVertexArray *halo_vl;
48     ssgTexCoordArray *halo_tl;
49
50     GLuint sun_texid;
51     GLubyte *sun_texbuf;
52
53 public:
54
55     // Constructor
56     FGSkySun( void );
57
58     // Destructor
59     ~FGSkySun( void );
60
61     // initialize the sun object and connect it into our scene graph
62     // root.  Pass in the path to your texture directory so
63     // initialize() can find the halo.rgba texture
64     bool initialize( const FGPath& path );
65
66     // repaint the sun colors based on current value of sun_anglein
67     // degrees relative to verticle
68     // 0 degrees = high noon
69     // 90 degrees = sun rise/set
70     // 180 degrees = darkest midnight
71     bool repaint( double sun_angle );
72
73     // reposition the sun at the specified right ascension and
74     // declination, offset by our current position (p) so that it
75     // appears fixed at a great distance from the viewer.  Also add in
76     // an optional rotation (i.e. for the current time of day.)
77     bool reposition( sgVec3 p, double angle,
78                      double rightAscension, double declination );
79
80     // Draw the sun
81     bool draw();
82
83     // enable the sun in the scene graph (default)
84     void enable() { sun_selector->select( 1 ); }
85
86     // disable the sun in the scene graph.  The leaf node is still
87     // there, how ever it won't be traversed on the cullandrender
88     // phase.
89     void disable() { sun_selector->select( 0 ); }
90
91 };
92
93
94 #if 0
95 class Star : public CelestialBody
96 {
97 private:
98   //double longitude;  // the sun's true longitude - this is depreciated by
99                        // CelestialBody::lonEcl 
100   double xs, ys;     // the sun's rectangular geocentric coordinates
101   double distance;   // the sun's distance to the earth
102    GLUquadricObj *SunObject;
103   GLuint sun_texid;
104   GLubyte *sun_texbuf;
105
106   void setTexture();
107 public:
108   Star (FGTime *t);
109   ~Star();
110   void updatePosition(FGTime *t);
111   double getM();
112   double getw();
113   //double getLon();
114   double getxs();
115   double getys();
116   double getDistance();
117   void newImage();
118 };
119
120
121
122 inline double Star::getM()
123 {
124   return M;
125 }
126
127 inline double Star::getw()
128 {
129   return w;
130 }
131
132 inline double Star::getxs()
133 {
134   return xs;
135 }
136
137 inline double Star::getys()
138 {
139   return ys;
140 }
141
142 inline double Star::getDistance()
143 {
144   return distance;
145 }
146 #endif
147
148
149 #endif // _SKYSUN_HXX_
150
151
152
153
154
155
156
157
158
159
160
161
162
163