Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
atmosphere.h
Go to the documentation of this file.
1 #include "gfx/vec.h"
2 #include "gfxlib_struct.h"
3 #include "gfx/matrix.h"
4 #include "gfx/mesh.h"
5 #include <vector>
6 
7 class Atmosphere
8 {
9 public:
10  struct Parameters
11  {
12  /* High level parameters */
13  /* coefficients for capturing scattering effects of the
14  * atmospheric composition/density */
15  float radius;
16  /* low angle */
18  /* low angle */
20  /* high angle */
22  /* high angle */
24  float scattering;
25  /* "scattering" coefficient, basically
26  * how much the low_color spreads around */
27  };
28 
29 private:
30  Parameters user_params;
31 
32  class SunBox
33  {
34 public: SunBox( Mesh *m ) : sunbox( m ) {}
35  ~SunBox();
36  Mesh *sunbox;
37  };
38  void setArray( float*, const GFXColor& );
39  void setArray1( float*, const GFXColor& );
40 /* Internal state information */
41  Mesh *dome; /* entire sky; for texture mapping */
42 /* 3 rendering passes, to preserve framerate */
43  Mesh *cap; /* mid to zenith */
44  Mesh *stack; /* horizon to zenith */
45 /* box around the sun (single star for now) */
46  std::vector< SunBox* >sunboxes;
47  Matrix tmatrix;
48  QVector position;
49 /* lighting contexts for the above 3 */
50  int l0, l1, l2;
51  int divisions;
52 
53 public: Atmosphere( const Parameters &params );
54  ~Atmosphere();
55  const Parameters& parameters();
56  void SetParameters( const Parameters &params );
57 
58 /* Update the precomputed mesh to the new parameters. This is
59  * expensive, so let the upper layers decide when to do this
60  */
61 
62 /* ugh, make update just change the lighting state */
63  void Update( const QVector &position, const Matrix &tmatrix );
64  void Draw();
65  static void ProcessDrawQueue();
66  void SetMatricesAndDraw( const QVector &position, const Matrix tmatrix );
67 /* inherit the orientation of
68  * the transformation matrix */
69  static void DrawAtmospheres();
70 };
71