]> git.mxchange.org Git - flightgear.git/blob - src/Objects/apt_signs.cxx
Replaced some debugging structure David inadvertantly removed.
[flightgear.git] / src / Objects / apt_signs.cxx
1 // apt_signs.cxx -- build airport signs on the fly
2 //
3 // Written by Curtis Olson, started July 2001.
4 //
5 // Copyright (C) 2001  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 #include <simgear/debug/logstream.hxx>
25 #include <simgear/math/sg_types.hxx>
26
27 #include "apt_signs.hxx"
28 #include "obj.hxx"
29
30
31 ssgBranch *gen_taxi_sign( const string path, const string content ) {
32     // for demo purposes we assume each element (letter) is 1x1 meter.
33     // Sign is placed 0.25 meters above the ground
34
35     ssgBranch *object = new ssgBranch();
36     object->setName( (char *)content.c_str() );
37
38     double offset = content.length() / 2.0;
39
40     for ( unsigned int i = 0; i < content.length(); ++i ) {
41         string material;
42
43         char item = content[i];
44         if ( item == '<' ) {
45             material = "ArrowL.rgb";
46         } else if ( item == '>' ) {
47             material = "ArrowR.rgb";
48         } else if ( item >= 'A' && item <= 'Z' ) {
49             material = "Letter";
50             material += item;
51             material += ".rgb";
52         } else if ( item >= 'a' && item <= 'z' ) {
53             int tmp = item - 'a';
54             char c = 'A' + tmp;
55             material = "Black";
56             material += c;
57             material += ".rgb";
58         } else {
59             SG_LOG( SG_TERRAIN, SG_ALERT,
60                     "Unknown taxi sign code = '" << item << "' !!!!" );
61             return NULL;
62         }
63
64         point_list nodes; nodes.clear();
65         point_list normals; normals.clear();
66         point_list texcoords; texcoords.clear();
67         int_list vertex_index; vertex_index.clear();
68         int_list normal_index; normal_index.clear();
69         int_list tex_index; tex_index.clear();
70
71         nodes.push_back( Point3D( -offset + i, 0, 0.25 ) );
72         nodes.push_back( Point3D( -offset + i + 1, 0, 0.25 ) );
73         nodes.push_back( Point3D( -offset + i, 0, 1.25 ) );
74         nodes.push_back( Point3D( -offset + i + 1, 0, 1.25 ) );
75
76         normals.push_back( Point3D( 0, -1, 0 ) );
77
78         texcoords.push_back( Point3D( 0, 0, 0 ) );
79         texcoords.push_back( Point3D( 1, 0, 0 ) );
80         texcoords.push_back( Point3D( 0, 1, 0 ) );
81         texcoords.push_back( Point3D( 1, 1, 0 ) );
82
83         vertex_index.push_back( 0 );
84         vertex_index.push_back( 1 );
85         vertex_index.push_back( 2 );
86         vertex_index.push_back( 3 );
87
88         normal_index.push_back( 0 );
89         normal_index.push_back( 0 );
90         normal_index.push_back( 0 );
91         normal_index.push_back( 0 );
92
93         tex_index.push_back( 0 );
94         tex_index.push_back( 1 );
95         tex_index.push_back( 2 );
96         tex_index.push_back( 3 );
97
98         ssgLeaf *leaf = gen_leaf( path, GL_TRIANGLE_STRIP, material,
99                                   nodes, normals, texcoords,
100                                   vertex_index, normal_index, tex_index,
101                                   false, NULL );
102
103         object->addKid( leaf );
104     }
105
106     return object;
107 }
108
109
110 ssgBranch *gen_runway_sign( const string path, const string name ) {
111     // for demo purposes we assume each element (letter) is 1x1 meter.
112     // Sign is placed 0.25 meters above the ground
113
114     ssgBranch *object = new ssgBranch();
115     object->setName( (char *)name.c_str() );
116
117     double width = name.length() / 3.0;
118
119     string material = name + ".rgb";
120
121     point_list nodes; nodes.clear();
122     point_list normals; normals.clear();
123     point_list texcoords; texcoords.clear();
124     int_list vertex_index; vertex_index.clear();
125     int_list normal_index; normal_index.clear();
126     int_list tex_index; tex_index.clear();
127
128     nodes.push_back( Point3D( -width, 0, 0.25 ) );
129     nodes.push_back( Point3D( width + 1, 0, 0.25 ) );
130     nodes.push_back( Point3D( -width, 0, 1.25 ) );
131     nodes.push_back( Point3D( width + 1, 0, 1.25 ) );
132
133     normals.push_back( Point3D( 0, -1, 0 ) );
134
135     texcoords.push_back( Point3D( 0, 0, 0 ) );
136     texcoords.push_back( Point3D( 1, 0, 0 ) );
137     texcoords.push_back( Point3D( 0, 1, 0 ) );
138     texcoords.push_back( Point3D( 1, 1, 0 ) );
139
140     vertex_index.push_back( 0 );
141     vertex_index.push_back( 1 );
142     vertex_index.push_back( 2 );
143     vertex_index.push_back( 3 );
144
145     normal_index.push_back( 0 );
146     normal_index.push_back( 0 );
147     normal_index.push_back( 0 );
148     normal_index.push_back( 0 );
149
150     tex_index.push_back( 0 );
151     tex_index.push_back( 1 );
152     tex_index.push_back( 2 );
153     tex_index.push_back( 3 );
154
155     ssgLeaf *leaf = gen_leaf( path, GL_TRIANGLE_STRIP, material,
156                               nodes, normals, texcoords,
157                               vertex_index, normal_index, tex_index,
158                               false, NULL );
159
160     object->addKid( leaf );
161
162     return object;
163 }