//
// Written by Curtis Olson, started April 1998.
//
-// Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
+// Copyright (C) 1998 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
# include <config.h>
#endif
-#ifdef HAVE_WINDOWS_H
-# include <windows.h>
-#endif
-
-#include <GL/gl.h>
-
-#include <plib/sg.h> // plib include
+#include <simgear/compiler.h>
+#include <simgear/props/props.hxx>
#include <simgear/structure/subsystem_mgr.hxx>
+#include <simgear/props/tiedpropertylist.hxx>
#include <simgear/math/interpolater.hxx>
-#include <simgear/math/point3d.hxx>
// Define a structure containing the global lighting parameters
*/
// in geocentric coordinates
- double _sun_lon, _sun_gc_lat;
+ double _sun_lon, _sun_lat;
double _moon_lon, _moon_gc_lat;
- // in cartesian coordiantes
- Point3D _sunpos, _moonpos;
-
// (in view coordinates)
- sgVec4 _sun_vec, _moon_vec;
+ SGVec4f _sun_vec, _moon_vec;
// inverse (in view coordinates)
- sgVec4 _sun_vec_inv, _moon_vec_inv;
+ SGVec4f _sun_vec_inv, _moon_vec_inv;
// the angle between the celestial object and the local horizontal
// (in radians)
*/
// ambient, diffuse and specular component
- GLfloat _scene_ambient[4];
- GLfloat _scene_diffuse[4];
- GLfloat _scene_specular[4];
+ SGVec4f _scene_ambient;
+ SGVec4f _scene_diffuse;
+ SGVec4f _scene_specular;
+ SGVec4f _scene_chrome;
// clear sky, fog and cloud color
- GLfloat _sky_color[4];
- GLfloat _fog_color[4];
- GLfloat _cloud_color[4];
+ SGVec4f _sun_color;
+ SGVec4f _sky_color;
+ SGVec4f _fog_color;
+ SGVec4f _cloud_color;
// clear sky and fog color adjusted for sunset effects
- GLfloat _adj_fog_color[4];
- GLfloat _adj_sky_color[4];
+ SGVec4f _adj_fog_color;
+ SGVec4f _adj_sky_color;
+
+ // input parameters affected by the weather system
+ float _saturation;
+ float _scattering;
+ float _overcast;
double _dt_total;
void update_sky_color ();
void update_adj_fog_color ();
+ void updateSunPos();
+
+ // properties for chrome light; not a tie because I want to fire
+ // property listeners when the values change.
+ SGPropertyNode_ptr _chromeProps[4];
+
+ SGPropertyNode_ptr _sunAngleRad;
+
+ SGPropertyNode_ptr _humidity;
+
+ simgear::TiedPropertyList _tiedProperties;
+
+ /**
+ * Tied-properties helper, record nodes which are tied for easy un-tie-ing
+ */
+ template <typename T>
+ void tie(SGPropertyNode* aNode, const char* aRelPath, const SGRawValue<T>& aRawValue)
+ {
+ _tiedProperties.Tie(aNode->getNode(aRelPath, true), aRawValue);
+ }
+
public:
FGLight ();
// Color related functions
- inline float *scene_ambient () const { return (float *)_scene_ambient; }
- inline float *scene_diffuse () const { return (float *)_scene_diffuse; }
- inline float *scene_specular () const { return (float *)_scene_specular; }
-
- inline float *sky_color () const { return (float *)_sky_color; }
- inline float *cloud_color () const { return (float *)_cloud_color; }
- inline float *adj_fog_color () const { return (float *)_adj_fog_color; }
+ inline const SGVec4f& scene_ambient () const { return _scene_ambient; }
+ inline const SGVec4f& scene_diffuse () const { return _scene_diffuse; }
+ inline const SGVec4f& scene_specular () const { return _scene_specular; }
+ inline const SGVec4f& scene_chrome () const { return _scene_chrome; }
+ inline const SGVec4f& sky_color () const { return _sky_color; }
+ inline const SGVec4f& cloud_color () const { return _cloud_color; }
+ inline const SGVec4f& adj_fog_color () const { return _adj_fog_color; }
+ inline const SGVec4f& adj_sky_color () const { return _adj_sky_color; }
// Sun related functions
inline double get_sun_lon () const { return _sun_lon; }
inline void set_sun_lon (double l) { _sun_lon = l; }
- inline double get_sun_gc_lat () const { return _sun_gc_lat; }
- inline void set_sun_gc_lat (double l) { _sun_gc_lat = l; }
-
- inline Point3D get_sunpos () const { return _sunpos; }
- inline void set_sunpos (Point3D p) { _sunpos = p; }
+ inline double get_sun_lat () const { return _sun_lat; }
+ inline void set_sun_lat (double l) { _sun_lat = l; }
- inline float *sun_vec () const { return (float *)_sun_vec; }
- inline float *sun_vec_inv () const { return (float *)_sun_vec_inv; }
+ inline SGVec4f& sun_vec () { return _sun_vec; }
+ inline SGVec4f& sun_vec_inv () { return _sun_vec_inv; }
// Moon related functions
inline double get_moon_gc_lat () const { return _moon_gc_lat; }
inline void set_moon_gc_lat (double l) { _moon_gc_lat = l; }
- inline Point3D get_moonpos () const { return _moonpos; }
- inline void set_moonpos (Point3D p) { _moonpos = p; }
-
- inline float *moon_vec () const { return (float *)_moon_vec; }
- inline float *moon_vec_inv () const { return (float *)_moon_vec_inv; }
+ inline const SGVec4f& moon_vec () const { return _moon_vec; }
+ inline const SGVec4f& moon_vec_inv () const { return _moon_vec_inv; }
};
#endif // _LIGHT_HXX