This file is indexed.

/usr/include/plib/ssgaSky.h is in libplib-dev 1.8.5-5.2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
/*
     PLIB - A Suite of Portable Game Libraries
     Copyright (C) 1998,2002  Steve Baker
 
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Library General Public
     License as published by the Free Software Foundation; either
     version 2 of the License, or (at your option) any later version.
 
     This library is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     Library General Public License for more details.
 
     You should have received a copy of the GNU Library General Public
     License along with this library; if not, write to the Free Software
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 
     For further information visit http://plib.sourceforge.net

     $Id: ssgaSky.h 2073 2006-03-27 08:09:54Z bram $
*/

// Written by Curtis Olson, started December 1997.
// SSG-ified by Curtis Olson, February 2000.
//
// Moved into ssgAux, July 2003.

#ifndef _INCLUDED_SSGASKY_H_
#define _INCLUDED_SSGASKY_H_

#include "ssg.h"

class ssgaCelestialBody;
class ssgaCelestialBodyList;
class ssgaCloudLayer;
class ssgaCloudLayerList;
class ssgaStars;
class ssgaSkyDome;
class ssgaSky;


class ssgaCelestialBody
{
private:

  ssgTransform *transform;
  ssgColourArray *cl;

  // used by repaint for rise/set effects
  double body_angle;
  double body_rotation;

  // used by reposition
  double body_right_ascension;
  double body_declination;
  double body_dist;

public:

  ssgaCelestialBody( void );
  ~ssgaCelestialBody( void );

  ssgBranch *build( const char* body_tex_path, const char* halo_tex_path, double body_size );
  ssgBranch *build( ssgSimpleState *orb_state, ssgSimpleState *halo_state, double body_size );

  bool reposition( sgVec3 p, double angle ) {
    return reposition ( p, angle, body_right_ascension, body_declination, body_dist ); }
  bool reposition( sgVec3 p, double angle, double rightAscension, double declination, double dist );

  bool repaint() { return repaint ( body_angle ); }
  bool repaint( double angle );

  void getPosition ( sgCoord* p )
  {
	sgMat4 Xform;
	transform->getTransform(Xform);
	sgSetCoord(p, Xform);
  }

  void setAngle ( double angle ) { body_angle = angle; }
  double getAngle () { return body_angle; }

  void setRotation ( double rotation ) { body_rotation = rotation; }
  double getRotation () { return body_rotation; }

  void setRightAscension ( double ra ) { body_right_ascension = ra; }
  double getRightAscension () { return body_right_ascension; }

  void setDeclination ( double decl ) { body_declination = decl; }
  double getDeclination () { return body_declination; }

  void setDist ( double dist ) { body_dist = dist; }
  double getDist () { return body_dist; }

  inline float *getColor() { return  cl->get( 0 ); }
} ;


class ssgaCelestialBodyList : private ssgSimpleList
{
public:

  ssgaCelestialBodyList ( int init = 3 )
	  : ssgSimpleList ( sizeof(ssgaCelestialBody*), init ) { }

  ~ssgaCelestialBodyList () { removeAll(); }

  int getNum (void) { return total ; }

  ssgaCelestialBody* get ( unsigned int n )
  {
    assert(n<total);
    return *( (ssgaCelestialBody**) raw_get ( n ) ) ;
  }

  void add ( ssgaCelestialBody* item ) { raw_add ( (char *) &item ) ;}

  void removeAll ()
  {
    for ( int i = 0; i < getNum (); i++ )
      delete get (i) ;
    ssgSimpleList::removeAll () ;
  }
} ;


class ssgaCloudLayer
{
private:

  ssgRoot *layer_root;
  ssgTransform *layer_transform;
  ssgLeaf *layer[4];

  ssgColourArray *cl[4]; 
  ssgVertexArray *vl[4];
  ssgTexCoordArray *tl[4];

  bool enabled;
  float layer_span;
  float layer_asl;
  float layer_thickness;
  float layer_transition;
  float scale;
  float speed;
  float direction;

  double last_lon, last_lat;
  double last_x, last_y;

public:

  ssgaCloudLayer( void );
  ~ssgaCloudLayer( void );

  void build( const char *cloud_tex_path, float span, float elevation, float thickness, float transition );
  void build( ssgSimpleState *cloud_state, float span, float elevation, float thickness, float transition );

  bool repositionFlat( sgVec3 p, double dt );
  bool reposition( sgVec3 p, sgVec3 up, double lon, double lat, double alt, double dt );

  bool repaint( sgVec3 fog_color );

  void draw();

  void enable() { enabled = true; }
  void disable() { enabled = false; }
  bool isEnabled() { return enabled; }

  float getElevation () { return layer_asl; }
  void  setElevation ( float elevation ) { layer_asl = elevation; }

  float getThickness () { return layer_thickness; }
  void  setThickness ( float thickness ) { layer_thickness = thickness; }

  float getTransition () { return layer_transition; }
  void  setTransition ( float transition ) { layer_transition = transition; }

  float getSpeed () { return speed; }
  void  setSpeed ( float val ) { speed = val; }

  float getDirection () { return direction; }
  void  setDirection ( float val ) { direction = val; }
};


class ssgaCloudLayerList : private ssgSimpleList
{
public:

  ssgaCloudLayerList ( int init = 3 )
	  : ssgSimpleList ( sizeof(ssgaCloudLayer*), init ) { }

  ~ssgaCloudLayerList () { removeAll(); }

  int getNum (void) { return total ; }

  ssgaCloudLayer* get ( unsigned int n )
  {
    assert(n<total);
    return *( (ssgaCloudLayer**) raw_get ( n ) ) ;
  }

  void add ( ssgaCloudLayer* item ) { raw_add ( (char *) &item ) ;}

  void removeAll ()
  {
    for ( int i = 0; i < getNum (); i++ )
      delete get (i) ;
    ssgSimpleList::removeAll () ;
  }
} ;


class ssgaStars
{
private:

  ssgTransform *stars_transform;
  ssgSimpleState *state;

  ssgColourArray *cl;
  ssgVertexArray *vl;

  int old_phase;  // data for optimization

public:

  ssgaStars( void );
  ~ssgaStars( void );

  ssgBranch *build( int num, sgdVec3 *star_data, double star_dist );

  bool reposition( sgVec3 p, double angle );

  bool repaint( double sol_angle, int num, sgdVec3 *star_data );
};


class ssgaSkyDome
{
private:

  ssgTransform *dome_transform;
  ssgSimpleState *dome_state;

  ssgVertexArray *center_disk_vl;
  ssgColourArray *center_disk_cl;

  ssgVertexArray *upper_ring_vl;
  ssgColourArray *upper_ring_cl;

  ssgVertexArray *middle_ring_vl;
  ssgColourArray *middle_ring_cl;

  ssgVertexArray *lower_ring_vl;
  ssgColourArray *lower_ring_cl;

public:

  ssgaSkyDome( void );
  ~ssgaSkyDome( void );

  ssgBranch *build( double hscale = 80000.0, double vscale = 80000.0 );

  bool repositionFlat( sgVec3 p, double spin );
  bool reposition( sgVec3 p, double lon, double lat, double spin );

  bool repaint( sgVec3 sky_color, sgVec3 fog_color, double sol_angle, double vis );
};


class ssgaSky
{
private:

  // components of the sky
  ssgaSkyDome *dome;
  ssgaCelestialBody* sol_ref;
  ssgaCelestialBodyList bodies;
  ssgaCloudLayerList clouds;
  ssgaStars *planets;
  ssgaStars *stars;

  ssgRoot *pre_root, *post_root;

  ssgSelector *pre_selector, *post_selector;
  ssgTransform *pre_transform, *post_transform;
  ssgTransform *bodies_transform, *stars_transform;

  // visibility
  float visibility;
  float effective_visibility;

  // near cloud visibility state variables
  bool in_puff;
  double puff_length;       // in seconds
  double puff_progression;  // in seconds
  double ramp_up;           // in seconds
  double ramp_down;         // in seconds

public:

  ssgaSky( void );
  ~ssgaSky( void );

  void build( double h_radius, double v_radius,
	  int nplanets, sgdVec3 *planet_data,
	  int nstars, sgdVec3 *star_data);

  ssgaCelestialBody* addBody( const char *body_tex_path, const char *halo_tex_path, double size, double dist, bool sol = false );
  ssgaCelestialBody* addBody( ssgSimpleState *orb_state, ssgSimpleState *halo_state, double size, double dist, bool sol = false );
  ssgaCelestialBody* getBody(int i) { return bodies.get(i); }
  int getBodyCount() { return bodies.getNum(); }

  ssgaCloudLayer* addCloud( const char *cloud_tex_path, float span, float elevation, float thickness, float transition );
  ssgaCloudLayer* addCloud( ssgSimpleState *cloud_state, float span, float elevation, float thickness, float transition );
  ssgaCloudLayer* getCloud(int i) { return clouds.get(i); }
  int getCloudCount() { return clouds.getNum(); }

  bool repositionFlat( sgVec3 view_pos, double spin, double dt );
  bool reposition( sgVec3 view_pos, sgVec3 zero_elev, sgVec3 view_up, double lon, double lat, double alt, double spin, double gst, double dt );

  bool repaint( sgVec4 sky_color, sgVec4 fog_color, sgVec4 cloud_color, double sol_angle,
	  int nplanets, sgdVec3 *planet_data,
	  int nstars, sgdVec3 *star_data );

  // modify visibility based on cloud layers, thickness, transition range, and simulated "puffs".
  void modifyVisibility( float alt, float time_factor );

  // draw background portions of sky (do this before you draw rest of your scene).
  void preDraw();

  // draw translucent clouds (do this after you've drawn all oapaque elements of your scene).
  void postDraw( float alt );

  // enable the sky
  inline void enable() {
    pre_selector->select( 1 );
    post_selector->select( 1 );
  }

  // disable the sky
  inline void disable() {
    pre_selector->select( 0 );
    post_selector->select( 0 );
  }

  // current effective visibility
  inline float getVisibility() const { return effective_visibility; }
  inline void setVisibility( float v ) {
    effective_visibility = visibility = v;
  }
} ;


// return a random number between [0.0, 1.0)
inline double ssgaRandom(void)
{
  return(rand() / (double)RAND_MAX);
}

//#if defined( macintosh )
//const float system_gamma = 1.4;
//#elif defined (sgi)
//const float system_gamma = 1.7;
//#else	// others
const float system_gamma = 2.5;
//#endif

// simple architecture independant gamma correction function.
inline void ssgaGammaCorrectRGB(float *color, float reff = 2.5, float system = system_gamma)
{
  color[0] = (float)pow(color[0], reff/system);
  color[1] = (float)pow(color[1], reff/system);
  color[2] = (float)pow(color[2], reff/system);
};

inline void ssgaGammaCorrectC(float *color, float reff = 2.5, float system = system_gamma)
{
  *color = (float)pow(*color, reff/system);
};

inline void ssgaGammaRestoreRGB(float *color, float reff = 2.5, float system = system_gamma)
{
  color[0] = (float)pow(color[0], system/reff);
  color[1] = (float)pow(color[1], system/reff);
  color[2] = (float)pow(color[2], system/reff);
};

inline void ssgaGammaRestoreC(float *color, float reff = 2.5, float system = system_gamma)
{
  *color = (float)pow(*color, system/reff);
};

#endif