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/debug/logstream.hxx>
25 #include <simgear/math/sg_types.hxx>
27 #include "apt_signs.hxx"
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
35 ssgBranch *object = new ssgBranch();
36 object->setName( (char *)content.c_str() );
38 double offset = content.length() / 2.0;
40 for ( unsigned int i = 0; i < content.length(); ++i ) {
43 char item = content[i];
45 material = "ArrowL.rgb";
46 } else if ( item == '>' ) {
47 material = "ArrowR.rgb";
48 } else if ( item >= 'A' && item <= 'Z' ) {
52 } else if ( item >= 'a' && item <= 'z' ) {
59 SG_LOG( SG_TERRAIN, SG_ALERT,
60 "Unknown taxi sign code = '" << item << "' !!!!" );
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();
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 ) );
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 normal_index.push_back( 0 );
89 normal_index.push_back( 0 );
90 normal_index.push_back( 0 );
91 normal_index.push_back( 0 );
93 tex_index.push_back( 0 );
94 tex_index.push_back( 1 );
95 tex_index.push_back( 2 );
96 tex_index.push_back( 3 );
98 ssgLeaf *leaf = gen_leaf( path, GL_TRIANGLE_STRIP, material,
99 nodes, normals, texcoords,
100 vertex_index, normal_index, tex_index,
103 object->addKid( leaf );
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
114 ssgBranch *object = new ssgBranch();
115 object->setName( (char *)name.c_str() );
117 double width = name.length() / 3.0;
119 string material = name + ".rgb";
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();
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 ) );
133 normals.push_back( Point3D( 0, -1, 0 ) );
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 ) );
140 vertex_index.push_back( 0 );
141 vertex_index.push_back( 1 );
142 vertex_index.push_back( 2 );
143 vertex_index.push_back( 3 );
145 normal_index.push_back( 0 );
146 normal_index.push_back( 0 );
147 normal_index.push_back( 0 );
148 normal_index.push_back( 0 );
150 tex_index.push_back( 0 );
151 tex_index.push_back( 1 );
152 tex_index.push_back( 2 );
153 tex_index.push_back( 3 );
155 ssgLeaf *leaf = gen_leaf( path, GL_TRIANGLE_STRIP, material,
156 nodes, normals, texcoords,
157 vertex_index, normal_index, tex_index,
160 object->addKid( leaf );