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
SGConfigureDirectionalLights(bool use_point_sprites,bool distance_attenuation,bool use_triangles)57 inline void SGConfigureDirectionalLights( bool use_point_sprites,
58 bool distance_attenuation,
59 bool use_triangles ) {
60 static SGSceneFeatures* sceneFeatures = SGSceneFeatures::instance();
61 sceneFeatures->setEnablePointSpriteLights(use_point_sprites);
62 sceneFeatures->setEnableDistanceAttenuationLights(distance_attenuation);
63 sceneFeatures->setEnableTriangleDirectionalLights(use_triangles);
64 }
65
66 class SGLightFactory {
67 public:
68
69 static osg::Drawable*
70 getLightDrawable(const SGLightBin::Light& light);
71
72 static osg::Drawable*
73 getLightDrawable(const SGDirectionalLightBin::Light& light, bool useTriangles);
74
75 /**
76 * Return a drawable for a very simple point light that isn't
77 * distance scaled.
78 */
79 static osg::Drawable*
80 getLights(const SGLightBin& lights, unsigned inc = 1, float alphaOff = 0);
81
82 static osg::Drawable*
83 getLights(const SGDirectionalLightBin& lights);
84
85 static osg::Drawable*
86 getVasi(const SGVec3f& up, const SGDirectionalLightBin& lights,
87 const SGVec4f& red, const SGVec4f& white);
88
89 static osg::Node*
90 getSequenced(const SGDirectionalLightBin& lights, const simgear::SGReaderWriterOptions* options);
91
92 static osg::Node*
93 getReil(const SGDirectionalLightBin& lights, const simgear::SGReaderWriterOptions* options);
94
95 static osg::Node*
96 getOdal(const SGLightBin& lights, const simgear::SGReaderWriterOptions* options);
97
98 static osg::Node*
99 getHoldShort(const SGDirectionalLightBin& lights, const simgear::SGReaderWriterOptions* options);
100
101 static osg::Node*
102 getGuard(const SGDirectionalLightBin& lights, const simgear::SGReaderWriterOptions* options);
103 };
104
105 simgear::Effect* getLightEffect(float size, const osg::Vec3& attenuation,
106 float minSize, float maxSize, bool directional,
107 const simgear::SGReaderWriterOptions* options);
108 #endif // _SG_PT_LIGHTS_HXX
109