1. with GLOBE_3D.Math; 
  2. pragma Elaborate_All (GLOBE_3D.Math); 
  3.  
  4. with Ada.Numerics.Float_Random;         use Ada.Numerics.Float_Random; 
  5.  
  6. package body GLOBE_3D.Stars_sky is 
  7.  
  8.    Star_Colours   : array (1 .. No_of_Stars) of GL.RGB_Color; 
  9.    Star_Positions : array (1 .. No_of_Stars) of Point_3D; -- normalized position on sphere 
  10.  
  11.    procedure Display (Rotation : Matrix_33) is 
  12.  
  13.       use GLOBE_3D.Math; 
  14.  
  15.    begin 
  16.       PushMatrix; 
  17.       Set_GL_Matrix (Rotation); 
  18.       Disable (TEXTURE_2D); 
  19.       for i in 1 .. No_of_Stars loop 
  20.          Color (Star_Colours (i)); 
  21.          GL_Begin (GL.POINTS); 
  22.          Vertex (Star_Positions (i)); 
  23.          GL_End; 
  24.       end loop; 
  25.       PopMatrix; 
  26.    end Display; 
  27.  
  28.    procedure Reset is 
  29.  
  30.       seed : Generator; 
  31.       v    : Vector_3D; 
  32.       int  : Real; 
  33.  
  34.       use REF, GLOBE_3D.Math; 
  35.  
  36.       function Amas return Real is -- expected tendencies : keep near or go far 
  37.  
  38.          r : Real; 
  39.  
  40.       begin 
  41.          r := Real (Random (seed)); 
  42.          r := r * 2.0 - 1.0;       -- r in - 1 .. 1 
  43.          r := r ** 8;              -- almost always ~0 
  44.          r := Exp (r * 1.8) - 1.0; 
  45.          return r; 
  46.       end Amas; 
  47.  
  48.    begin 
  49.       Reset (seed); 
  50.       v := (far_side, 0.0, 0.0); 
  51.       for i in 1 .. No_of_Stars loop 
  52.          v := XYZ_rotation (Amas, Amas, Amas) * v; 
  53.          Star_Positions (i) := v; 
  54.          int := Real (Random (seed)) * 0.3; 
  55.          Star_Colours (i) := (int + 0.15 * Real (Random (seed)), 
  56.                               int + 0.12 * Real (Random (seed)), 
  57.                               int + 0.12 * Real (Random (seed))); 
  58.       end loop; 
  59.    end Reset; 
  60.  
  61. begin 
  62.    Reset; 
  63. end GLOBE_3D.Stars_sky;