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 - 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 #include <simgear/math/sg_types.hxx>
26 #include "apt_signs.hxx"
30 ssgBranch *gen_taxi_sign( const string path, const string content ) {
31 // for demo purposes we assume each element (letter) is 1x1 meter.
32 // Sign is placed 0.25 meters above the ground
34 ssgBranch *object = new ssgBranch();
35 object->setName( (char *)content.c_str() );
37 double offset = content.length() / 2.0;
39 for ( unsigned int i = 0; i < content.length(); ++i ) {
42 char item = content[i];
44 material = "ArrowL.rgb";
45 } else if ( item == '>' ) {
46 material = "ArrowR.rgb";
47 } else if ( item >= 'A' && item <= 'Z' ) {
51 } else if ( item >= 'a' && item <= 'z' ) {
58 cout << "Unknown taxi sign code = '" << item << "' !!!!" << endl;
62 point_list nodes; nodes.clear();
63 point_list normals; normals.clear();
64 point_list texcoords; texcoords.clear();
65 int_list vertex_index; vertex_index.clear();
66 int_list tex_index; tex_index.clear();
68 nodes.push_back( Point3D( -offset + i, 0, 0.25 ) );
69 nodes.push_back( Point3D( -offset + i + 1, 0, 0.25 ) );
70 nodes.push_back( Point3D( -offset + i, 0, 1.25 ) );
71 nodes.push_back( Point3D( -offset + i + 1, 0, 1.25 ) );
73 normals.push_back( Point3D( 0, -1, 0 ) );
74 normals.push_back( Point3D( 0, -1, 0 ) );
75 normals.push_back( Point3D( 0, -1, 0 ) );
76 normals.push_back( Point3D( 0, -1, 0 ) );
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 ) );
83 vertex_index.push_back( 0 );
84 vertex_index.push_back( 1 );
85 vertex_index.push_back( 2 );
86 vertex_index.push_back( 3 );
88 tex_index.push_back( 0 );
89 tex_index.push_back( 1 );
90 tex_index.push_back( 2 );
91 tex_index.push_back( 3 );
93 ssgLeaf *leaf = gen_leaf( path, GL_TRIANGLE_STRIP, material,
94 nodes, normals, texcoords,
95 vertex_index, tex_index,
98 object->addKid( leaf );
105 ssgBranch *gen_runway_sign( const string path, const string name ) {
106 // for demo purposes we assume each element (letter) is 1x1 meter.
107 // Sign is placed 0.25 meters above the ground
109 ssgBranch *object = new ssgBranch();
110 object->setName( (char *)name.c_str() );
112 double width = name.length() / 3.0;
114 string material = name + ".rgb";
116 point_list nodes; nodes.clear();
117 point_list normals; normals.clear();
118 point_list texcoords; texcoords.clear();
119 int_list vertex_index; vertex_index.clear();
120 int_list tex_index; tex_index.clear();
122 nodes.push_back( Point3D( -width, 0, 0.25 ) );
123 nodes.push_back( Point3D( width + 1, 0, 0.25 ) );
124 nodes.push_back( Point3D( -width, 0, 1.25 ) );
125 nodes.push_back( Point3D( width + 1, 0, 1.25 ) );
127 normals.push_back( Point3D( 0, -1, 0 ) );
128 normals.push_back( Point3D( 0, -1, 0 ) );
129 normals.push_back( Point3D( 0, -1, 0 ) );
130 normals.push_back( Point3D( 0, -1, 0 ) );
132 texcoords.push_back( Point3D( 0, 0, 0 ) );
133 texcoords.push_back( Point3D( 1, 0, 0 ) );
134 texcoords.push_back( Point3D( 0, 1, 0 ) );
135 texcoords.push_back( Point3D( 1, 1, 0 ) );
137 vertex_index.push_back( 0 );
138 vertex_index.push_back( 1 );
139 vertex_index.push_back( 2 );
140 vertex_index.push_back( 3 );
142 tex_index.push_back( 0 );
143 tex_index.push_back( 1 );
144 tex_index.push_back( 2 );
145 tex_index.push_back( 3 );
147 ssgLeaf *leaf = gen_leaf( path, GL_TRIANGLE_STRIP, material,
148 nodes, normals, texcoords,
149 vertex_index, tex_index,
152 object->addKid( leaf );