1 // pt_lights.hxx -- build a 'directional' light on the fly
3 // Written by Curtis Olson, started March 2002.
5 // Copyright (C) 2002 Curtis L. Olson - curt@flightgear.org
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.
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.
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.
24 #ifndef _SG_PT_LIGHTS_HXX
25 #define _SG_PT_LIGHTS_HXX
29 # error This library requires C++
33 #include <simgear/compiler.h>
36 #include <vector> // STL
39 #include <plib/ssg.h> // plib include
41 #include <simgear/math/sg_types.hxx>
47 typedef vector < int > int_list;
48 typedef int_list::iterator int_list_iterator;
49 typedef int_list::const_iterator int_point_list_iterator;
52 // Define the various supported light types
57 SG_RWYLIGHT_TOUCHDOWN,
58 SG_RWYLIGHT_THRESHOLD,
66 // Generate a directional light. This routines creates a
67 // 'directional' light that can only be viewed from within 90 degrees
68 // of the specified dir vector.
70 // To accomplish this, he routine creates a triangle with the 1st
71 // point coincident with the specified pt and the 2nd and 3rd points
72 // extending upward. The 1st point is created with an 'alpha' value
73 // of 1 while the 2nd and 3rd points are created with an 'alpha' of
76 // If the triangle is drawn in glPolygonMode(GL_FRONT, GL_POINT) mode,
77 // then two important things happen:
79 // 1) Only the 3 vertex points are drawn, the 2nd two with an alpha of
80 // 0 so actually only the desired point is rendered.
82 // 2) since we are drawing a triangle, back face culling takes care of
83 // eliminating this poing when the view angle relative to dir is
84 // greater than 90 degrees.
86 // The final piece of this puzzle is that if we now use environment
87 // mapping on this point, via an appropriate texture we can then
88 // control the intensity and color of the point based on the view
89 // angle relative to 'dir' the optimal view direction of the light
90 // (i.e. the direction the light is pointing.)
92 // Yes this get's to be long and convoluted. If you can suggest a
93 // simpler way, please do! :-)
95 ssgLeaf *sgMakeDirectionalLight( sgVec3 pt, sgVec3 dir, sgVec3 up );
98 ssgBranch *sgMakeDirectionalLights( const point_list &nodes,
99 const point_list &normals,
100 const int_list &pnt_i,
101 const int_list &nml_i,
102 SGMaterialLib *matlib,
103 const string &material,
107 #endif // _SG_PT_LIGHTS_HXX