]> git.mxchange.org Git - flightgear.git/blob - src/Objects/apt_signs.cxx
Revert to pre-wind-sticking ground reaction forces until they can be debugged.
[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 tex_index; tex_index.clear();
69
70         nodes.push_back( Point3D( -offset + i, 0, 0.25 ) );
71         nodes.push_back( Point3D( -offset + i + 1, 0, 0.25 ) );
72         nodes.push_back( Point3D( -offset + i, 0, 1.25 ) );
73         nodes.push_back( Point3D( -offset + i + 1, 0, 1.25 ) );
74
75         normals.push_back( Point3D( 0, -1, 0 ) );
76         normals.push_back( Point3D( 0, -1, 0 ) );
77         normals.push_back( Point3D( 0, -1, 0 ) );
78         normals.push_back( Point3D( 0, -1, 0 ) );
79
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 ) );
84
85         vertex_index.push_back( 0 );
86         vertex_index.push_back( 1 );
87         vertex_index.push_back( 2 );
88         vertex_index.push_back( 3 );
89
90         tex_index.push_back( 0 );
91         tex_index.push_back( 1 );
92         tex_index.push_back( 2 );
93         tex_index.push_back( 3 );
94
95         ssgLeaf *leaf = gen_leaf( path, GL_TRIANGLE_STRIP, material,
96                                   nodes, normals, texcoords,
97                                   vertex_index, tex_index,
98                                   false, NULL );
99
100         object->addKid( leaf );
101     }
102
103     return object;
104 }
105
106
107 ssgBranch *gen_runway_sign( const string path, const string name ) {
108     // for demo purposes we assume each element (letter) is 1x1 meter.
109     // Sign is placed 0.25 meters above the ground
110
111     ssgBranch *object = new ssgBranch();
112     object->setName( (char *)name.c_str() );
113
114     double width = name.length() / 3.0;
115
116     string material = name + ".rgb";
117
118     point_list nodes; nodes.clear();
119     point_list normals; normals.clear();
120     point_list texcoords; texcoords.clear();
121     int_list vertex_index; vertex_index.clear();
122     int_list tex_index; tex_index.clear();
123
124     nodes.push_back( Point3D( -width, 0, 0.25 ) );
125     nodes.push_back( Point3D( width + 1, 0, 0.25 ) );
126     nodes.push_back( Point3D( -width, 0, 1.25 ) );
127     nodes.push_back( Point3D( width + 1, 0, 1.25 ) );
128
129     normals.push_back( Point3D( 0, -1, 0 ) );
130     normals.push_back( Point3D( 0, -1, 0 ) );
131     normals.push_back( Point3D( 0, -1, 0 ) );
132     normals.push_back( Point3D( 0, -1, 0 ) );
133
134     texcoords.push_back( Point3D( 0, 0, 0 ) );
135     texcoords.push_back( Point3D( 1, 0, 0 ) );
136     texcoords.push_back( Point3D( 0, 1, 0 ) );
137     texcoords.push_back( Point3D( 1, 1, 0 ) );
138
139     vertex_index.push_back( 0 );
140     vertex_index.push_back( 1 );
141     vertex_index.push_back( 2 );
142     vertex_index.push_back( 3 );
143
144     tex_index.push_back( 0 );
145     tex_index.push_back( 1 );
146     tex_index.push_back( 2 );
147     tex_index.push_back( 3 );
148
149     ssgLeaf *leaf = gen_leaf( path, GL_TRIANGLE_STRIP, material,
150                               nodes, normals, texcoords,
151                               vertex_index, tex_index,
152                               false, NULL );
153
154     object->addKid( leaf );
155
156     return object;
157 }