1 // apt_signs.cxx -- build airport signs on the fly
3 // Written by Curtis Olson, started July 2001.
5 // Copyright (C) 2001 Curtis L. Olson - http://www.flightgear.org/~curt
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 # include <simgear_config.h>
27 #include <simgear/debug/logstream.hxx>
28 #include <simgear/math/sg_types.hxx>
29 #include <simgear/scene/tgdb/leaf.hxx>
31 #include "apt_signs.hxx"
34 ssgBranch *sgMakeTaxiSign( SGMaterialLib *matlib,
35 const string path, const string content )
37 // for demo purposes we assume each element (letter) is 1x1 meter.
38 // Sign is placed 0.25 meters above the ground
40 ssgBranch *object = new ssgBranch();
41 object->setName( (char *)content.c_str() );
43 double offset = content.length() / 2.0;
45 for ( unsigned int i = 0; i < content.length(); ++i ) {
48 char item = content[i];
50 material = "ArrowL.rgb";
51 } else if ( item == '>' ) {
52 material = "ArrowR.rgb";
53 } else if ( item >= 'A' && item <= 'Z' ) {
57 } else if ( item >= 'a' && item <= 'z' ) {
64 SG_LOG( SG_TERRAIN, SG_ALERT,
65 "Unknown taxi sign code = '" << item << "' !!!!" );
69 point_list nodes; nodes.clear();
70 point_list normals; normals.clear();
71 point_list texcoords; texcoords.clear();
72 int_list vertex_index; vertex_index.clear();
73 int_list normal_index; normal_index.clear();
74 int_list tex_index; tex_index.clear();
76 nodes.push_back( Point3D( -offset + i, 0, 0.25 ) );
77 nodes.push_back( Point3D( -offset + i + 1, 0, 0.25 ) );
78 nodes.push_back( Point3D( -offset + i, 0, 1.25 ) );
79 nodes.push_back( Point3D( -offset + i + 1, 0, 1.25 ) );
81 normals.push_back( Point3D( 0, -1, 0 ) );
83 texcoords.push_back( Point3D( 0, 0, 0 ) );
84 texcoords.push_back( Point3D( 1, 0, 0 ) );
85 texcoords.push_back( Point3D( 0, 1, 0 ) );
86 texcoords.push_back( Point3D( 1, 1, 0 ) );
88 vertex_index.push_back( 0 );
89 vertex_index.push_back( 1 );
90 vertex_index.push_back( 2 );
91 vertex_index.push_back( 3 );
93 normal_index.push_back( 0 );
94 normal_index.push_back( 0 );
95 normal_index.push_back( 0 );
96 normal_index.push_back( 0 );
98 tex_index.push_back( 0 );
99 tex_index.push_back( 1 );
100 tex_index.push_back( 2 );
101 tex_index.push_back( 3 );
103 ssgLeaf *leaf = sgMakeLeaf( path, GL_TRIANGLE_STRIP, matlib, material,
104 nodes, normals, texcoords,
105 vertex_index, normal_index, tex_index,
108 object->addKid( leaf );
115 ssgBranch *sgMakeRunwaySign( SGMaterialLib *matlib,
116 const string path, const string name )
118 // for demo purposes we assume each element (letter) is 1x1 meter.
119 // Sign is placed 0.25 meters above the ground
121 ssgBranch *object = new ssgBranch();
122 object->setName( (char *)name.c_str() );
124 double width = name.length() / 3.0;
126 string material = name + ".rgb";
128 point_list nodes; nodes.clear();
129 point_list normals; normals.clear();
130 point_list texcoords; texcoords.clear();
131 int_list vertex_index; vertex_index.clear();
132 int_list normal_index; normal_index.clear();
133 int_list tex_index; tex_index.clear();
135 nodes.push_back( Point3D( -width, 0, 0.25 ) );
136 nodes.push_back( Point3D( width + 1, 0, 0.25 ) );
137 nodes.push_back( Point3D( -width, 0, 1.25 ) );
138 nodes.push_back( Point3D( width + 1, 0, 1.25 ) );
140 normals.push_back( Point3D( 0, -1, 0 ) );
142 texcoords.push_back( Point3D( 0, 0, 0 ) );
143 texcoords.push_back( Point3D( 1, 0, 0 ) );
144 texcoords.push_back( Point3D( 0, 1, 0 ) );
145 texcoords.push_back( Point3D( 1, 1, 0 ) );
147 vertex_index.push_back( 0 );
148 vertex_index.push_back( 1 );
149 vertex_index.push_back( 2 );
150 vertex_index.push_back( 3 );
152 normal_index.push_back( 0 );
153 normal_index.push_back( 0 );
154 normal_index.push_back( 0 );
155 normal_index.push_back( 0 );
157 tex_index.push_back( 0 );
158 tex_index.push_back( 1 );
159 tex_index.push_back( 2 );
160 tex_index.push_back( 3 );
162 ssgLeaf *leaf = sgMakeLeaf( path, GL_TRIANGLE_STRIP, matlib, material,
163 nodes, normals, texcoords,
164 vertex_index, normal_index, tex_index,
167 object->addKid( leaf );