]> git.mxchange.org Git - simgear.git/blob - simgear/scene/tgdb/pt_lights.hxx
OSG 3.2.0 compatibility and surface light effects.
[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/SGReaderWriterOptions.hxx>
44 #include <simgear/scene/util/SGSceneFeatures.hxx>
45
46 #include "SGLightBin.hxx"
47 #include "SGDirectionalLightBin.hxx"
48
49 namespace simgear
50 {
51 class Effect;
52 }
53
54 // Specify the way we want to draw directional point lights (assuming the
55 // appropriate extensions are available.)
56
57 inline void SGConfigureDirectionalLights( bool use_point_sprites,
58                                    bool enhanced_lighting,
59                                    bool distance_attenuation ) {
60   static SGSceneFeatures* sceneFeatures = SGSceneFeatures::instance();
61   sceneFeatures->setEnablePointSpriteLights(use_point_sprites);
62   sceneFeatures->setEnableDistanceAttenuationLights(distance_attenuation);
63 }
64
65 class SGLightFactory {
66 public:
67
68   static osg::Drawable*
69   getLightDrawable(const SGLightBin::Light& light);
70
71   static osg::Drawable*
72   getLightDrawable(const SGDirectionalLightBin::Light& light);
73
74   /**
75    * Return a drawable for a very simple point light that isn't
76    * distance scaled.
77    */
78   static osg::Drawable*
79   getLights(const SGLightBin& lights, unsigned inc = 1, float alphaOff = 0);
80
81   static osg::Drawable*
82   getLights(const SGDirectionalLightBin& lights);
83
84   static osg::Drawable*
85   getVasi(const SGVec3f& up, const SGDirectionalLightBin& lights,
86           const SGVec4f& red, const SGVec4f& white);
87
88   static osg::Node*
89   getSequenced(const SGDirectionalLightBin& lights, const simgear::SGReaderWriterOptions* options);
90
91   static osg::Node*
92   getOdal(const SGLightBin& lights, const simgear::SGReaderWriterOptions* options);
93
94   static osg::Node*
95   getHoldShort(const SGDirectionalLightBin& lights, const simgear::SGReaderWriterOptions* options);
96
97   static osg::Node*
98   getGuard(const SGDirectionalLightBin& lights, const simgear::SGReaderWriterOptions* options);
99 };
100
101 simgear::Effect* getLightEffect(float size, const osg::Vec3& attenuation,
102                                 float minSize, float maxSize, bool directional,
103                                 const simgear::SGReaderWriterOptions* options);
104 #endif // _SG_PT_LIGHTS_HXX