Debian Codegraph @

Docs/README.scenery

raw
1 This document describes how FlightGear searches and loads scenery, how to
2 add static objects to the scenery as well as the syntax of *.stg files.
3
4
5
6
7 Contents ----------------------------------------------------------------------
8
9 1 scenery path
10 2 terrasync
11
12 3 stg files
13 3.1 OBJECT_BASE
14 3.2 OBJECT
15 3.4 OBJECT_SHARED / OBJECT_SHARED_AGL
16 3.3 OBJECT_STATIC / OBJECT_STATIC_AGL
17 3.5 OBJECT_SIGN /OBJECT_SIGN_AGL
18 3.6 BUILDING_ROUGH / BUILDING_DETAILED
19 3.7 ROAD_ROUGH / ROAD_DETAILED
20 3.8 RAILWAY_ROUGH / RAILWAY_DETAILED
21 3.9 BUILDING_LIST
22 3.10 TREE_LIST
23 3.11 LINE_FEATURE_LIST
24 3.12 OBJECT_LIGHT
25 3.13 LIGHT_LIST
26 3.14 OBJECT_INSTANCED
27
28 4 model manager ("/models/model")
29 4.1 static objects
30 4.2 dynamic objects
31 4.3 loading/unloading at runtime
32
33 5 tools for object placing
34 5.1 calc-tile.pl
35 5.2 ufo scenery object editor
36
37 6 embedded Nasal
38 6.1 static models
39 6.2 AI models
40
41 7 WS3.0 tools
42 7.1
43
44
45 1 scenery path ----------------------------------------------------------------
46
47 FlightGear loads scenery by default from the Scenery/ subdirectory of its
48 data directory. The path to this data directory can be set via environment
49 variable FG_ROOT or the --fg-root option. The scenery path can be set
50 independently via environment variable FG_SCENERY or option --fg-scenery.
51 The order of precedence is as follows:
52
53 --fg-scenery=/some/dir ... highest priority
54 $FG_SCENERY
55 $FG_ROOT/Scenery/ ... lowest priority
56
57
58 A scenery specification may be a list of paths, separated by the OS-specific
59 path separator (colon on Unix/OSX, semicolon on MS Windows). The paths are
60 searched in the order from left to right:
61
62 FG_SCENERY=/first/dir:/second/dir:/third/dir
63 (likewise with --fg-scenery option)
64
65 Each of the scenery paths normally contains a set of directories, each containing
66 a particular scenery type :
67
68 Terrain/ containing the terrain mesh and airport data
69 Objects/ containing placed scenery objects such as large landmarks, bridges
70 Pylons/ containing electricity pylon Models
71 Roads/ containing detailed road and railways
72 Buildings/ containing osm2city-generated buildings
73
74 The user can control at runtime which of these directories is actually loaded
75 via the property tree:
76 /sim/rendering/scenery-path-suffix[n]/name defines the name of the sub-directory
77 /sim/rendering/scenery-path-suffix[n]/enabled indicates whether it is loaded.
78
79 hese properties are typically set in the Rendering Options menu.
80
81 In turn each of these contains a tree of directories breaking down the world into
82 10x10 degree and then 1x1 degree chunks. E.g. Terrain/w130n30/w123n37/
83
84 For backwards compatibility reasons, the top level can alternatively just
85 contain 10x10 degree directories. E.g. w130n30/w123n37/
86
87 Note that as soon as any of the scenery-path-suffix directories is found, any
88 10x10 directory on the same hierarchy level will be ignored!
89
90 This example shows which directories are used to search for scenery:
91
92 $ ls /first/dir
93 w130n30/ searched
94
95 $ ls /second/dir
96 Objects/ searched
97 Terrain/ searched
98 w130n30/ *not* searched
99
100 $ ls /third/dir
101 Terrain/ searched
102 w130n30/ *not* searched
103
104
105 Within the 1x1 degree chunks, the ground is further broken up into "tiles" of
106 approx 20x20km. If FlightGear searches for a particular "tile" file, let's say for
107 "w130n30/w123n37/942050.stg", then (using the above examples) it looks
108 into
109
110 /first/dir/w130n30/w123n37/942050.stg (A)
111
112 /second/dir/Terrain/w130n30/w123n37/942050.stg (B)\__ same path element
113 /second/dir/Objects/w130n30/w123n37/942050.stg (C)/ /second/dir
114 /second/dir/Pylons/w130n30/w123n37/942050.stg (D)/
115 /second/dir/Roads/w130n30/w123n37/942050.stg (E)/
116 /second/dir/Buildings/w130n30/w123n37/942050.stg (F)/
117
118 /third/dir/Terrain/w130n30/w123n37/942050.stg (G)
119
120 As soon as it finds an OBJECT_BASE entry it only finishes this
121 path element and then stops scanning. So, if (B) contains an entry
122 "OBJECT_BASE 942050.btg, then the other directories in /second/dir (C, D, E, F)
123 will be read. But (G) will *not*!
124
125 This searching behavior is usually used to collect user-downloaded scenery first,
126 then to read automatically downloaded scenery (see terrasync
127 below), then standard scenery and objects that came with the distribution.
128 So a typical scenery path specification could look like this:
129
130 FG_SCENERY=$HOME/.fgfs/Scenery:$HOME/.fgfs/TerraSync:$FG_ROOT/Scenery
131
132 The first path would then be populated by the user with unpacked scenery
133 archives downloaded various sources.
134
135 Using a private directory for downloaded add-on scenery and adding
136 that path to FG_SCENERY is the preferred way. This separates default
137 data from locally added data, and makes administration and later updates
138 easier.
139
140 HINT: if you want to see where FlightGear is searching and finding
141 terrain/objects, start it with the --log-level=info option.
142
143 2 terrasync -------------------------------------------------------------------
144
145 FlightGear can download scenery on-the-fly. Simply select "Download scenery
146 automatically" from the launcher, or use --enable-terrasync from the commandline.
147 By default this will add $HOME/.fgfs/TerraSync to the scenery path.
148
149 Note, however, that if it downloads scenery for the area around your
150 starting location, then you'll only see that after the next start, or
151 after you flew or teleported to a distant location and then back.
152
153 2.1 .dirindex -----------------------------------------------------------------
154
155 To save having to download scenery every time, while allowing updates to
156 propagate, terrasync checks for a .dirindex file each time it downloads a
157 directory from the server. This lists files, directories and tarballs that
158 should be present in the local directory, along with their size and a sha1sum
159 of their contents. This sha1sum is checked against the local files to
160 determine which files are to be downloaded.
161
162 The format of the .dirindex is as follows:
163
164 version:<version>
165 path:<scenery_path>
166 <type>:<filename>:<sha1sum>:<size>
167 <type>:<filename>:<sha1sum>:<size>
168 <type>:<filename>:<sha1sum>:<size>
169 .
170 .
171 .
172
173 Where:
174
175 <version> is the .dirindex version number
176 <scenery_path> is the path of the current file, e.g. Objects/w010n50/w009n57
177 <type> is the file type - "f" for file, "d" for directory, "t" for tarball
178 <filename> is the file name (e.g. 2811121.stg)
179 <sha1sum> is the sha1sum of the file named (e.g. 9da6ebc1695ed1c3b151cd34263e9c931ee309ea)
180 <size> is the size of the file
181
182 Tarballs (labelled with a "t" in the .dirindex) must be <name>.tgz files which
183 unpack into a <name>/ sub-directory. This enables terrasync to clean up
184 out of date files by simply deleting the <name>/ subdirectory before unpacking
185 the updated file.
186
187 See also https://sourceforge.net/p/flightgear/flightgear/ci/next/tree/scripts/python/TerraSync/tests/data/dirindex/
188
189 3 stg files -------------------------------------------------------------------
190
191 stg files ("static terragear") define the static elements of a scenery
192 "tile", including the terrain elevation data, airport geometry, and all
193 static objects placed on this tile. (See section 5 for how to find out which
194 geo coordinates belong to which tile.) Four of the available key words
195 are followed by a string and four numbers. The meaning of these numbers
196 is always the same and described in section 3.3.
197
198 3.1 OBJECT_BASE
199 ----------------
200
201 specifies the terrain elevation data file. These files are generated with
202 the TerraGear tools (http://wiki.flightgear.org/TerraGear) and have file
203 extension ".btg" ("binary terragear"; there used to be an "*.atg" file, too,
204 where the 'a' stood for ASCII).
205
206 Example:
207
208 OBJECT_BASE 942050.btg
209
210 The entry may be anywhere in the 942050.stg file, on a separate line.
211
212 3.2 OBJECT
213 -----------
214
215 specifies an airport geometry 'drop-in' file. The scenery elevation file
216 has cut out holes for airports, that are filled with such objects. They
217 are usually called after the airport ICAO id:
218
219 Example:
220
221 OBJECT KSFO.btg
222
223 These files are, again, created by TerraGear tools and are usually gzipped,
224 so you'll find that file stored as KSFO.btg.gz.
225
226
227
228
229 3.3 OBJECT_SHARED / OBJECT_SHARED_AGL
230 --------------------------------------
231
232 add static object to the tile.
233
234 Example:
235
236 OBJECT_SHARED Models/Airport/tower.xml -122.501090 37.514830 15.5 0.00 0.00 0.00 0.00
237
238 Syntax:
239
240 OBJECT_SHARED <object-path> <lon> <lat> <elev-m> <hdg-deg> <pitch-deg> <roll-deg> <radius>
241
242 The <object-path> is relative to the data directory (FG_ROOT).
243 <elev-m> is in meter and relative to mean sea-level (in the fgfs world).
244 <hdg-deg> is in degree, counter-clockwise with North being 0.0. Note
245 that this differs from about every other place in FlightGear, most notably
246 the /orientation/heading-deg entry in the property system, which is clockwise.
247 <pitch-deg> and <roll-deg> are in degree and optional.
248 <radius> is the (optional) radius of the model. This is added to the LOD range
249 to help ensure that very large meshes (typical from osm2city) are drawn at the
250 correct distance from the model edge. I can safely be ignored for any model
251 <1km in size.
252
253 OBJECT_SHARED models are cached and reused. They are only once in memory
254 and never freed. (See also the next section.)
255
256 OBJECT_SHARED_AGL places the object relative to the ground elevation. Note that
257 this is an expensive operation and is strongly discouraged.
258
259 3.4 OBJECT_STATIC / OBJECT_STATIC_AGL
260 --------------------------------------
261
262 add static objects to the tile, just like OBJECT_SHARED. There are three
263 differences to OBJECT_SHARED (apart from the name):
264
265 (A) the path is relative to the tile directory where the *.stg file with
266 this entry is located. For example, relative to 130n30/w123n37/. This
267 usually means that all 3D object files, textures, and XML animation
268 files are in this tile directory, too.
269
270 (B) these objects are *not* cached and kept loaded, but rather freed with
271 the tile (that is, when you leave that area).
272
273 (C) the animation XML files may contain Nasal blocks <nasal><load> and
274 <nasal><unload> which are executed on loading/unloading.
275
276 Example:
277
278 OBJECT_STATIC ggb-fb.xml -122.4760494 37.81876042 0 105 0.00 0.00
279
280
281 OBJECT_STATIC_AGL places the object relative to the ground elevation. Note that
282 this is an expensive operation and is strongly discouraged.
283
284
285 3.5 OBJECT_SIGN / OBJECT_SIGN_AGL
286 ---------------------------------
287
288 defines taxiway or runway sign. The syntax is much like that of OBJECT_SHARED
289 entries, except that the <object-path> is replaced with a sign contents specification
290 and that <radius> is replaced with a size value at the end of the line.
291
292 Example:
293
294 OBJECT_SIGN {@R}10L-28R{@L}C -122.35797457 37.61276290 -0.5398 74.0 2
295
296 The sign specification defines the sign contents. We try to resemble the
297 apt.dat 850 specifications in our implementation.
298 In the simplest form it contains just 'normal' text, for example:
299
300 EXIT
301
302 This will create a black panel of 1m height with "EXIT" written on it
303 in white versal letters. Actually, each of those characters are
304 single-letter glyph names that are looked up in the <glyph> map of a
305 texture font <material> entry in $FG_ROOT/materials.xml. It just
306 happens that the <glyph> entry for <name> 'E' maps to a drawn 'E' in
307 the font texture. This isn't true for all ASCII characters. Many aren't
308 mapped at all (and thus not available), others are mapped to non-standard
309 drawings. The '_', for example, is mapped to an empty black area and can
310 therefore be used as a space. (The sign specification must not contain
311 real spaces.) The '*' is mapped to a raised period.
312
313 Some glyph names consist of more than one character, and can't, thus, be
314 used directly. They have to be put in a pair of curly braces:
315
316 {^rd}
317
318 This creates an arrow that points to the right and down. Braces can really
319 contain a list of glyph names, separated by commas (no space!).
320 Single-letter glyph names can be used that way, too, or in any mixture
321 of both methods:
322
323 EXIT
324 {E,X,I,T}
325 {E}{X}{I}{T}
326 EX{I,T}
327 E{X,I}T{^lu,^rd}
328 {^u}EXIT{^u}
329
330
331 Multi-letter glyph names are usually used for symbols. Arrow symbol names
332 always start with a caret ("arrow head") and the left or right direction
333 always comes first (like the x in a Cartesian coordinate system). Here's
334 a list of some of the available names (see $FG_ROOT/materials.xml for
335 more):
336
337
338 ^l left arrow
339 ^r right arrow
340 ^u up arrow
341 ^d down arrow
342 ^lu left-up arrow
343 ^ld left-down arrow
344 ^ru right-up arrow
345 ^rd right-down arrow
346 no-entry "no entry" symbol
347 critical runway critical area
348 safety ils safety area
349 hazard end of taxiway
350
351
352
353 There are commands for pre-defined sign types according to the FAA
354 specification (5345-44; see http://www.google.com/search?q=5345-44g).
355
356 @Y "Direction, Destination, Boundary" sign (black on yellow)
357 @R "Mandatory Instruction" sign (white on red with black outline)
358 @L "Location" sign (yellow text and frame on black)
359 @B "Runway Distance Remaining" sign (white on black)
360
361
362 Examples:
363
364 {@R}10L-28R{@L}C
365 {@Y,^l}P|{^lu}N{@L}F{@Y}F{^ru}
366 {@Y,^ld}C ... same as any of {@Y}{@ld}C {@Y,@ld,C}
367 {@B}17
368
369
370 Syntax errors are reported in --log-level=debug, in the SG_TERRAIN
371 group. You can use this command line to filter out such messages:
372
373 $ fgfs --log-level=debug 2>&1|grep OBJECT_SIGN
374
375 OBJECT_SIGN_AGL places the sign relative to the ground elevation. Note that
376 this is an expensive operation and is strongly discouraged.
377
378 3.6 BUILDING_ROUGH / BUILDING_DETAILED
379 ---------------------------------------
380
381 defines building meshes, typically based on OSM data.
382
383 Example:
384
385 BUILDING_ROUGH buildings.ac -122.501090 37.514830 15.5 0.00 0.00 0.00 4000.0
386
387 Syntax:
388
389 BUILDING_ROUGH <object-path> <lon> <lat> <elev-m> <hdg-deg> <pitch-deg> <roll-deg> <radius-m>
390
391 Note that only bare .ac files should be referenced. The material definition for
392 "OSM_Building" will be used to determine the texture and Effects.
393
394 BUILDING_ROUGH uses the "rough" LOD range, while BUILDING_DETAILED uses the
395 "detailed" LOD range. Some randomness is applied so that building meshes
396 gradually fade in
397
398 3.7 ROAD_ROUGH / ROAD_DETAILED
399 -------------------------------
400
401 Identical to BUILDING_ROUGH / BUILDING_DETAILED above, except used for roads.
402 the material definition "OSM_Road" is applied.
403
404 3.8 RAILWAY_ROUGH / RAILWAY_DETAILED
405 -------------------------------
406
407 Identical to BUILDING_ROUGH / BIULDING_DETAILED above, except used for roads.
408 the material definition "OSM_Railway" is applied.
409
410 3.9 BUILDING_LIST
411 ------------------
412
413 Defines a file containing building coordinates that should be rendered using
414 the building shader (aka Random Buildings).
415
416 Example:
417
418 BUILDING_LIST buildings.txt OSM_Building -2.72943543 56.00080606 36.1
419
420 Syntax
421
422 BUILDING_LIST <filename> <material name> <lon> <lat> <elev>
423
424 Where:
425 - <filename> is the name of a file containing building positions. May be a .txt or
426 a gzipped .txt.gz file. If FlightGear is unable to open <filename> it will
427 automatically try to open <filename>.gz.
428 - <material name> is the name of the material that will be referenced to find
429 random building parameters.
430 - <lat>, <lon>, <elev> defines the center of the set of buildings, and also
431 the point at which the material definition will be evaluated (for regional
432 materials).
433
434 See README.materials for details on configuring the random building parameters.
435
436 The referenced <filename> (in the example buildings.txt) contains lines of the form
437
438 X Y Z R B W D H P S O F WT RT
439
440 Where:
441 - X,Y,Z are the cartesian coordinates of the center of the front face. +X is South, +Y is East
442 - R is the building rotation in degrees centered on the middle of the front face.
443 - B is the building type [0, 1, 2] for SMALL, MEDIUM, LARGE
444 - W is the building width in meters
445 - D is the building depth in meters
446 - H is the building height in meters, excluding any pitched roof
447 - P is the pitch height in meters. 0 for a flat roof
448 - S is the roof shape (only 0, 2, 4, 6 are implemented, others are approximated to those) :
449 0=flat 1=skillion 2=gabled 3=half-hipped 4=hipped 5=pyramidal 6=gambrel
450 7=mansard 8=dome 9=onion 10=round 11=saltbox
451 - O is the roof ridge orientation :
452 0 = parallel to the front face of the building
453 1 = orthogonal to the front face of the building
454 - F is the number of floors (integer)
455 - WT is the texture index to use for walls (integer). Buildings with the same WT value will have the same wall texture assigned. There are 6 small, 6 medium and 4 large textures.
456 - RT is the texture index to use for roofs (integer). Buildings with the same RT value will have the same roof texture assigned. There are 6 small, 6 medium and 4 large textures.
457
458 <x> <y> <z> <rot> <type>
459
460 where :
461 - (<x>,<y>,<z>) define the bottom left corner of the building in cartesian space (+X is South, +Y is East, +Z is up), with (0,0,0) being the position referenced above
462 - <rot> is the clockwise rotation around the Z-axis in degrees, rotating around the bottom left (SW) corner of the building
463 - <type> is {0,1,2} which map to small, medium and large buildings respectively, as per random buildings.
464
465 For example, the following entries generates 3 small, 2 medium and 2 large buildings in an easterly line:
466
467 0 0 0 0 0
468 0 100 0 0 0
469 0 200 0 0 0
470 0 300 0 0 1
471 0 400 0 0 1
472 0 500 0 0 2
473
474 3.10 TREE_LIST
475 ------------------
476
477 Defines a file containing tree coordinates that should be rendered using
478 the tree shader (aka Random vegetation).
479
480 Example:
481
482 TREE_LIST trees.txt DeciduousBroadCover -3.36074090 55.95297494 30.3822
483
484 Syntax
485
486 TREE_LIST <filename> <material name> <lon> <lat> <elev>
487
488 Where:
489 - <filename> is the name of a file containing tree positions. May be a .txt or
490 a gzipped .txt.gz file. If FlightGear is unable to open <filename> it will
491 automatically try to open <filename>.gz.
492 - <material name> is the name of the material that will be referenced to find
493 random vegetation parameters such as size, texture.
494 - <lat>, <lon>, <elev> defines the center of the set of trees, and also
495 the point at which the material definition will be evaluated (for regional
496 materials).
497
498 See README.materials for details on configuring the random vegetation parameters.
499
500 The referenced <filename> (in the example trees.txt) contains lines of the form
501
502 X Y Z A B C
503
504 Where:
505 - X,Y,Z are the cartesian coordinates of the tree. +X is South, +Y is East
506 - A,B,C is optional and represents the normal of the underlying terrain. Used for shadows. Defaults to (0,0,1)
507
508 3.11 LINE_FEATURE_LIST
509 -------------------------
510
511 Defines a file containing a set of linear feature that should be rendered using a
512 particular Material. E.g. Road, Waterways
513
514 Example:
515
516 LINE_FEATURE_LIST roads.txt Road
517
518 Syntax
519
520 LINE_FEATURE_LIST <filename> <material name>
521
522 Where:
523 - <filename> is the name of a file containing linear feature positions. May be a .txt or
524 a gzipped .txt.gz file. If FlightGear is unable to open <filename> it will
525 automatically try to open <filename>.gz.
526 - <material name> is the name of the material that will be used to render the feature.
527 This can use an Effect as normal, e.g. for road traffic.
528
529 See README.materials for details on configuring the linear feature parameters.
530
531 The referenced <filename> (in the example road.txt) contains lines of the form
532
533 W ATTR A B C D lon0 lat0 lon1 lat1 lon2 lat2 lon3 lat4
534
535 Where:
536
537 - W is the feature width in meters.
538 - ATTR is an integer value used to store packed attributes (e.g. bitwise. Bit 1 is for lit)
539 - A,B,C,D are float values used to store attributes (currently unused)
540 - lonN, latN are lon/lat pairs on the center of the line feature. There must be at least two pairs.
541
542 The linear feature will be built on top of the terrain, offset by the line-feature-offset-m parameter
543 of the material definition.
544
545 3.12 OBJECT_LIGHT
546 ------------------
547
548 Add a light to the tile.
549
550 Example:
551
552 OBJECT_LIGHT sample-light -129.00074514 -9.00490134 5 10.0 100.0 0 1.0 1.0 1.0 1.0 0.0 0.0 0.0 360.0 360.0 -1 1.0 1.0 0.0
553
554 Syntax:
555
556 OBJECT_LIGHT <light-name> <lon> <lat> <elev-m> <size-cm> <intensity-cd> <on-period> <color-r> <color-g> <color-b> <color-a> <normal-x> <normal-y> <normal-z> <horizontal-angle> <vertical-angle> <animation-param-1> <animation-param-2> <animation-param-3> <animation-param-4>
557
558 Where:
559 - <light-name> is a name for the light. Multiple lights may have the same name.
560 - <lon> and <lat> are positions in longitude and latitude of the light.
561 - <elev-m> is in meter and relative to mean sea-level (in the fgfs world).
562 - <size-cm> is the size in centimeters of the light.
563 - <intensity-cd> is the intensity of the light in candelas.
564 - <on-period> defines what part of the day the light is turned on at:
565 0 means the light will be on all the time
566 1 means the light will turn on at sunset (sun angle ~89 degrees)
567 2 means the light will turn on around sunset with some variability
568 3 means the light will turn on at sunset or when visibility is less than 5000 nautical miles
569 - <color-r>, <color-g>, <color-b> and <color-a> define the color of the light. Values range from 0.0 to 1.0.
570 - <normal-x>, <normal-y>, <normal-z>, <horizontal-angle> and <vertical-angle> define the directionality of the light:
571 If both <horizonal/vertical-angle> are 360, the light is considered omnidirectional and the normals have no effect.
572 If not, <normal-x> points to south, <normal-y> points to east and <normal-z> points up.
573 - <animation-param-1>, <animation-param-2>, <animation-param-3> and <animation-param-4> define animations:
574 If <animation-param-1> is less than 0, light is not animated.
575 If <animation-param-1> is greater than 0, then its value is used as the total time interval of a single loop of the animation
576 <animation-param-2> defines the portion of the loop the light is working (its switched off completely for the remaining portion)
577 <animation-param-3> defines the strobe rate of the light w.r.t. to the full loop interval (i.e. <animation-param-1>).
578 A value less than equal to zero turns off strobing completely.
579 <animation-param-4> defines the offset (so two lights with the same animation can start at different real-world times)
580
581 Examples:
582 - On for half a second, off for half a second
583 1.0 0.5 0.0 0.0
584 - Alternatively,
585 1.0 1.0 1.0 0.0
586 - On for half a second, off for half a second, offset by 0.2 seconds
587 1.0 0.5 0.0 0.2
588 - Blink twice for half a second, and then remain off for half a second
589 1.0 0.5 4.0 0.0
590
591 *Notes for Normal vector computation:*
592 A good way to think about the normal vector comptuation is to use spherical coordinates: http://motionscript.com/mastering-expressions/img/spherical-coords.gif.
593
594 In this case, the -X is north (i.e. 0 degrees on the compass rose), +Y is east (90 degrees), and Z is the vertical axis. And the compass rose sits flush on the XY plane. What you want to do is get the vector that is at the center of your light. In the case of the following light:
595
596 - visible 30 degree below horizon up to 45 degrees over the horizon
597 - visible from 70 degrees to 110 degrees on a compas
598
599 the normal would be the line from the light to 7.5 degrees from the horizon vertically (center of 45 and -30) and 90 degrees on the compass rose (center of 70 and 110). Using the equations, we get:
600
601 normal-x = 0.0
602 normal-y = 0.99144
603 normal-z = 0.13053
604 horizontal-angle = 40 degrees (110-70)
605 vertical-angle = 75 degrees (45 - (-30))
606
607 To make things easier, here is a python snippet that does all that computation and prints out the 5 numbers relating to the normal and angles:
608
609 ###################################################################
610 import math
611 def get_definition(min_h, max_h, min_v, max_v):
612 h = min_h + (max_h - min_h)/2
613 v = -90 + min_v + (max_v - min_v)/2
614
615 r = 1 # Unit length vector
616
617 x = -1 * round(r * math.sin(math.radians(v)) * math.cos(math.radians(h)), 5)
618 y = -1 * round(r * math.sin(math.radians(v)) * math.sin(math.radians(h)), 5)
619 z = round(r * math.cos(math.radians(v)), 5)
620 print(x, y, z, max_h - min_h, max_v - min_v)
621 ###################################################################
622
623 3.13 LIGHT_LIST
624 ----------------
625 Defines a file containing multiple light coordinates and properties.
626
627 Example:
628
629 LIGHT_LIST light_list.txt -129.00074514 -9.00490134 5
630
631 Syntax
632
633 LIGHT_LIST <filename> <lon> <lat> <elev>
634
635 Where:
636 - <filename> is the name of a file containing building positions. May be a .txt or
637 a gzipped .txt.gz file. If FlightGear is unable to open <filename> it will
638 automatically try to open <filename>.gz.
639 - <lat>, <lon>, <elev> defines the center of the set of lights
640
641 The referenced <filename> (in the example light_list.txt) contains lines defining lights of various types
642
643 - "omnidirectional":
644 X Y Z <size-cm> <intensity-cd> <on-period> <color-r> <color-g> <color-b> <color-a>
645 - "omnidirectional-animated":
646 X Y Z <size-cm> <intensity-cd> <on-period> <color-r> <color-g> <color-b> <color-a> <animation-param-1> <animation-param-2> <animation-param-3> <animation-param-4>
647 - "directional":
648 X Y Z <size-cm> <intensity-cd> <on-period> <color-r> <color-g> <color-b> <color-a> <normal-x> <normal-y> <normal-z> <horizontal-angle> <vertical-angle>
649 - "directional-animated":
650 X Y Z <size-cm> <intensity-cd> <on-period> <color-r> <color-g> <color-b> <color-a> <normal-x> <normal-y> <normal-z> <horizontal-angle> <vertical-angle> <animation-param-1> <animation-param-2> <animation-param-3> <animation-param-4>
651
652 The type of the light is automatically detected based on the number of parameters specified for each light.
653
654 Where:
655 - X,Y,Z are the cartesian coordinates of the light. +X is South and +Y is East.
656 - The rest of the parameters are the same as OBJECT_LIGHT (Section 3.12)
657
658 3.14 OBJECT_INSTANCED
659 ---------------------
660 Defines a model and properties to place multiple instances of the object
661
662 Example:
663
664 OBJECT_INSTANCED Models/Commercial/tower-glass-dark-blue.ac instances.txt default -129.00115321 -8.98951092 0
665
666 Syntax:
667
668 OBJECT_INSTANCED <object-path> <filename> <effect-path> <lon> <lat> <elev-m>
669
670 Where:
671 - <object-path> is the path to an object relative to the data directory (same as OBJECT_SHARED). Models used should be raw models (e.g. *.ac) and not *.xml's, and should contain as few objects as possible (recommendation is single object per model), using a texture atlas for representing different semantic parts in the model instead of splitting them into various objects.
672 - <filename> is the name of a file containing instance positions and other properties. May be a .txt or a gzipped .txt.gz file. If FlightGear is unable to open <filename> it will automatically try to open <filename>.gz.
673 - <effect-path> is the name of the effect that will be applied. See below for currently available options.
674 - <lon>, <lat>, <elev-m> defines the position relative to which all the instances will be placed (similar to BUILDING_LIST)
675
676 The referenced <filename> (in the example instances.txt) contains lines defining one instance per line:
677
678 <X> <Y> <Z> <hdg> <pitch> <roll> <scale>
679
680 Where:
681 - X, Y, Z are the cartsian coordiates of the instance, +X is South and +Y is East.
682 - (optional) hdg, pitch and roll define the rotation of the instance, matching OBJECT_SHARED exactly
683 - (optional) scale is a multiplier for the scale of the instance, with a value of 1 indicate no scaling
684
685 Each line will therefore contain 3 (position only), 6 (position+rotation), 4 (position+scale) or 7 (all properties) parameters. In the case of both rotation and scaling, the scaling is applied before rotation.
686
687 If the effect being used supports custom attributes, the line *must contain* 4 additional custom parameters:
688
689 <X> <Y> <Z> <hdg> <pitch> <roll> <scale> <custom-attrib-1> <custom-attrib-2> <custom-attrib-3> <custom-attrib-4>
690
691 Again, the intermediate rotation and scaling parameters are optional and can be skipped if the instance does not require any rotation/scaling, leading to 7 (position+custom), 10 (position+rotation+custom), 8 (position+scale+custom) or 11 (all properties) parameters.
692
693 The function of custom attributes will differ from effect to effect, see below.
694
695 ### Instancing Effects
696 There are two types of effects supported by the instancing framework:
697
698 - Effects with default parameters
699 - "default": The default instancing effect described above which does basic instance position, rotation and scaling
700 - "Effects/object-instancing": Same as "default"
701 - Effects with additional custom parameters
702 - "Effects/object-instancing-colored": Requires four additional custom attributes, which are the colors <red> <green> <blue> <factor> respectively. The instance's color/texture will be blended with the (r,g,b) values provided based on the given factor. A factor of 0 implies keeping the original color, while a factor of 1 replaces the original color with the provided (r,g,b) completely.
703
704 Note: Implementing new effects with additional custom parameters requires a small source-side change in ObjectInstanceBin.hxx
705
706 4 model manager ("/models/model") --------------------------------------------
707
708
709 4.1 static objects
710 -------------------
711
712 Another way to add objects to the scenery is via the "model manager".
713 It reads all /models/model entries at startup and places these objects
714 in the scenery. Just load a definition like the following into the
715 property tree, for example by putting it into $FG_ROOT/preferences.xml, or
716 better: an XML file that you load with e.g. --config=$HOME/.fgfs/stuff.xml:
717
718 <models>
719 <model n="0">
720 <name>pony</name>
721 <path>Local/pony.ac</path>
722 <longitude-deg>-115.8352869</longitude-deg>
723 <latitude-deg>37.24302849</latitude-deg>
724 <elevation-ft>4534.691321</elevation-ft>
725 <heading-deg>0</heading-deg>
726 <pitch-deg>0</pitch-deg>
727 <roll-deg>0</roll-deg>
728 </model>
729 </models>
730
731 The <path> is relative to $FG_ROOT, the <name> is optional. One can leave the
732 heading/pitch/roll entries away, in which case they are set to zero. The values
733 are fixed and unchangeable at runtime.
734
735
736
737
738 4.2 dynamic objects
739 --------------------
740
741 Any of the model properties can be made changeable at runtime by appending
742 "-prop" and using a property path name instead of the fixed value:
743
744 <local>
745 <pony>
746 <longitude-deg>-115.8352869/<longitude-deg>
747 <latitude-deg>37.24302849</latitude-deg>
748 <elevation-ft>4534.691321</elevation-ft>
749 <heading-deg>0</heading-deg>
750 </pony>
751 </local>
752
753 <models>
754 <model n="1">
755 <name>pony</name>
756 <path>Local/pony.ac</path>
757 <longitude-deg-prop>/local/pony/longitude-deg</longitude-deg-prop>
758 <latitude-deg-prop>/local/pony/latitude-deg</latitude-deg-prop>
759 <elevation-ft-prop>/local/pony/elevation-ft</elevation-ft-prop>
760 <heading-deg-prop>/local/pony/heading-deg</heading-deg-prop>
761 <pitch-deg>1.234</pitch-deg> <!-- static, just for fun -->
762 </model>
763 </models>
764
765 Then one can move the pony around by changing the values in /local/pony/ in
766 the property system. One can, of course, use other animals, too.
767
768
769
770
771 4.3 loading/unloading at runtime
772 --------------------------------
773
774 Both dynamic and static model-manager-models can be loaded and unloaded
775 at runtime. For loading you first create a new <model> entry under <models>,
776 initialize all properties there (<longitude-deg> or <longitude-deg-prop>,
777 etc.), and finally you create a child <load> of any type in this group.
778 This is the signal for the model manager to load the object. You can
779 remove the <load> property after that. It has no further meaning.
780
781 To remove a model-manager model at runtime, you simply delete the whole
782 <model> group.
783
784
785
786
787
788 5 tools for object placing ----------------------------------------------------
789
790
791 5.1 calc-tile.pl
792 ----------------
793
794 For finding out the tile number for a given geo coordinate pair there's
795 a script "scripts/perl/scenery/calc-tile.pl" in the FlightGear sources.
796 You feed longitude and latitude to it and it returns the path to the
797 *.stg file where you have to add the object entry.
798
799 $ perl calc-tile.pl 16.1234 48.5678
800 Longitude: 16.1234
801 Latitude: 48.5678
802 Tile: 3220128
803 Path: "e010n40/e016n48/3220128.stg"
804
805
806
807
808 5.2 ufo scenery object editor
809 -----------------------------
810
811 The ufo has a scenery object editor built-in. It uses the model manager
812 described in section 4. To place objects with it, start fgfs, optionally
813 with specifying an initial model type ("cursor") and a list of subdirectories
814 of $FG_ROOT where the ufo should search for available 3D models ("source"):
815
816 $ fgfs --aircraft=ufo --prop:cursor=Models/Airport/radar.xml \
817 --prop:source=Models,Scenery/Objects
818
819 Then click anywhere on the terrain to add a model (left mouse button).
820 You can open the adjustment dialog (Tab-key) to make adjustments to
821 position and orientation. Click as often as you like, choose further
822 models from the space-key dialog. You can select an already placed object
823 by Ctrl-clicking at its base (not at the object itself, but the surface
824 point where it's located!). By also holding the Shift key down, you
825 can select several objects or add them to a selection. You can remove
826 the selected object(s) with the Backspace-key. (See the ?-key dialog
827 for futher available keys.) After clicking on the input field right
828 over the status line (invisible if there's no text in it) you can enter
829 a comment/legend for the selected object.
830
831 And finally, you dump the object data to the terminal (d-key) or export
832 them to a file $HOME/.fgfs/ufo-model-export.xml (Unix) or
833 %APPDATA%\flightgear.org\ufo-model-export.xml (MS Windows).
834
835 You can now put the generated object entries into the specified *.stg
836 file to make them permanent. Or load the whole exported *.xml file
837 via --config option:
838
839 $ fgfs --config=$HOME/.fgfs/ufo-model-export.xml
840
841 If you choose the sign placeholder object from the m-key dialog (first
842 entry; "Aircraft/ufo/Models/sign.ac"), then an OBJEC_SIGN *.stg line
843 will be generated with the legend used as sign contents. If you didn't
844 insert any legend, then the sign text will be: NO CONTENTS and a 4 digits
845 random number for later identification in the *.stg file.
846
847 Unfortunately, objects added with this method are kept in memory, no
848 matter where you are actually flying, so the *.stg method is preferable.
849
850
851
852
853
854 6 embedded Nasal in XML files (static objects and AI) -------------------------
855
856
857 6.1 static models
858 -----------------
859
860 Objects loaded via OBJECT_STATIC in *.stg files as well as AI models loaded
861 via scenarios may contain embedded Nasal code. This can be used to drive
862 more advanced animations. An example is a lighthouse with specific light
863 signals, or hangar doors that open when the "player"'s aircraft is nearby.
864 The Nasal code is added to the object's XML wrapper/animation file, anywhere
865 on the top level, for example:
866
867
868 <PropertyList>
869 <path>lighthouse.ac</path>
870
871 <nasal>
872 <load>
873 var loop_id = 0;
874 var light = aircraft.light.new("
875 "/models/static/w120n30/w118n35/lighthouse/light",
876 [2, 1, 2, 1, 2, 1, 2, 5]);
877
878 var loop = func(id) {
879 id == loop_id or return;
880 light.switch(getprop("/sim/time/sun-angle-rad") > 1.37);
881 settimer(func { loop(id) }, 30);
882 }
883 loop(loop_id += 1);
884 </load>
885
886 <unload>loop_id += 1</unload>
887 </nasal>
888
889 <animation>
890 <type>select</type>
891 <object-name>light-halo</object-name>
892 <property>/models/static/w120n30/w118n35/lighthouse/light/state</property>
893 </animation>
894
895 ...
896 </PropertyList>
897
898
899 The <load> part is executed when the scenery tile on which the model is placed
900 is loaded into memory. It can start timers or listeners that modify properties,
901 which are then queried by the <animation>. As a convention developers are requested
902 to use "/models/static/" + <tile-path> + <file-basename>. So, in the above example
903 file "$FG_ROOT/Scenery/Objects/w120n30/w118n35/lighthouse.xml" all properties
904 are stored under "/models/static/w120n30/w118n35/lighthouse/". That way collisions
905 with other models are quite unlikely.
906
907 An optional <unload> part is executed when the tile and model is removed from
908 memory. Note that this is only when the "player" is already far away! To
909 cause minimal impact on the framerate it is recommended to do as few
910 calculations as possible, to use as large timer intervals as possible, and to
911 stop all timers and listeners in the <unload> part, as shown in the example.
912
913 All Nasal variables/functions are in a separate namespace, which is named
914 after the file name. It's recommended not to access this namespace from
915 outside for other than development purposes.
916
917 What the above code does: as soon as the model is loaded, an aircraft.light
918 is created with a specific light sequence. Then, in half-minute intervals,
919 the light is turned on or off depending on the sun angle. On <unload> the
920 loop identifier is increased, which makes the loop terminate itself. For
921 more info about this technique, see the Nasal wiki.
922
923
924
925
926 6.2 AI models
927 -------------
928
929 Here the syntax is the same like for static models. The only two differences
930 are:
931
932 - these models are currently only removed at program end, so it's more
933 important to consider effects on performance.
934
935 - AI models don't need to store their properties in /models/static/...,
936 but get a separate node under /ai/models/, for example /ai/models/carrier[1].
937 The embedded Nasal code can access this dynamically assigned property
938 via cmdarg() function, which returns a props.Node hash. Example:
939
940 <nasal>
941 <load>print("my data are under ", cmdarg().getPath())</load>
942 <unload>print("Currently I'm only called at fgfs exit!")</unload>
943 </nasal>