]> git.mxchange.org Git - flightgear.git/blob - src/Objects/pt_lights.hxx
Add a function declaration
[flightgear.git] / src / Objects / 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  - curt@flightgear.org
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., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #ifndef _PT_LIGHTS_HXX
25 #define _PT_LIGHTS_HXX
26
27
28 #ifndef __cplusplus                                                          
29 # error This library requires C++
30 #endif                                   
31
32
33 #ifdef HAVE_CONFIG_H
34 #  include <config.h>
35 #endif
36
37 #include <simgear/compiler.h>
38
39 #include <vector>               // STL
40 #include STL_STRING
41
42 #include <plib/sg.h>
43 #include <plib/ssg.h>           // plib include
44
45 #include <simgear/math/sg_types.hxx>
46
47 SG_USING_STD(string);
48 SG_USING_STD(vector);
49
50
51 typedef vector < int > int_list;
52 typedef int_list::iterator int_list_iterator;
53 typedef int_list::const_iterator int_point_list_iterator;
54
55
56 // Define the various supported light types
57 typedef enum {
58     FG_RWYLIGHT_TAXI = 0,
59     FG_RWYLIGHT_VASI,
60     FG_RWYLIGHT_EDGE,
61     FG_RWYLIGHT_TOUCHDOWN,
62     FG_RWYLIGHT_THRESHOLD,
63     FG_RWYLIGHT_WHITE,
64     FG_RWYLIGHT_RED,
65     FG_RWYLIGHT_GREEN,
66     FG_RWYLIGHT_YELLOW
67 } fgRunwayLightType;
68
69
70 // Generate a directional light.  This routines creates a
71 // 'directional' light that can only be viewed from within 90 degrees
72 // of the specified dir vector.
73
74 // To accomplish this, he routine creates a triangle with the 1st
75 // point coincident with the specified pt and the 2nd and 3rd points
76 // extending upward.  The 1st point is created with an 'alpha' value
77 // of 1 while the 2nd and 3rd points are created with an 'alpha' of
78 // 0.0.
79
80 // If the triangle is drawn in glPolygonMode(GL_FRONT, GL_POINT) mode,
81 // then two important things happen:
82
83 // 1) Only the 3 vertex points are drawn, the 2nd two with an alpha of
84 // 0 so actually only the desired point is rendered.
85
86 // 2) since we are drawing a triangle, back face culling takes care of
87 // eliminating this poing when the view angle relative to dir is
88 // greater than 90 degrees.
89
90 // The final piece of this puzzle is that if we now use environment
91 // mapping on this point, via an appropriate texture we can then
92 // control the intensity and color of the point based on the view
93 // angle relative to 'dir' the optimal view direction of the light
94 // (i.e. the direction the light is pointing.)
95
96 // Yes this get's to be long and convoluted.  If you can suggest a
97 // simpler way, please do! :-)
98
99 ssgLeaf *gen_directional_light( sgVec3 pt, sgVec3 dir, sgVec3 up );
100
101
102 ssgBranch *gen_directional_lights( const point_list &nodes,
103                                    const point_list &normals,
104                                    const int_list &pnt_i,
105                                    const int_list &nml_i,
106                                    const string &material,
107                                    sgVec3 up );
108
109
110 #endif // _PT_LIGHTS_HXX