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>
26 #include <simgear/scene/tgdb/leaf.hxx>
28 #include "apt_signs.hxx"
31 ssgBranch *sgMakeTaxiSign( SGMaterialLib *matlib,
32 const string path, const string content )
34 // for demo purposes we assume each element (letter) is 1x1 meter.
35 // Sign is placed 0.25 meters above the ground
37 ssgBranch *object = new ssgBranch();
38 object->setName( (char *)content.c_str() );
40 double offset = content.length() / 2.0;
42 for ( unsigned int i = 0; i < content.length(); ++i ) {
45 char item = content[i];
47 material = "ArrowL.rgb";
48 } else if ( item == '>' ) {
49 material = "ArrowR.rgb";
50 } else if ( item >= 'A' && item <= 'Z' ) {
54 } else if ( item >= 'a' && item <= 'z' ) {
61 SG_LOG( SG_TERRAIN, SG_ALERT,
62 "Unknown taxi sign code = '" << item << "' !!!!" );
66 point_list nodes; nodes.clear();
67 point_list normals; normals.clear();
68 point_list texcoords; texcoords.clear();
69 int_list vertex_index; vertex_index.clear();
70 int_list normal_index; normal_index.clear();
71 int_list tex_index; tex_index.clear();
73 nodes.push_back( Point3D( -offset + i, 0, 0.25 ) );
74 nodes.push_back( Point3D( -offset + i + 1, 0, 0.25 ) );
75 nodes.push_back( Point3D( -offset + i, 0, 1.25 ) );
76 nodes.push_back( Point3D( -offset + i + 1, 0, 1.25 ) );
78 normals.push_back( Point3D( 0, -1, 0 ) );
80 texcoords.push_back( Point3D( 0, 0, 0 ) );
81 texcoords.push_back( Point3D( 1, 0, 0 ) );
82 texcoords.push_back( Point3D( 0, 1, 0 ) );
83 texcoords.push_back( Point3D( 1, 1, 0 ) );
85 vertex_index.push_back( 0 );
86 vertex_index.push_back( 1 );
87 vertex_index.push_back( 2 );
88 vertex_index.push_back( 3 );
90 normal_index.push_back( 0 );
91 normal_index.push_back( 0 );
92 normal_index.push_back( 0 );
93 normal_index.push_back( 0 );
95 tex_index.push_back( 0 );
96 tex_index.push_back( 1 );
97 tex_index.push_back( 2 );
98 tex_index.push_back( 3 );
100 ssgLeaf *leaf = sgMakeLeaf( path, GL_TRIANGLE_STRIP, matlib, material,
101 nodes, normals, texcoords,
102 vertex_index, normal_index, tex_index,
105 object->addKid( leaf );
112 ssgBranch *sgMakeRunwaySign( SGMaterialLib *matlib,
113 const string path, const string name )
115 // for demo purposes we assume each element (letter) is 1x1 meter.
116 // Sign is placed 0.25 meters above the ground
118 ssgBranch *object = new ssgBranch();
119 object->setName( (char *)name.c_str() );
121 double width = name.length() / 3.0;
123 string material = name + ".rgb";
125 point_list nodes; nodes.clear();
126 point_list normals; normals.clear();
127 point_list texcoords; texcoords.clear();
128 int_list vertex_index; vertex_index.clear();
129 int_list normal_index; normal_index.clear();
130 int_list tex_index; tex_index.clear();
132 nodes.push_back( Point3D( -width, 0, 0.25 ) );
133 nodes.push_back( Point3D( width + 1, 0, 0.25 ) );
134 nodes.push_back( Point3D( -width, 0, 1.25 ) );
135 nodes.push_back( Point3D( width + 1, 0, 1.25 ) );
137 normals.push_back( Point3D( 0, -1, 0 ) );
139 texcoords.push_back( Point3D( 0, 0, 0 ) );
140 texcoords.push_back( Point3D( 1, 0, 0 ) );
141 texcoords.push_back( Point3D( 0, 1, 0 ) );
142 texcoords.push_back( Point3D( 1, 1, 0 ) );
144 vertex_index.push_back( 0 );
145 vertex_index.push_back( 1 );
146 vertex_index.push_back( 2 );
147 vertex_index.push_back( 3 );
149 normal_index.push_back( 0 );
150 normal_index.push_back( 0 );
151 normal_index.push_back( 0 );
152 normal_index.push_back( 0 );
154 tex_index.push_back( 0 );
155 tex_index.push_back( 1 );
156 tex_index.push_back( 2 );
157 tex_index.push_back( 3 );
159 ssgLeaf *leaf = sgMakeLeaf( path, GL_TRIANGLE_STRIP, matlib, material,
160 nodes, normals, texcoords,
161 vertex_index, normal_index, tex_index,
164 object->addKid( leaf );