]> git.mxchange.org Git - simgear.git/blob - simgear/scene/tgdb/pt_lights.hxx
Replace SG_USE_STD() by using std::
[simgear.git] / simgear / scene / tgdb / pt_lights.hxx
1 // pt_lights.hxx -- build a 'directional' light on the fly
2 //
3 // Written by Curtis Olson, started March 2002.
4 //
5 // Copyright (C) 2002  Curtis L. Olson  - http://www.flightgear.org/~curt
6 //
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.
11 //
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.
16 //
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23
24 #ifndef _SG_PT_LIGHTS_HXX
25 #define _SG_PT_LIGHTS_HXX
26
27
28 #ifndef __cplusplus
29 # error This library requires C++
30 #endif
31
32 #include <simgear/compiler.h>
33
34 #include <string>
35 #include <vector>               // STL
36
37 #include <osg/Drawable>
38 #include <osg/Node>
39 #include <osg/Point>
40
41 #include <simgear/math/sg_types.hxx>
42 #include <simgear/scene/material/matlib.hxx>
43 #include <simgear/scene/util/SGSceneFeatures.hxx>
44
45 #include "SGLightBin.hxx"
46 #include "SGDirectionalLightBin.hxx"
47
48 using std::string;
49 using std::vector;
50
51 // Specify the way we want to draw directional point lights (assuming the
52 // appropriate extensions are available.)
53
54 inline void SGConfigureDirectionalLights( bool use_point_sprites,
55                                    bool enhanced_lighting,
56                                    bool distance_attenuation ) {
57   static SGSceneFeatures* sceneFeatures = SGSceneFeatures::instance();
58   sceneFeatures->setEnablePointSpriteLights(use_point_sprites);
59   sceneFeatures->setEnableDistanceAttenuationLights(distance_attenuation);
60 }
61
62 class SGPointSpriteLightCullCallback : public osg::NodeCallback {
63 public:
64   SGPointSpriteLightCullCallback(const osg::Vec3& da = osg::Vec3(1, 0.001, 0.0002),
65                                  float sz = 4);
66   SGPointSpriteLightCullCallback(osg::Point* point);
67
68   virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
69
70 private:
71   osg::ref_ptr<osg::StateSet> _pointSpriteStateSet;
72   osg::ref_ptr<osg::StateSet> _distanceAttenuationStateSet;
73 };
74
75 class SGLightFactory {
76 public:
77
78   static osg::Node*
79   getLight(const SGLightBin::Light& light);
80
81   static osg::Node*
82   getLight(const SGDirectionalLightBin::Light& light);
83
84   static osg::Drawable*
85   getLights(const SGLightBin& lights, unsigned inc = 1, float alphaOff = 0);
86
87   static osg::Drawable*
88   getLights(const SGDirectionalLightBin& lights);
89
90   static osg::Drawable*
91   getVasi(const SGVec3f& up, const SGDirectionalLightBin& lights,
92           const SGVec4f& red, const SGVec4f& white);
93
94   static osg::Node*
95   getSequenced(const SGDirectionalLightBin& lights);
96
97   static osg::Node*
98   getOdal(const SGLightBin& lights);
99 };
100
101 #endif // _SG_PT_LIGHTS_HXX