1 // light.hxx -- lighting routines
3 // Written by Curtis Olson, started April 1998.
5 // Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 # error This library requires C++
43 #include <plib/sg.h> // plib include
45 #include <simgear/math/interpolater.hxx>
46 #include <simgear/math/point3d.hxx>
49 // Define a structure containing the global lighting parameters
52 // Lighting look up tables (based on sun angle with local horizon)
53 SGInterpTable *ambient_tbl;
54 SGInterpTable *diffuse_tbl;
55 SGInterpTable *specular_tbl;
56 SGInterpTable *sky_tbl;
60 ///////////////////////////////////////////////////////////
61 // position of the sun in various forms
63 // in geocentric coordinates
64 double sun_lon, sun_gc_lat;
66 // in cartesian coordiantes
69 // (in view coordinates)
72 // inverse (in view coordinates)
75 // the angle between the sun and the local horizontal (in radians)
78 // the rotation around our vertical axis of the sun (relative to
79 // due south with positive numbers going in the counter clockwise
80 // direction.) This is the direction we'd need to face if we
81 // wanted to travel towards the sun.
84 ///////////////////////////////////////////////////////////
85 // Have the same for the moon. Useful for having some light at night
86 // and stuff. I (Durk) also want to use this for adding similar
87 // coloring effects to the moon as I did to the sun.
88 ///////////////////////////////////////////////////////////
89 // position of the moon in various forms
91 // in geocentric coordinates
92 double moon_lon, moon_gc_lat;
94 // in cartesian coordiantes
97 // (in view coordinates)
100 // inverse (in view coordinates)
101 GLfloat moon_vec_inv[4];
103 // the angle between the moon and the local horizontal (in radians)
106 // the rotation around our vertical axis of the moon (relative to
107 // due south with positive numbers going in the counter clockwise
108 // direction.) This is the direction we'd need to face if we
109 // wanted to travel towards the sun.
110 double moon_rotation;
112 ///////////////////////////////////////////////////////////
113 // Derived lighting values
116 GLfloat scene_ambient[4];
119 GLfloat scene_diffuse[4];
122 GLfloat scene_specular[4];
125 GLfloat fog_color[4];
127 // fog color adjusted for sunset effects
128 GLfloat adj_fog_color[4];
130 // clear screen color
131 GLfloat sky_color[4];
136 // initialize lighting tables
139 // update lighting parameters based on current sun position
142 // calculate fog color adjusted for sunrise/sunset effects
143 void UpdateAdjFog( void );
150 // Global shared light parameter structure
151 extern fgLIGHT cur_light_params;