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++
44 #include <plib/sg.h> // plib include
46 #include <simgear/math/interpolater.hxx>
47 #include <simgear/math/point3d.hxx>
50 // Define a structure containing the global lighting parameters
53 // Lighting look up tables (based on sun angle with local horizon)
54 SGInterpTable *ambient_tbl;
55 SGInterpTable *diffuse_tbl;
56 SGInterpTable *specular_tbl;
57 SGInterpTable *sky_tbl;
61 ///////////////////////////////////////////////////////////
62 // position of the sun in various forms
64 // in geocentric coordinates
65 double sun_lon, sun_gc_lat;
67 // in cartesian coordiantes
70 // (in view coordinates)
73 // inverse (in view coordinates)
76 // the angle between the sun and the local horizontal (in radians)
79 // the rotation around our vertical axis of the sun (relative to
80 // due south with positive numbers going in the counter clockwise
81 // direction.) This is the direction we'd need to face if we
82 // wanted to travel towards the sun.
85 ///////////////////////////////////////////////////////////
86 // Have the same for the moon. Useful for having some light at night
87 // and stuff. I (Durk) also want to use this for adding similar
88 // coloring effects to the moon as I did to the sun.
89 ///////////////////////////////////////////////////////////
90 // position of the moon in various forms
92 // in geocentric coordinates
93 double moon_lon, moon_gc_lat;
95 // in cartesian coordiantes
98 // (in view coordinates)
101 // inverse (in view coordinates)
102 GLfloat moon_vec_inv[4];
104 // the angle between the moon and the local horizontal (in radians)
107 // the rotation around our vertical axis of the moon (relative to
108 // due south with positive numbers going in the counter clockwise
109 // direction.) This is the direction we'd need to face if we
110 // wanted to travel towards the sun.
111 double moon_rotation;
113 ///////////////////////////////////////////////////////////
114 // Derived lighting values
117 GLfloat scene_ambient[4];
120 GLfloat scene_diffuse[4];
123 GLfloat scene_specular[4];
126 GLfloat fog_color[4];
128 // fog color adjusted for sunset effects
129 GLfloat adj_fog_color[4];
131 // clear screen color
132 GLfloat sky_color[4];
137 // initialize lighting tables
140 // update lighting parameters based on current sun position
143 // calculate fog color adjusted for sunrise/sunset effects
144 void UpdateAdjFog( void );
151 // Global shared light parameter structure
152 extern fgLIGHT cur_light_params;