├── .gitignore
├── version.mak
├── src
├── .gitignore
├── .lldbinit
├── bbox.h
├── planes.h
├── Makefile.mac
├── Makefile.win
├── Makefile.lin
├── drawdebug.c
├── planes.c
├── groundtraffic.h
├── draw.c
└── routes.c
├── GroundTraffic
├── .gitignore
└── ReadMe.txt
├── Makefile
├── README.md
├── LICENSE.md
├── lgpl-2.1.txt
└── ReadMe.html
/.gitignore:
--------------------------------------------------------------------------------
1 | *.bak
2 | *.zip
3 |
4 | .DS_Store
5 | Thumbs.db
6 |
--------------------------------------------------------------------------------
/version.mak:
--------------------------------------------------------------------------------
1 | PROJECT=GroundTraffic
2 | VER=152
3 | VERSION=1.52
4 |
--------------------------------------------------------------------------------
/src/.gitignore:
--------------------------------------------------------------------------------
1 | *.bak
2 | *.d
3 | *.o
4 | *.dep
5 | *.obj
6 | *.pdb
7 | *.xpl
8 |
--------------------------------------------------------------------------------
/GroundTraffic/.gitignore:
--------------------------------------------------------------------------------
1 | # Placeholder to create directory for output
2 | *.xpl
3 | *.exp
4 | *.ilk
5 | *.lib
6 | *.idb
7 | *.pdb
8 |
--------------------------------------------------------------------------------
/src/.lldbinit:
--------------------------------------------------------------------------------
1 | target create "~/Desktop/X-Plane 10/X-Plane.app/Contents/MacOS/X-Plane"
2 | settings set target.run-args -- --no_crash_reporter
3 |
--------------------------------------------------------------------------------
/GroundTraffic/ReadMe.txt:
--------------------------------------------------------------------------------
1 | GroundTraffic plugin
2 | ====================
3 |
4 | [↯] No user serviceable parts inside [!]
5 |
6 | Version 1.52
7 | Copyright Jonathan Harris 2013-2016
8 | http://marginal.org.uk/x-planescenery/
9 | Licensed under the GNU Library General Public License v2.1.
10 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | include version.mak
2 |
3 | TARGET=$(PROJECT)_$(VER).zip
4 |
5 | FILES=ReadMe.html $(PROJECT)/ReadMe.txt $(PROJECT)/lin.xpl $(PROJECT)/mac.xpl $(PROJECT)/win.xpl $(PROJECT)/64/lin.xpl $(PROJECT)/64/win.xpl
6 |
7 | all: $(TARGET)
8 |
9 | clean:
10 | rm $(TARGET)
11 |
12 | $(TARGET): $(FILES)
13 | touch $^
14 | chmod +x $(PROJECT)/*.xpl $(PROJECT)/64/*.xpl
15 | rm -f $(TARGET)
16 | zip -MM -o $(TARGET) $+
17 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | GroundTraffic kit for X-Plane®
2 | ====
3 |
4 | This kit allows [X-Plane](x-plane.com) scenery designers to add animated ground vehicle traffic to airport scenery packages.
5 |
6 | The repo contains assets intended for scenery designers, plus the source code to the X-Plane plugin that performs the animations. Scenery designer oriented documention is contained in the file [ReadMe.html](http://htmlpreview.github.io/?https://raw.githubusercontent.com/Marginal/GroundTraffic/master/ReadMe.html).
7 |
8 | Building the plugin
9 | ----
10 | The plugin is built from the `src` directory.
11 |
12 | Mac 32 & 64 bit fat binary:
13 |
14 | make -f Makefile.mac
15 |
16 | Linux 32 & 64 bit binaries:
17 |
18 | make -f Makefile.lin
19 |
20 | Windows 32 or 64 bit binary:
21 |
22 | vcvarsall [target]
23 | nmake -f Makefile.win
24 |
25 |
--------------------------------------------------------------------------------
/src/bbox.h:
--------------------------------------------------------------------------------
1 | /*
2 | * GroundTraffic
3 | *
4 | * (c) Jonathan Harris 2013
5 | *
6 | * Licensed under GNU LGPL v2.1.
7 | */
8 |
9 | #ifndef _BBOX_H_
10 | #define _BBOX_H_
11 |
12 | typedef struct
13 | {
14 | float minlat, maxlat, minlon, maxlon;
15 | } bbox_t;
16 |
17 | static inline void bbox_init(bbox_t *bbox)
18 | {
19 | bbox->minlat = 90;
20 | bbox->maxlat = -90;
21 | bbox->minlon = 180;
22 | bbox->maxlon = -180;
23 | }
24 |
25 | static inline void bbox_add(bbox_t *bbox, float lat, float lon)
26 | {
27 | if (lat < bbox->minlat) bbox->minlat = lat;
28 | if (lat > bbox->maxlat) bbox->maxlat = lat;
29 | if (lon < bbox->minlon) bbox->minlon = lon;
30 | if (lon > bbox->maxlon) bbox->maxlon = lon;
31 | }
32 |
33 | static inline int bbox_intersect(bbox_t *a, bbox_t *b)
34 | {
35 | return ((a->minlat <= b->maxlat) && (a->maxlat > b->minlat) &&
36 | (a->minlon <= b->maxlon) && (a->maxlon > b->minlon));
37 | }
38 |
39 | #endif /* _BBOX_H_ */
40 |
--------------------------------------------------------------------------------
/src/planes.h:
--------------------------------------------------------------------------------
1 | /*
2 | * GroundTraffic
3 | *
4 | * (c) Jonathan Harris 2013
5 | *
6 | * Licensed under GNU LGPL v2.1.
7 | */
8 |
9 | #ifdef _MSC_VER
10 | typedef __int32 int32_t;
11 | #else
12 | # include
13 | #endif
14 |
15 | #include "groundtraffic.h"
16 |
17 | #define MAX_PLANES 20 /* Seems to be a hard-coded limit in X-Plane, but maybe could increase in future */
18 | #define MAX_ACF_NAME 256
19 | #define MAX_ACF_PATH 512
20 |
21 | typedef struct
22 | {
23 | XPLMDataRef x, y, z, vx, vz, hdg, gear;
24 | } plane_ref_t;
25 |
26 | typedef struct
27 | {
28 | point_t p, v; /* Position [m], speed [m/s] */
29 | float hdg; /* [degrees] */
30 | } plane_pos_t;
31 |
32 | typedef struct
33 | {
34 | char name[MAX_ACF_NAME];
35 | float length, semiwidth, refheight, cgz; /* dimensions [m] */
36 | } plane_acf_t;
37 |
38 |
39 | /* prototypes */
40 | int setup_plane_refs();
41 | void reset_planes();
42 | int count_planes();
43 | plane_acf_t *get_plane_info(int planeno);
44 | int get_plane_pos(plane_pos_t *pos, int planeno);
45 | point_t *get_plane_footprint(int planeno, float time);
46 |
--------------------------------------------------------------------------------
/src/Makefile.mac:
--------------------------------------------------------------------------------
1 | # -*-Makefile-*-
2 |
3 | include ../version.mak
4 |
5 | XPSDK=../../XPSDK213
6 |
7 | CC=cc
8 | #BUILD=-g -DDEBUG
9 | #LDFLAGS=-bundle
10 | BUILD=-O3 -DNDEBUG
11 | LDFLAGS=-bundle -Wl,-x
12 | DEFINES=-DAPL=1 -DIBM=0 -DLIN=0 -DVERSION=$(VERSION)
13 | INC=-F$(XPSDK)/Libraries/Mac -I$(XPSDK)/CHeaders/XPLM
14 | CFLAGS=-arch i386 -arch x86_64 -march=core2 -ffast-math -pipe -Wall -Winline -Wno-missing-braces -fvisibility=hidden -mmacosx-version-min=10.6 $(BUILD) $(DEFINES) $(INC)
15 |
16 | VPATH=
17 | SRC=groundtraffic.c draw.c routes.c planes.c drawdebug.c
18 | LIBS=-framework XPLM -framework OpenGL
19 | TARGETDIR=../$(PROJECT)
20 | INSTALLDIR=~/Desktop/X-Plane\ 10/Custom\ Scenery/KSEA\ Demo\ GroundTraffic/plugins/$(PROJECT)
21 |
22 | ############################################################################
23 |
24 | BUILDDIR=$(shell uname)
25 | OBJS=$(addprefix $(BUILDDIR)/, $(addsuffix .o, $(basename $(notdir $(SRC)))))
26 | TARGET=$(TARGETDIR)/mac.xpl
27 |
28 | RM=rm -f
29 | CP=cp -p
30 | MD=mkdir -p
31 |
32 | .PHONY: all clean install
33 |
34 | all: $(TARGET)
35 |
36 | install: $(TARGET) | $(INSTALLDIR)
37 | $(CP) $(TARGET) $(INSTALLDIR)/
38 |
39 | $(TARGET): $(OBJS) | $(TARGETDIR)
40 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS)
41 |
42 | $(OBJS): | $(BUILDDIR)
43 |
44 | $(BUILDDIR):
45 | $(MD) $(BUILDDIR)
46 |
47 | $(BUILDDIR)/%.o: %.c
48 | $(CC) $(CFLAGS) -c -o $@ $<
49 | @$(CC) $(BUILD) $(DEFINES) $(INC) -MM $< | sed -e 's|$*.o|$@|' > $(@:.o=.d)
50 |
51 | $(TARGETDIR):
52 | $(MD) $(TARGETDIR)
53 |
54 | $(INSTALLDIR):
55 | $(MD) $(INSTALLDIR)
56 |
57 | clean:
58 | $(RM) *~ *.bak $(OBJS) $(OBJS:.o=.d) $(TARGET)
59 |
60 | # pull in dependency info
61 | -include $(OBJS:.o=.d)
62 |
--------------------------------------------------------------------------------
/src/Makefile.win:
--------------------------------------------------------------------------------
1 | # -*-Makefile-*- in NMAKE format
2 |
3 | !include ..\version.mak
4 |
5 | XPSDK=..\..\XPSDK213
6 |
7 | CC=cl
8 | #BUILD=-Zi -DDEBUG
9 | BUILD=-O2 -DNDEBUG
10 | DEFINES=-DIBM=1 -DAPL=0 -DLIN=0 -DVERSION=$(VERSION)
11 | INC=-I$(XPSDK)\CHeaders\XPLM -I$(XPSDK)/CHeaders/Widgets
12 | CFLAGS=-nologo -fp:fast $(BUILD) $(DEFINES) $(INC)
13 | LDFLAGS=-LD
14 |
15 | SRC=.\groundtraffic.c .\draw.c .\routes.c .\planes.c .\drawdebug.c
16 | LIBS=$(XPSDK)\Libraries\Win\XPLM$(ARCHXP).lib $(XPSDK)\Libraries\Win\XPWidgets$(ARCHXP).lib GlU32.Lib OpenGL32.Lib
17 | TARGETDIR=..\$(PROJECT)
18 | INSTALLDIR=X:\Desktop\X-Plane 10\Custom Scenery\KSEA Demo GroundTraffic\plugins\$(PROJECT)
19 |
20 | ############################################################################
21 |
22 | OBJS=$(SRC:.c=.obj)
23 | # Work out which target we're set up for by looking for a program (ml64.exe) that only exists in the path for one target
24 | !if [ml64 >nul 2>&1] == 0
25 | CPU=x64
26 | ARCHDIR=64
27 | ARCHXP=_64
28 | BUILDDIR=Win64
29 | OBJS=$(OBJS:.\=Win64\)
30 | !else
31 | CFLAGS=$(CFLAGS) -arch:SSE2
32 | CPU=x86
33 | ARCHDIR=
34 | ARCHXP=
35 | BUILDDIR=Win32
36 | OBJS=$(OBJS:.\=Win32\)
37 | !endif
38 | TARGET=$(TARGETDIR)\$(ARCHDIR)\win.xpl
39 |
40 | RM=del /q
41 | CP=copy /y
42 | MD=mkdir
43 |
44 | all: $(TARGET)
45 |
46 | install: $(TARGET)
47 | -@if not exist "$(INSTALLDIR)\$(ARCHDIR)" $(MD) "$(INSTALLDIR)\$(ARCHDIR)"
48 | $(CP) $(TARGET) "$(INSTALLDIR)\$(ARCHDIR)"
49 |
50 | $(TARGET): $(OBJS)
51 | -@if not exist "$(TARGETDIR)\$(ARCHDIR)" $(MD) "$(TARGETDIR)\$(ARCHDIR)"
52 | $(CC) $(CFLAGS) $(LDFLAGS) -Fe$@ $(OBJS) $(LIBS)
53 |
54 | .c{$(BUILDDIR)}.obj:
55 | $(CC) $(CFLAGS) -c -Fo$@ -Fd$* $<
56 | @echo $@: $< \> $*.dep
57 | @for /f "usebackq tokens=4*" %i in (`"$(CC) $(CFLAGS) /Zs /Z7 /w /showIncludes $< 2>nul: | findstr Note:"`) do @echo. "%i %j" \>> $*.dep
58 | @echo.>> $*.dep
59 |
60 | clean:
61 | -$(RM) *~ *.bak $(OBJS:.obj=.*) $(BUILDDIR)\Makefile.dep $(TARGET:.xpl=.*) 2>nul:
62 |
63 | # pull in dependency info
64 | !if [$(MD) $(BUILDDIR) 2>nul: & type $(OBJS:.obj=.dep) > $(BUILDDIR)\Makefile.dep 2>nul:]
65 | !endif
66 | !include $(BUILDDIR)\Makefile.dep
67 |
--------------------------------------------------------------------------------
/src/Makefile.lin:
--------------------------------------------------------------------------------
1 | # -*-Makefile-*-
2 | # Setup for building on Ubuntu x86_64 with multilib support, plus:
3 | # sudo ln -s mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
4 | # sudo ln -s libGLU.so.1 /usr/lib/i386-linux-gnu/libGLU.so
5 |
6 | include ../version.mak
7 |
8 | XPSDK=../../XPSDK213
9 |
10 | CC=gcc
11 | #BUILD=-g -DDEBUG
12 | #LDFLAGS=
13 | BUILD=-O3 -s -DNDEBUG
14 | LDFLAGS=-Wl,-x
15 | DEFINES=-DAPL=0 -DIBM=0 -DLIN=1 -DVERSION=$(VERSION)
16 | INC=-I$(XPSDK)/CHeaders/XPLM -I$(XPSDK)/CHeaders/Widgets
17 | CFLAGS=-march=core2 -ffast-math -pipe -Wall -Wdouble-promotion -Winline -Wno-missing-braces -static-libgcc -shared -fPIC -fvisibility=hidden $(BUILD) $(DEFINES) $(INC)
18 |
19 | VPATH=
20 | SRC=groundtraffic.c draw.c routes.c planes.c drawdebug.c
21 | LIBS=-lGLU -lGL
22 | TARGETDIR=../$(PROJECT)
23 | INSTALLDIR=~/Desktop/X-Plane\ 10/Custom\ Scenery/KSEA\ Demo\ GroundTraffic/plugins/$(PROJECT)
24 |
25 | ############################################################################
26 |
27 | BUILD_32=$(shell uname)32
28 | OBJS_32=$(addprefix $(BUILD_32)/, $(addsuffix .o, $(basename $(notdir $(SRC)))))
29 | TARGET_32=$(TARGETDIR)/lin.xpl
30 | INSTALL_32=$(INSTALLDIR)
31 | BUILD_64=$(shell uname)64
32 | OBJS_64=$(addprefix $(BUILD_64)/, $(addsuffix .o, $(basename $(notdir $(SRC)))))
33 | TARGET_64=$(TARGETDIR)/64/lin.xpl
34 | INSTALL_64=$(INSTALLDIR)/64
35 | TARGET=$(TARGET_32) $(TARGET_64)
36 |
37 | RM=rm -f
38 | CP=cp -p
39 | MD=mkdir -p
40 |
41 | .PHONY: all clean install
42 |
43 | all: $(TARGET_32) $(TARGET_64)
44 |
45 | install: $(TARGET_32) $(TARGET_64) | $(INSTALL_32) $(INSTALL_64)
46 | $(CP) $(TARGET_32) $(INSTALL_32)/
47 | $(CP) $(TARGET_64) $(INSTALL_64)/
48 |
49 | $(TARGET_32): $(OBJS_32) | $(TARGETDIR)
50 | $(CC) $(CFLAGS) $(LDFLAGS) -m32 -o $@ $+ $(LIBS)
51 |
52 | $(TARGET_64): $(OBJS_64) | $(TARGETDIR)/64
53 | $(CC) $(CFLAGS) $(LDFLAGS) -m64 -o $@ $+ $(LIBS)
54 |
55 | $(OBJS_32): | $(BUILD_32)
56 |
57 | $(OBJS_64): | $(BUILD_64)
58 |
59 | $(BUILD_32):
60 | $(MD) $(BUILD_32)
61 |
62 | $(BUILD_64):
63 | $(MD) $(BUILD_64)
64 |
65 | $(BUILD_32)/%.o: %.c
66 | $(CC) $(CFLAGS) -m32 -c -o $@ $<
67 | @$(CC) $(CFLAGS) -m32 -MM $< | sed -e 's|$*.o|$@|' > $(@:.o=.d)
68 |
69 | $(BUILD_64)/%.o: %.c
70 | $(CC) $(CFLAGS) -m64 -c -o $@ $<
71 | @$(CC) $(CFLAGS) -m64 -MM $< | sed -e 's|$*.o|$@|' > $(@:.o=.d)
72 |
73 | $(TARGETDIR):
74 | $(MD) $(TARGETDIR)
75 |
76 | $(TARGETDIR)/64:
77 | $(MD) $(TARGETDIR)/64
78 |
79 | $(INSTALL_32):
80 | $(MD) $(INSTALL_32)
81 |
82 | $(INSTALL_64):
83 | $(MD) $(INSTALL_64)
84 |
85 | clean:
86 | $(RM) *~ *.bak $(OBJS_32) $(OBJS_32:.o=.d) $(OBJS_64) $(OBJS_64:.o=.d) $(TARGET_32) $(TARGET_64)
87 |
88 | # pull in dependency info
89 | -include $(OBJS_32:.o=.d) $(OBJS_64:.o=.d)
90 |
--------------------------------------------------------------------------------
/src/drawdebug.c:
--------------------------------------------------------------------------------
1 | /*
2 | * GroundTraffic
3 | *
4 | * (c) Jonathan Harris 2014
5 | *
6 | * Licensed under GNU LGPL v2.1.
7 | */
8 |
9 | #include "groundtraffic.h"
10 |
11 | #define CIRCLEDIV 72
12 |
13 |
14 | /* Draw route paths in 3d drawing phase */
15 | void drawdebug3d(int drawnodes, GLint view[4])
16 | {
17 | GLdouble model[16], proj[16];
18 | int i;
19 | route_t *route;
20 |
21 | /* This is slow! */
22 | glGetDoublev(GL_MODELVIEW_MATRIX, model);
23 | glGetDoublev(GL_PROJECTION_MATRIX, proj);
24 |
25 | for(route=airport.routes; route; route=route->next)
26 | if (!route->parent)
27 | {
28 | GLdouble winX, winY, winZ;
29 |
30 | gluProject(route->drawinfo->x, route->drawinfo->y, route->drawinfo->z, model, proj, view, &winX, &winY, &winZ);
31 | if (winZ<=1 && winX>=0 && winX<(view[0]+view[2]) && winY>=0 && winY<(view[1]+view[3])) /* on screen and not behind us */
32 | {
33 | route->drawX = winX;
34 | route->drawY = winY;
35 | }
36 | else
37 | route->drawX = route->drawY = 0;
38 |
39 | glColor3fv(&route->drawcolor.r);
40 | glBegin((route->highway || route->path[route->pathlen-1].flags.reverse) ? GL_LINE_STRIP : GL_LINE_LOOP);
41 | for (i=0; ipathlen; i++)
42 | {
43 | path_t *node = route->path + i;
44 |
45 | glVertex3fv(&node->p.x);
46 |
47 | if (drawnodes)
48 | {
49 | gluProject(node->p.x, node->p.y, node->p.z, model, proj, view, &winX, &winY, &winZ);
50 | if (winZ<=1 && winX>=0 && winX<(view[0]+view[2]) && winY>=0 && winY<(view[1]+view[3])) /* on screen and not behind us */
51 | {
52 | node->drawX = winX;
53 | node->drawY = winY;
54 | }
55 | else
56 | node->drawX = node->drawY = 0;
57 | }
58 | else
59 | node->drawX = node->drawY = 0;
60 | }
61 | glEnd();
62 | }
63 | }
64 |
65 |
66 | /* Draw route labels in 2d drawing phase - uses screen co-ordinates calculated in 3d phase */
67 | void drawdebug2d()
68 | {
69 | float waycolor[] = { 1, 1, 1 }, routecolor[] = { 0.5f, 1, 1 };
70 | int i;
71 | route_t *route;
72 |
73 | for (route=airport.routes; route; route=route->next)
74 | if (!route->parent)
75 | for (i=0; ipathlen; i++)
76 | {
77 | path_t *node = route->path + i;
78 | if (node->drawX && node->drawY)
79 | {
80 | // XPLMDrawTranslucentDarkBox(node->drawX-font_width, node->drawY+font_semiheight-2, node->drawX+(strlen(labeltbl+5*i)-1)*font_width+1, node->drawY-font_semiheight-2);
81 | XPLMDrawString(waycolor, node->drawX-font_width, node->drawY-font_semiheight, labeltbl+5*i, NULL, xplmFont_Basic);
82 | }
83 | }
84 |
85 | for (route=airport.routes; route; route=route->next)
86 | if (!route->parent)
87 | if (route->drawX && route->drawY)
88 | {
89 | char buf[32];
90 | int off;
91 |
92 | sprintf(buf, "%d", route->lineno);
93 | off = strlen(buf);
94 |
95 | /* Test state flags in same order as drawcallback */
96 | if (route->state.waiting)
97 | sprintf(buf+off, " %d\xE2\x96\xAA" "At", route->last_node); /* BLACK SMALL SQUARE */
98 | else if (route->state.dataref)
99 | sprintf(buf+off, " %d\xE2\x96\xAA" "When", route->last_node);
100 | else if (route->state.paused)
101 | sprintf(buf+off, " %d\xE2\x96\xAA" "Pause", route->last_node);
102 | else if (route->state.collision == (collision_t*) -1)
103 | sprintf(buf+off, " %d\xE2\xA8\xAF" "aircraft", route->last_node); /* VECTOR OR CROSS PRODUCT */
104 | else if (route->state.collision)
105 | sprintf(buf+off, " %d\xE2\xA8\xAF" "%d", route->last_node, route->state.collision->route->lineno);
106 | else
107 | sprintf(buf+off, " %d\xE2\x9E\xA1" "%d", route->last_node, route->next_node); /* BLACK RIGHTWARDS ARROW */
108 | XPLMDrawTranslucentDarkBox(route->drawX-off*font_width, route->drawY+3*font_semiheight, route->drawX+(strlen(buf)-2-off)*font_width+1, route->drawY+font_semiheight);
109 | XPLMDrawString(routecolor, route->drawX-off*font_width, route->drawY+font_semiheight+2, buf, NULL, xplmFont_Basic);
110 | XPLMDrawString(&(route->drawcolor.r), route->drawX, route->drawY+font_semiheight+3, "\xE2\x96\xAE", NULL, xplmFont_Basic); /* BLACK VERTICAL RECTANGLE */
111 | }
112 | }
113 |
114 |
115 | int drawmap3d(XPLMDrawingPhase inPhase, int inIsBefore, void *inRefcon)
116 | {
117 | int i;
118 |
119 | if (!airport.drawroutes || airport.state == noconfig || !intilerange(airport.tower) || airport.tower.alt == (double) INVALID_ALT)
120 | return 1;
121 |
122 | XPLMSetGraphicsState(0, 0, 0, 0, 1, 0, 0);
123 | glLineWidth(1);
124 |
125 | /* draw activation range */
126 | glColor3f(0, 0, 0);
127 | glBegin(GL_LINE_LOOP);
128 | for (i=0; ix = XPLMFindDataRef(name))) return 0;
33 | strcpy(c, "local_y"); if (!(plane_ref->y = XPLMFindDataRef(name))) return 0;
34 | strcpy(c, "local_z"); if (!(plane_ref->z = XPLMFindDataRef(name))) return 0;
35 | strcpy(c, "local_vx"); if (!(plane_ref->vx = XPLMFindDataRef(name))) return 0;
36 | strcpy(c, "local_vz"); if (!(plane_ref->vz = XPLMFindDataRef(name))) return 0;
37 | strcpy(c, "psi"); if (!(plane_ref->hdg = XPLMFindDataRef(name))) return 0;
38 | if (!(plane_ref->gear= XPLMFindDataRef("sim/aircraft/parts/acf_gear_deploy"))) return 0;
39 |
40 | /* AI aircraft */
41 | for (i=1; ix = XPLMFindDataRef(name))) return 0;
47 | strcpy(c, "y"); if (!(plane_ref->y = XPLMFindDataRef(name))) return 0;
48 | strcpy(c, "z"); if (!(plane_ref->z = XPLMFindDataRef(name))) return 0;
49 | strcpy(c, "v_x"); if (!(plane_ref->vx = XPLMFindDataRef(name))) return 0;
50 | strcpy(c, "v_z"); if (!(plane_ref->vz = XPLMFindDataRef(name))) return 0;
51 | strcpy(c, "psi"); if (!(plane_ref->hdg = XPLMFindDataRef(name))) return 0;
52 | strcpy(c, "gear_deploy"); if (!(plane_ref->gear= XPLMFindDataRef(name))) return 0;
53 | }
54 |
55 | return -1;
56 | }
57 |
58 | void reset_planes()
59 | {
60 | plane_count = 0;
61 | }
62 |
63 | int count_planes()
64 | {
65 | int i;
66 | XPLMPluginID controller;
67 |
68 | if (plane_count) return plane_count;
69 |
70 | XPLMCountAircraft(&plane_count, &i, &controller); /* Use total, cos active may increase later */
71 | assert (plane_count > 0 && plane_count <= MAX_PLANES);
72 | if (plane_count > MAX_PLANES) plane_count = MAX_PLANES;
73 |
74 | for (i=0; iname, path);
83 | for (o=0; oname, plane_info[o].name))
85 | {
86 | memcpy(info, plane_info+o, sizeof(plane_acf_t));
87 | break;
88 | }
89 | if (olength = 40;
93 | info->cgz = 18;
94 | info->semiwidth = 18;
95 | info->refheight = 3.5;
96 |
97 | if (!(h = fopen(path, "r"))) continue;
98 | o = fgetc(h);
99 | if (o=='I' || o=='A')
100 | read_v10_plane(h, o, info);
101 | else if (o=='i' || o=='a')
102 | read_old_plane(h, o, info);
103 | fclose(h);
104 | }
105 |
106 | return plane_count;
107 | }
108 |
109 |
110 | static void read_v10_plane(FILE *h, int platform, plane_acf_t *info)
111 | {
112 | char line[256], *c1, *c2;
113 | int eol1;
114 | int version;
115 |
116 | if (!fgets(line, sizeof(line), h)) return;
117 | if (!fgets(line, sizeof(line), h)) return;
118 | c1=strtok(line, sep);
119 | c2=strtok(NULL, sep);
120 | if (!c1 || !sscanf(c1, "%d%n", &version, &eol1) || c1[eol1] ||
121 | strcmp(c2, "version") ||
122 | version < 1004)
123 | return; /* doesn't look like an ACF file */
124 |
125 | while (fgets(line, sizeof(line), h))
126 | {
127 | /* Assume for speed that fields are single-space separated */
128 | if (!strncmp(line, "P acf/_size_x ", sizeof("P acf/_size_x ")-1))
129 | {
130 | if (!sscanf(line+sizeof("P acf/_size_x ")-1, "%f", &info->semiwidth)) return;
131 | info->semiwidth *= 0.3048f;
132 | }
133 | else if (!strncmp(line, "P acf/_size_z ", sizeof("P acf/_size_z ")-1))
134 | {
135 | if (!sscanf(line+sizeof("P acf/_size_z ")-1, "%f", &info->length)) return;
136 | info->length *= 0.3048f;
137 | }
138 | else if (!strncmp(line, "P acf/_h_eqlbm ", sizeof("P acf/_h_eqlbm ")-1))
139 | {
140 | if (!sscanf(line+sizeof("P acf/_h_eqlbm ")-1, "%f", &info->refheight)) return;
141 | info->refheight *= 0.3048f;
142 | }
143 | else if (!strncmp(line, "P acf/_cgZ ", sizeof("P acf/_cgZ ")-1))
144 | {
145 | if (!sscanf(line+sizeof("P acf/_cgZ ")-1, "%f", &info->cgz)) return;
146 | info->cgz *= 0.3048f;
147 | }
148 | }
149 | }
150 |
151 | static size_t freadswap(void *ptr, size_t size, size_t nitems, FILE *stream)
152 | {
153 | unsigned char *c = ptr;
154 | int i, b;
155 |
156 | for (i=0; i=0; b--)
158 | if (!fread(c + b, 1, 1, stream)) return i;
159 |
160 | return nitems;
161 | }
162 |
163 | static void read_old_plane(FILE *h, int platform, plane_acf_t *info)
164 | {
165 | int version = 0;
166 | size_t (*readfn)(void *, size_t, size_t, FILE *) = platform=='i' ? fread : freadswap;
167 |
168 | assert(sizeof(int) == 4); /* Code below assumes this - could use int32_t */
169 | readfn(&version, 4, 1, h);
170 |
171 | /* WB_cgZ */
172 | if (version>=700 && version<=740)
173 | {
174 | if (fseek(h, 0x98a45, SEEK_SET)) return;
175 | }
176 | else if ((version>=800 && version<=941) || version==8000)
177 | {
178 | if (fseek(h, 0x21489, SEEK_SET)) return;
179 | }
180 | else /* unknown version */
181 | {
182 | return;
183 | }
184 | if (!readfn(&info->cgz, 4, 1, h)) return;
185 | info->cgz *= 0.3048f;
186 |
187 | /* AUTO_size_x, AUTO_size_z */
188 | if (version<=740)
189 | {
190 | if (fseek(h, 0x9bc2d, SEEK_SET)) return;
191 | }
192 | else
193 | {
194 | if (fseek(h, 0x21711, SEEK_SET)) return;
195 | }
196 | if (!readfn(&info->semiwidth, 4, 1, h)) return;
197 | info->semiwidth *= 0.3048f;
198 | if (!readfn(&info->length, 4, 1, h)) return;
199 | info->length *= 0.3048f;
200 |
201 | /* AUTO_h_eqlbm */
202 | if (version<=740)
203 | {
204 | if (fseek(h, 0x9bc3d, SEEK_SET)) return;
205 | }
206 | else
207 | {
208 | if (fseek(h, 0x2171d, SEEK_SET)) return;
209 | }
210 | if (!readfn(&info->refheight, 4, 1, h)) return;
211 | info->refheight *= 0.3048f;
212 | }
213 |
214 |
215 | plane_acf_t *get_plane_info(int planeno)
216 | {
217 | return plane_info + planeno;
218 | }
219 |
220 |
221 | int get_plane_pos(plane_pos_t *pos, int planeno)
222 | {
223 | plane_ref_t *plane_ref = plane_refs + planeno;
224 | float gear;
225 |
226 | assert(planeno < plane_count);
227 | if (!XPLMGetDatavf(plane_ref->gear, &gear, 0, 1) || gear!=1) return 0; /* Not interested in airborne planes */
228 |
229 | pos->p.x = XPLMGetDataf(plane_ref->x);
230 | pos->p.y = XPLMGetDataf(plane_ref->y);
231 | pos->p.z = XPLMGetDataf(plane_ref->z);
232 | if (!(pos->p.x || pos->p.z)) return 0; /* No position data ??? */
233 |
234 | pos->v.x = XPLMGetDataf(plane_ref->vx);
235 | pos->v.y = 0; /* Don't care about vertical speed */
236 | pos->v.z = XPLMGetDataf(plane_ref->vz);
237 | pos->hdg = XPLMGetDataf(plane_ref->hdg);
238 |
239 | return -1;
240 | }
241 |
242 |
243 | /* Get a plane's ground footprint.
244 | * Returns NULL if the plane is airborne. Otherwise returns pointer to a statically allocated
245 | * array of 4 points, contents of which will be overwritten on next call. */
246 | point_t *get_plane_footprint(int planeno, float time)
247 | {
248 | static point_t p[4]; /* footprint rectangle */
249 |
250 | plane_pos_t pos;
251 | plane_acf_t *info = plane_info + planeno;
252 | float gndy, h, cosh, sinh;
253 | point_t proj, tail, semi;
254 |
255 | if (!get_plane_pos(&pos, planeno)) return NULL;
256 |
257 | gndy = pos.p.y - info->refheight;
258 | h = D2R(pos.hdg);
259 | cosh = cosf(h);
260 | sinh = sinf(h);
261 | if (pos.v.x || pos.v.z)
262 | {
263 | /* Add space in front of plane */
264 | proj.x = pos.p.x + sinh * 2 * info->cgz + time * pos.v.x;
265 | proj.z = pos.p.z - cosh * 2 * info->cgz + time * pos.v.z;
266 | }
267 | else
268 | {
269 | /* unless plane is *completely* static (i.e. brake on) */
270 | proj.x = pos.p.x + sinh * info->cgz;
271 | proj.z = pos.p.z - cosh * info->cgz;
272 | }
273 | tail.x = pos.p.x - sinh * (info->length - info->cgz);
274 | tail.z = pos.p.z + cosh * (info->length - info->cgz);
275 | semi.x = cosh * info->semiwidth;
276 | semi.z = sinh * info->semiwidth;
277 |
278 | p[0].x = proj.x - semi.x; p[0].y = gndy; p[0].z = proj.z - semi.z;
279 | p[1].x = proj.x + semi.x; p[1].y = gndy; p[1].z = proj.z + semi.z;
280 | p[2].x = tail.x + semi.x; p[2].y = gndy; p[2].z = tail.z + semi.z;
281 | p[3].x = tail.x - semi.x; p[3].y = gndy; p[3].z = tail.z - semi.z;
282 |
283 | return p;
284 | }
285 |
--------------------------------------------------------------------------------
/src/groundtraffic.h:
--------------------------------------------------------------------------------
1 | /*
2 | * GroundTraffic
3 | *
4 | * (c) Jonathan Harris 2013-2014
5 | *
6 | * Licensed under GNU LGPL v2.1.
7 | */
8 |
9 | #ifndef _GROUNDTRAFFIC_H_
10 | #define _GROUNDTRAFFIC_H_
11 |
12 | #ifdef _MSC_VER
13 | # define _USE_MATH_DEFINES
14 | # define _CRT_SECURE_NO_DEPRECATE
15 | # define inline __forceinline
16 | #endif
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 | #ifdef _MSC_VER
31 | # define PATH_MAX MAX_PATH
32 | # define snprintf _snprintf
33 | # define hypotf _hypotf
34 | # define strcasecmp(s1, s2) _stricmp(s1, s2)
35 | # define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n)
36 | #endif
37 |
38 | #if IBM /* http://msdn.microsoft.com/en-us/library/windows/desktop/ms686355%28v=vs.85%29.aspx */
39 | # define WIN32_LEAN_AND_MEAN
40 | # include
41 | #else
42 | # include
43 | # include
44 | # include
45 | # include
46 | # if APL /* https://developer.apple.com/library/mac/documentation/cocoa/Conceptual/Multithreading/ThreadSafety/ThreadSafety.html */
47 | # include
48 | # define MemoryBarrier OSMemoryBarrier
49 | # elif LIN /* http://gcc.gnu.org/onlinedocs/gcc-4.6.3/gcc/Atomic-Builtins.html */
50 | # define MemoryBarrier __sync_synchronize
51 | # endif
52 | #endif
53 |
54 | #if APL
55 | # include
56 | # include
57 | #else
58 | # include
59 | # include
60 | #endif
61 |
62 | #define XPLM210 /* Requires X-Plane 10.0 or later */
63 | #define XPLM200
64 | #include "XPLMDataAccess.h"
65 | #include "XPLMDisplay.h"
66 | #include "XPLMGraphics.h"
67 | #include "XPLMPlanes.h"
68 | #include "XPLMPlugin.h"
69 | #include "XPLMProcessing.h"
70 | #include "XPLMScenery.h"
71 | #include "XPLMUtilities.h"
72 |
73 | #include "bbox.h"
74 |
75 | /* Version of assert that suppresses "variable ... set but not used" if the variable only exists for the purpose of the asserted expression */
76 | #ifdef NDEBUG
77 | # undef assert
78 | # define assert(expr) ((void)(expr))
79 | #elif !IBM
80 | # include
81 | # undef assert
82 | # define assert(expr) { if (!(expr)) raise(SIGTRAP); };
83 | #endif
84 |
85 | /* constants */
86 | #define MAX_NAME 256 /* Arbitrary limit on object name lengths */
87 | #define TILE_RANGE 1 /* How many tiles away from plane's tile to consider getting out of bed for */
88 | #define ACTIVE_POLL 16 /* Poll to see if we've come into range every n frames */
89 | #define ACTIVE_DISTANCE 5000.f /* Distance [m] from tower location at which to actually get out of bed */
90 | #define ACTIVE_WATER 20000.f /* As above when "water" flag is set (you can see a long way on water) */
91 | #define ACTIVE_HYSTERESIS (ACTIVE_DISTANCE*0.05f)
92 | #define MAX_RADIUS 4000.f /* Arbitrary limit on size of routes' bounding box */
93 | #define RADIUS 6378145.f /* from sim/physics/earth_radius_m [m] */
94 | #define DEFAULT_DRAWLOD 2.f /* Equivalent to an object 3m high */
95 | #define DEFAULT_LOD 2.25f /* Equivalent to "medium" world detail distance */
96 | #define DEFAULT_DRAWCARS 3.f /* Equivalent to "Chicago Suburbs" world detail distance */
97 | #define PROBE_ALT_FIRST -100 /* Arbitrary depth below tower for probe of first waypoint */
98 | #define PROBE_ALT_NEXT -25 /* Arbitrary depth below previous waypoint */
99 | #define PROBE_INTERVAL 0.5f /* How often to probe ahead for altitude [s] */
100 | #define PROBE_GRADIENT 0.25f /* Max gradient that vehicles will follow = 1:4 */
101 | #define TURN_TIME 2.f /* Time [s] to execute a turn at a waypoint */
102 | #define AT_INTERVAL 60.f /* How often [s] to poll for At times */
103 | #define WHEN_INTERVAL 1.f /* How often [s] to poll for When DataRef values */
104 | #define COLLISION_INTERVAL 2.f /* How long [s] to poll for crossing route path to become free. Also minimum spacing on overlapping segments */
105 | #define COLLISION_TIMEOUT ((int) 60/COLLISION_INTERVAL) /* How many times to poll before giving up to break deadlock */
106 | #define COLLISION_ALT 3.f /* Objects won't collide if their altitude differs by more than this [m] */
107 | #define RESET_TIME 15.f /* If we're deactivated for longer than this then reset route timings */
108 | #define MAX_VAR 10 /* How many var datarefs */
109 | #define HIGHWAY_VARIANCE 0.25f /* How much to vary spacing of objects on a highway */
110 |
111 | /* Options */
112 | #undef DO_BENCHMARK
113 | #undef DO_MARKERS
114 |
115 | /* Published DataRefs */
116 | #define REF_BASE "marginal/groundtraffic/"
117 | #define REF_VAR REF_BASE "var"
118 | #define REF_DISTANCE REF_BASE "distance"
119 | #define REF_SPEED REF_BASE "speed"
120 | #define REF_STEER REF_BASE "steer"
121 | #define REF_NODE_LAST REF_BASE "waypoint/last"
122 | #define REF_NODE_LAST_DISTANCE REF_BASE "waypoint/last/distance"
123 | #define REF_NODE_NEXT REF_BASE "waypoint/next"
124 | #define REF_NODE_NEXT_DISTANCE REF_BASE "waypoint/next/distance"
125 | #define REF_LOD REF_BASE "lod"
126 | #define REF_RANGE REF_BASE "range"
127 | #define REF_DRAWTIME REF_BASE "drawtime"
128 |
129 | typedef enum
130 | {
131 | distance=0, speed, steer, node_last, node_last_distance, node_next, node_next_distance,
132 | #ifdef DEBUG
133 | lod, range,
134 | #endif
135 | #ifdef DO_BENCHMARK
136 | drawtime,
137 | #endif
138 | dataref_count
139 | } dataref_t;
140 |
141 | /* Geolocation */
142 | typedef struct
143 | {
144 | float lat, lon, alt; /* drawing routines use float, so no point storing higher precision */
145 | } loc_t;
146 |
147 | #define INVALID_ALT FLT_MAX
148 | typedef struct
149 | {
150 | double lat, lon, alt; /* but XPLMWorldToLocal uses double, so prevent type conversions */
151 | } dloc_t;
152 |
153 | /* OpenGL coordinate */
154 | typedef struct
155 | {
156 | float x, y, z;
157 | } point_t;
158 |
159 | typedef struct
160 | {
161 | double x, y, z;
162 | } dpoint_t;
163 |
164 | /* Days in same order as tm_wday in struct tm, such that 2**tm_wday==DAY_X */
165 | #define DAY_SUN 1
166 | #define DAY_MON 2
167 | #define DAY_TUE 4
168 | #define DAY_WED 8
169 | #define DAY_THU 16
170 | #define DAY_FRI 32
171 | #define DAY_SAT 64
172 | #define DAY_ALL (DAY_SUN|DAY_MON|DAY_TUE|DAY_WED|DAY_THU|DAY_FRI|DAY_SAT)
173 | #define MAX_ATTIMES 24 /* Number of times allowed in an At command */
174 | #define INVALID_AT -1
175 |
176 |
177 | /* User-defined published DataRef or per-route var[n] */
178 | typedef enum { rising, falling } slope_t;
179 | typedef enum { linear, sine } curve_t;
180 | typedef struct userref_t
181 | {
182 | char *name; /* NULL for per-route var[n] datarefs */
183 | XPLMDataRef ref;
184 | float duration;
185 | float start1, start2;
186 | slope_t slope;
187 | curve_t curve;
188 | struct userref_t *next; /* NULL for per-route var[n] datarefs */
189 | } userref_t;
190 |
191 | /* Set command */
192 | typedef struct setcmd_t
193 | {
194 | userref_t *userref;
195 | float duration;
196 | struct {
197 | int set1 : 1; /* set command */
198 | int set2 : 1; /* pause ... set command */
199 | slope_t slope : 1;
200 | curve_t curve : 1;
201 | } flags;
202 | struct setcmd_t *next; /* Next setcmd at a waypoint */
203 | } setcmd_t;
204 |
205 |
206 | /* DataRef referenced in When or And command */
207 | #define xplmType_Mine -1
208 | typedef struct extref_t
209 | {
210 | char *name;
211 | XPLMDataRef ref; /* ID, or pointer if type == xplmType_Mine */
212 | XPLMDataTypeID type;
213 | struct extref_t *next;
214 | } extref_t;
215 |
216 |
217 | /* When & And command */
218 | typedef struct whenref_t
219 | {
220 | extref_t *extref;
221 | int idx;
222 | float from, to;
223 | struct whenref_t *next; /* Next whenref at a waypoint */
224 | } whenref_t;
225 |
226 |
227 | /* Route path - locations or commands */
228 | struct collision_t;
229 | typedef struct
230 | {
231 | loc_t waypoint; /* World */
232 | point_t p; /* Local OpenGL co-ordinates */
233 | point_t p1, p3; /* Bezier points for turn */
234 | int pausetime;
235 | short attime[MAX_ATTIMES]; /* minutes past midnight */
236 | unsigned char atdays;
237 | struct {
238 | int reverse : 1; /* Reverse whole route */
239 | int backup : 1; /* Just reverse to next node */
240 | } flags;
241 | struct collision_t *collisions; /* Collisions with other routes */
242 | setcmd_t *setcmds;
243 | whenref_t *whenrefs;
244 | int drawX, drawY; /* For labeling nodes */
245 | } path_t;
246 |
247 | typedef struct
248 | {
249 | GLfloat r, g, b;
250 | } glColor3f_t;
251 |
252 | typedef struct
253 | {
254 | char *name;
255 | char *physical_name;
256 | XPLMObjectRef objref;
257 | float drawlod; /* Multiply by lod_factor to get draw distance */
258 | float lag; /* time lag. [m] in train defn, [s] in route */
259 | float offset; /* offset applied after rotation before drawing. [m] */
260 | float heading; /* rotation applied before drawing */
261 | } objdef_t;
262 |
263 | /* A route from routes.txt */
264 | struct collision_t;
265 | struct highway_t;
266 | typedef struct route_t
267 | {
268 | int lineno; /* Source line in GroundTraffic.txt */
269 | objdef_t object;
270 | path_t *path;
271 | int pathlen;
272 | bbox_t bbox; /* Bounding box of path */
273 | struct
274 | {
275 | int frozen : 1; /* Child whose parent is waiting */
276 | int paused : 1; /* Waiting for pause duration */
277 | int waiting : 1; /* Waiting for At time */
278 | int dataref : 1; /* Waiting for DataRef value */
279 | int forwardsb : 1; /* Waypoint before backing up */
280 | int backingup : 1;
281 | int forwardsa : 1; /* Waypoint after backing up */
282 | int hasdataref: 1; /* Does the object on this route have DataRef callbacks? */
283 | struct collision_t *collision; /* Waiting for this collision to resolve */
284 | } state;
285 | int direction; /* Traversing path 1=forwards, -1=reverse */
286 | int last_node, next_node; /* The last and next waypoints visited on the path */
287 | float last_time, next_time; /* Time we left last_node, expected time to hit the next node */
288 | float freeze_time; /* For children: Time when parent started pause */
289 | float speed; /* [m/s] */
290 | float last_distance; /* Cumulative distance travelled from first to last_node [m] */
291 | float next_distance; /* Distance from last_node to next_node [m] */
292 | float distance; /* Cumulative distance travelled from first node [m] */
293 | float next_heading; /* Heading from last_node to next_node [m] */
294 | float steer; /* Approximate steer angle (degrees) while turning */
295 | glColor3f_t drawcolor; /* debug path color */
296 | int drawX, drawY; /* debug label position */
297 | XPLMDrawInfo_t *drawinfo; /* Where to draw - current OpenGL co-ordinates */
298 | float last_probe, next_probe; /* Time of last altitude probe and when we should probe again */
299 | float last_y, next_y; /* OpenGL co-ordinates at last and next probe points */
300 | int deadlocked; /* Counter used to break collision deadlock */
301 | float highway_offset; /* For highway children: Starting offset from start of route */
302 | struct highway_t *highway; /* Is a highway */
303 | userref_t (*varrefs)[MAX_VAR]; /* Per-route var dataref */
304 | struct route_t *parent; /* Points to head of a train */
305 | struct route_t *next;
306 | } route_t;
307 |
308 |
309 | /* A train of interconnected objects */
310 | #define MAX_TRAIN 16
311 | typedef struct train_t
312 | {
313 | char *name;
314 | objdef_t objects[MAX_TRAIN];
315 | struct train_t *next;
316 | } train_t;
317 |
318 |
319 | /* A highway */
320 | #define MAX_HIGHWAY 16
321 | typedef struct highway_t
322 | {
323 | objdef_t objects[MAX_HIGHWAY];
324 | objdef_t *expanded; /* Physical objects */
325 | int obj_count; /* Physical object count */
326 | float spacing;
327 | struct highway_t *next;
328 | } highway_t;
329 |
330 |
331 | /* Collision between routes */
332 | typedef struct collision_t
333 | {
334 | route_t *route; /* Other route */
335 | int node; /* Other node (assuming forwards direction) */
336 | struct collision_t *next;
337 | } collision_t;
338 |
339 |
340 | /* airport info from routes.txt */
341 | typedef struct
342 | {
343 | enum { noconfig=0, inactive, activating, active } state;
344 | int case_folding; /* Whether our package is on a case-sensitive file system (i.e. Linux) */
345 | int done_first_activation; /* Whether we've calculated collisions and expanded highways */
346 | int new_airport; /* Whether we've moved to a new airport, so activation should be immediate */
347 | dloc_t tower;
348 | dpoint_t p; /* Remember OpenGL location of tower to detect scenery shift */
349 | int drawroutes;
350 | int reflections;
351 | float active_distance;
352 | route_t *routes;
353 | route_t *firstroute;
354 | train_t *trains;
355 | userref_t *userrefs;
356 | extref_t *extrefs;
357 | XPLMDrawInfo_t *drawinfo; /* consolidated XPLMDrawInfo_t array for all routes/objects so they can be batched */
358 | } airport_t;
359 |
360 |
361 | /* Worker thread */
362 | /* Align to cache-line - http://software.intel.com/en-us/articles/avoiding-and-identifying-false-sharing-among-threads */
363 | #if IBM
364 | typedef __declspec(align(64)) struct
365 | #else
366 | typedef struct __attribute__((aligned(64)))
367 | #endif
368 | {
369 | #if IBM
370 | HANDLE thread;
371 | #else
372 | pthread_t thread;
373 | #endif
374 | int die_please;
375 | int finished;
376 | } worker_t;
377 |
378 |
379 | /* prototypes */
380 | int activate(airport_t *airport);
381 | void deactivate(airport_t *airport);
382 | void proberoutes(airport_t *airport);
383 | void maproutes(airport_t *airport);
384 | float userrefcallback(XPLMDataRef inRefcon);
385 |
386 | int xplog(char *msg);
387 | int readconfig(char *pkgpath, airport_t *airport);
388 | void clearconfig(airport_t *airport);
389 |
390 | void labelcallback(XPLMWindowID inWindowID, void *inRefcon);
391 | int drawcallback(XPLMDrawingPhase inPhase, int inIsBefore, void *inRefcon);
392 |
393 | void drawdebug3d(int drawnodes, GLint view[4]);
394 | void drawdebug2d();
395 | int drawmap3d(XPLMDrawingPhase inPhase, int inIsBefore, void *inRefcon);
396 | int drawmap2d(XPLMDrawingPhase inPhase, int inIsBefore, void *inRefcon);
397 |
398 |
399 | /* Globals */
400 | extern char *pkgpath;
401 | extern XPLMDataRef ref_plane_lat, ref_plane_lon, ref_view_x, ref_view_y, ref_view_z, ref_rentype, ref_night, ref_monotonic, ref_doy, ref_tod, ref_LOD;
402 | extern XPLMDataRef ref_datarefs[dataref_count], ref_varref;
403 | extern XPLMProbeRef ref_probe;
404 | extern float lod_bias;
405 | extern airport_t airport;
406 | extern route_t *drawroute; /* Global so can be accessed in dataref callback */
407 | extern int year; /* Current year (in GMT tz) */
408 | #ifdef DO_BENCHMARK
409 | extern int drawcumul;
410 | extern int drawframes;
411 | #endif
412 |
413 | extern float last_frame; /* Global so can be reset while disabled */
414 | extern float lod_factor;
415 | extern char *labeltbl;
416 | extern int font_width, font_semiheight;
417 |
418 |
419 | /* inlines */
420 |
421 | /* naive UTF8-aware strlen */
422 | static inline int utf8_strlen(const char *s)
423 | {
424 | int len = 0;
425 | while (*s)
426 | if (((*s++) & 0xC0) != 0x80) len++; /* Not a continuation byte */
427 | return len;
428 | }
429 |
430 |
431 | static inline int intilerange(dloc_t loc)
432 | {
433 | double tile_lat, tile_lon;
434 | tile_lat = floor(XPLMGetDatad(ref_plane_lat));
435 | tile_lon = floor(XPLMGetDatad(ref_plane_lon));
436 | return ((fabs(tile_lat - floor(loc.lat)) <= TILE_RANGE) && (fabs(tile_lon - floor(loc.lon)) <= TILE_RANGE));
437 | }
438 |
439 |
440 | static inline int indrawrange(float xdist, float ydist, float zdist, float range)
441 | {
442 | assert (airport.tower.alt != (double) INVALID_ALT); /* If altitude is invalid then arguments to this function will be too */
443 | return (xdist*xdist + ydist*ydist + zdist*zdist <= range*range);
444 | }
445 |
446 | static inline float R2D(float r)
447 | {
448 | return r * ((float) (180*M_1_PI));
449 | }
450 |
451 | static inline float D2R(float d)
452 | {
453 | return d * ((float) (M_PI/180));
454 | }
455 |
456 |
457 | /* Operations on point_t */
458 |
459 | static inline float angleto(point_t *from, point_t *to)
460 | {
461 | return atan2f(to->x-from->x, to->z-from->z);
462 | }
463 |
464 | /* 2D is point inside polygon? */
465 | static inline int inside(point_t *p, point_t *poly, int npoints)
466 | {
467 | /* http://paulbourke.net/geometry/polygonmesh/ "Determining if a point lies on the interior of a polygon" */
468 | int i, j, c=0;
469 | for (i=0, j=npoints-1; iz) && (p->z < poly[j].z)) || ((poly[j].z <= p->z) && (p->z < poly[i].z))) &&
471 | (p->x < (poly[j].x - poly[i].x) * (p->z - poly[i].z) / (poly[j].z - poly[i].z) + poly[i].x))
472 | c = !c;
473 | return c;
474 | }
475 |
476 | /* 2D does line p0->p1 intersect p2->p3 */
477 | static inline int intersect(point_t *p0, point_t *p1, point_t *p2, point_t *p3)
478 | {
479 | /* http://stackoverflow.com/a/1968345 */
480 | float s, t, d, s1_x, s1_z, s2_x, s2_z;
481 |
482 | s1_x = p1->x - p0->x; s1_z = p1->z - p0->z;
483 | s2_x = p3->x - p2->x; s2_z = p3->z - p2->z;
484 | d = -s2_x * s1_z + s1_x * s2_z;
485 | if (d==0) return 0; /* Precisely parallel or collinear - ignore in either case */
486 |
487 | s = (-s1_z * (p0->x - p2->x) + s1_x * (p0->z - p2->z)) / d;
488 | t = ( s2_x * (p0->z - p2->z) - s2_z * (p0->x - p2->x)) / d;
489 |
490 | /* use strict comparison because only interested in significant intersections */
491 | return s > 0 && s < 1 && t > 0 && t < 1;
492 | }
493 |
494 |
495 | /* Operations on loc_t */
496 |
497 | /* 2D does line p0->p1 intersect p2->p3 */
498 | static inline int loc_intersect(loc_t *p0, loc_t *p1, loc_t *p2, loc_t *p3)
499 | {
500 | /* http://stackoverflow.com/a/1968345 */
501 | float s, t, d, s1_x, s1_y, s2_x, s2_y;
502 |
503 | s1_x = p1->lon - p0->lon; s1_y = p1->lat - p0->lat;
504 | s2_x = p3->lon - p2->lon; s2_y = p3->lat - p2->lat;
505 | d = (-s2_x * s1_y + s1_x * s2_y);
506 | if (d==0) return 0; /* Precisely parallel or collinear - ignore in either case */
507 |
508 | s = (-s1_y * (p0->lon - p2->lon) + s1_x * (p0->lat - p2->lat)) / d;
509 | t = ( s2_x * (p0->lat - p2->lat) - s2_y * (p0->lon - p2->lon)) / d;
510 |
511 | /* use strict comparison because path segments don't count as colliding if they just share a starting node */
512 | return s > 0 && s < 1 && t > 0 && t < 1;
513 | }
514 |
515 |
516 | /* quick and dirty and not very accurate gettimeofday implementation ignoring timezone */
517 | #if defined(_MSC_VER) && defined(DO_BENCHMARK)
518 | # include /* for timeval */
519 | static inline int gettimeofday(struct timeval *tp, void *tzp)
520 | {
521 | LARGE_INTEGER frequency; // ticks per second
522 | LARGE_INTEGER counter;
523 |
524 | QueryPerformanceFrequency(&frequency);
525 | QueryPerformanceCounter(&counter);
526 | counter.QuadPart = (counter.QuadPart * 1000000) / frequency.QuadPart; /* In microseconds */
527 | tp->tv_sec = counter.QuadPart / 1000000;
528 | tp->tv_usec = counter.QuadPart - tp->tv_sec * 1000000;
529 | return 0;
530 | }
531 | #endif
532 |
533 |
534 | /* Operations on worker_t */
535 |
536 | static inline int worker_start(worker_t *worker, void *(*start_routine)(void *))
537 | {
538 | worker->die_please = worker->finished = 0;
539 | MemoryBarrier();
540 | #if IBM
541 | if (!(worker->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) start_routine, NULL, 0, NULL)))
542 | #else
543 | if (pthread_create(&worker->thread, NULL, start_routine, NULL))
544 | #endif
545 | {
546 | return xplog("Internal error: Can't create worker thread");
547 | }
548 | return -1;
549 | }
550 |
551 | /* Wait for worker to stop */
552 | static inline void worker_wait(worker_t *worker)
553 | {
554 | if (worker->thread)
555 | {
556 | #if IBM
557 | WaitForSingleObject(worker->thread, INFINITE);
558 | CloseHandle(worker->thread);
559 | #else
560 | pthread_join(worker->thread, NULL);
561 | #endif
562 | worker->thread = 0;
563 | }
564 | }
565 |
566 | /* Signal worker and wait for it to stop */
567 | static inline void worker_stop(worker_t *worker)
568 | {
569 | if (worker->thread)
570 | {
571 | worker->die_please = -1;
572 | MemoryBarrier();
573 | worker_wait(worker);
574 | }
575 | }
576 |
577 | /* Check whether worker is finished */
578 | static inline int worker_is_finished(worker_t *worker)
579 | {
580 | if (worker->thread)
581 | {
582 | MemoryBarrier();
583 | if (worker->finished)
584 | {
585 | worker_wait(worker);
586 | return -1;
587 | }
588 | else
589 | return 0;
590 | }
591 | else
592 | return -1;
593 | }
594 |
595 | /* Called from worker thread to check for early termination */
596 | #define worker_check_stop(worker) { MemoryBarrier(); if ((*(worker)).die_please) return NULL; }
597 |
598 | /* Called from worker thread to indicate completion */
599 | #define worker_has_finished(worker) { MemoryBarrier(); (*(worker)).finished = -1; }
600 |
601 |
602 | #endif /* _GROUNDTRAFFIC_H_ */
603 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 2.1, February 1999
3 |
4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | (This is the first released version of the Lesser GPL. It also counts
10 | as the successor of the GNU Library Public License, version 2, hence
11 | the version number 2.1.)
12 |
13 | Preamble
14 |
15 | The licenses for most software are designed to take away your
16 | freedom to share and change it. By contrast, the GNU General Public
17 | Licenses are intended to guarantee your freedom to share and change
18 | free software--to make sure the software is free for all its users.
19 |
20 | This license, the Lesser General Public License, applies to some
21 | specially designated software packages--typically libraries--of the
22 | Free Software Foundation and other authors who decide to use it. You
23 | can use it too, but we suggest you first think carefully about whether
24 | this license or the ordinary General Public License is the better
25 | strategy to use in any particular case, based on the explanations below.
26 |
27 | When we speak of free software, we are referring to freedom of use,
28 | not price. Our General Public Licenses are designed to make sure that
29 | you have the freedom to distribute copies of free software (and charge
30 | for this service if you wish); that you receive source code or can get
31 | it if you want it; that you can change the software and use pieces of
32 | it in new free programs; and that you are informed that you can do
33 | these things.
34 |
35 | To protect your rights, we need to make restrictions that forbid
36 | distributors to deny you these rights or to ask you to surrender these
37 | rights. These restrictions translate to certain responsibilities for
38 | you if you distribute copies of the library or if you modify it.
39 |
40 | For example, if you distribute copies of the library, whether gratis
41 | or for a fee, you must give the recipients all the rights that we gave
42 | you. You must make sure that they, too, receive or can get the source
43 | code. If you link other code with the library, you must provide
44 | complete object files to the recipients, so that they can relink them
45 | with the library after making changes to the library and recompiling
46 | it. And you must show them these terms so they know their rights.
47 |
48 | We protect your rights with a two-step method: (1) we copyright the
49 | library, and (2) we offer you this license, which gives you legal
50 | permission to copy, distribute and/or modify the library.
51 |
52 | To protect each distributor, we want to make it very clear that
53 | there is no warranty for the free library. Also, if the library is
54 | modified by someone else and passed on, the recipients should know
55 | that what they have is not the original version, so that the original
56 | author's reputation will not be affected by problems that might be
57 | introduced by others.
58 |
59 | Finally, software patents pose a constant threat to the existence of
60 | any free program. We wish to make sure that a company cannot
61 | effectively restrict the users of a free program by obtaining a
62 | restrictive license from a patent holder. Therefore, we insist that
63 | any patent license obtained for a version of the library must be
64 | consistent with the full freedom of use specified in this license.
65 |
66 | Most GNU software, including some libraries, is covered by the
67 | ordinary GNU General Public License. This license, the GNU Lesser
68 | General Public License, applies to certain designated libraries, and
69 | is quite different from the ordinary General Public License. We use
70 | this license for certain libraries in order to permit linking those
71 | libraries into non-free programs.
72 |
73 | When a program is linked with a library, whether statically or using
74 | a shared library, the combination of the two is legally speaking a
75 | combined work, a derivative of the original library. The ordinary
76 | General Public License therefore permits such linking only if the
77 | entire combination fits its criteria of freedom. The Lesser General
78 | Public License permits more lax criteria for linking other code with
79 | the library.
80 |
81 | We call this license the "Lesser" General Public License because it
82 | does Less to protect the user's freedom than the ordinary General
83 | Public License. It also provides other free software developers Less
84 | of an advantage over competing non-free programs. These disadvantages
85 | are the reason we use the ordinary General Public License for many
86 | libraries. However, the Lesser license provides advantages in certain
87 | special circumstances.
88 |
89 | For example, on rare occasions, there may be a special need to
90 | encourage the widest possible use of a certain library, so that it becomes
91 | a de-facto standard. To achieve this, non-free programs must be
92 | allowed to use the library. A more frequent case is that a free
93 | library does the same job as widely used non-free libraries. In this
94 | case, there is little to gain by limiting the free library to free
95 | software only, so we use the Lesser General Public License.
96 |
97 | In other cases, permission to use a particular library in non-free
98 | programs enables a greater number of people to use a large body of
99 | free software. For example, permission to use the GNU C Library in
100 | non-free programs enables many more people to use the whole GNU
101 | operating system, as well as its variant, the GNU/Linux operating
102 | system.
103 |
104 | Although the Lesser General Public License is Less protective of the
105 | users' freedom, it does ensure that the user of a program that is
106 | linked with the Library has the freedom and the wherewithal to run
107 | that program using a modified version of the Library.
108 |
109 | The precise terms and conditions for copying, distribution and
110 | modification follow. Pay close attention to the difference between a
111 | "work based on the library" and a "work that uses the library". The
112 | former contains code derived from the library, whereas the latter must
113 | be combined with the library in order to run.
114 |
115 | GNU LESSER GENERAL PUBLIC LICENSE
116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
117 |
118 | 0. This License Agreement applies to any software library or other
119 | program which contains a notice placed by the copyright holder or
120 | other authorized party saying it may be distributed under the terms of
121 | this Lesser General Public License (also called "this License").
122 | Each licensee is addressed as "you".
123 |
124 | A "library" means a collection of software functions and/or data
125 | prepared so as to be conveniently linked with application programs
126 | (which use some of those functions and data) to form executables.
127 |
128 | The "Library", below, refers to any such software library or work
129 | which has been distributed under these terms. A "work based on the
130 | Library" means either the Library or any derivative work under
131 | copyright law: that is to say, a work containing the Library or a
132 | portion of it, either verbatim or with modifications and/or translated
133 | straightforwardly into another language. (Hereinafter, translation is
134 | included without limitation in the term "modification".)
135 |
136 | "Source code" for a work means the preferred form of the work for
137 | making modifications to it. For a library, complete source code means
138 | all the source code for all modules it contains, plus any associated
139 | interface definition files, plus the scripts used to control compilation
140 | and installation of the library.
141 |
142 | Activities other than copying, distribution and modification are not
143 | covered by this License; they are outside its scope. The act of
144 | running a program using the Library is not restricted, and output from
145 | such a program is covered only if its contents constitute a work based
146 | on the Library (independent of the use of the Library in a tool for
147 | writing it). Whether that is true depends on what the Library does
148 | and what the program that uses the Library does.
149 |
150 | 1. You may copy and distribute verbatim copies of the Library's
151 | complete source code as you receive it, in any medium, provided that
152 | you conspicuously and appropriately publish on each copy an
153 | appropriate copyright notice and disclaimer of warranty; keep intact
154 | all the notices that refer to this License and to the absence of any
155 | warranty; and distribute a copy of this License along with the
156 | Library.
157 |
158 | You may charge a fee for the physical act of transferring a copy,
159 | and you may at your option offer warranty protection in exchange for a
160 | fee.
161 |
162 | 2. You may modify your copy or copies of the Library or any portion
163 | of it, thus forming a work based on the Library, and copy and
164 | distribute such modifications or work under the terms of Section 1
165 | above, provided that you also meet all of these conditions:
166 |
167 | a) The modified work must itself be a software library.
168 |
169 | b) You must cause the files modified to carry prominent notices
170 | stating that you changed the files and the date of any change.
171 |
172 | c) You must cause the whole of the work to be licensed at no
173 | charge to all third parties under the terms of this License.
174 |
175 | d) If a facility in the modified Library refers to a function or a
176 | table of data to be supplied by an application program that uses
177 | the facility, other than as an argument passed when the facility
178 | is invoked, then you must make a good faith effort to ensure that,
179 | in the event an application does not supply such function or
180 | table, the facility still operates, and performs whatever part of
181 | its purpose remains meaningful.
182 |
183 | (For example, a function in a library to compute square roots has
184 | a purpose that is entirely well-defined independent of the
185 | application. Therefore, Subsection 2d requires that any
186 | application-supplied function or table used by this function must
187 | be optional: if the application does not supply it, the square
188 | root function must still compute square roots.)
189 |
190 | These requirements apply to the modified work as a whole. If
191 | identifiable sections of that work are not derived from the Library,
192 | and can be reasonably considered independent and separate works in
193 | themselves, then this License, and its terms, do not apply to those
194 | sections when you distribute them as separate works. But when you
195 | distribute the same sections as part of a whole which is a work based
196 | on the Library, the distribution of the whole must be on the terms of
197 | this License, whose permissions for other licensees extend to the
198 | entire whole, and thus to each and every part regardless of who wrote
199 | it.
200 |
201 | Thus, it is not the intent of this section to claim rights or contest
202 | your rights to work written entirely by you; rather, the intent is to
203 | exercise the right to control the distribution of derivative or
204 | collective works based on the Library.
205 |
206 | In addition, mere aggregation of another work not based on the Library
207 | with the Library (or with a work based on the Library) on a volume of
208 | a storage or distribution medium does not bring the other work under
209 | the scope of this License.
210 |
211 | 3. You may opt to apply the terms of the ordinary GNU General Public
212 | License instead of this License to a given copy of the Library. To do
213 | this, you must alter all the notices that refer to this License, so
214 | that they refer to the ordinary GNU General Public License, version 2,
215 | instead of to this License. (If a newer version than version 2 of the
216 | ordinary GNU General Public License has appeared, then you can specify
217 | that version instead if you wish.) Do not make any other change in
218 | these notices.
219 |
220 | Once this change is made in a given copy, it is irreversible for
221 | that copy, so the ordinary GNU General Public License applies to all
222 | subsequent copies and derivative works made from that copy.
223 |
224 | This option is useful when you wish to copy part of the code of
225 | the Library into a program that is not a library.
226 |
227 | 4. You may copy and distribute the Library (or a portion or
228 | derivative of it, under Section 2) in object code or executable form
229 | under the terms of Sections 1 and 2 above provided that you accompany
230 | it with the complete corresponding machine-readable source code, which
231 | must be distributed under the terms of Sections 1 and 2 above on a
232 | medium customarily used for software interchange.
233 |
234 | If distribution of object code is made by offering access to copy
235 | from a designated place, then offering equivalent access to copy the
236 | source code from the same place satisfies the requirement to
237 | distribute the source code, even though third parties are not
238 | compelled to copy the source along with the object code.
239 |
240 | 5. A program that contains no derivative of any portion of the
241 | Library, but is designed to work with the Library by being compiled or
242 | linked with it, is called a "work that uses the Library". Such a
243 | work, in isolation, is not a derivative work of the Library, and
244 | therefore falls outside the scope of this License.
245 |
246 | However, linking a "work that uses the Library" with the Library
247 | creates an executable that is a derivative of the Library (because it
248 | contains portions of the Library), rather than a "work that uses the
249 | library". The executable is therefore covered by this License.
250 | Section 6 states terms for distribution of such executables.
251 |
252 | When a "work that uses the Library" uses material from a header file
253 | that is part of the Library, the object code for the work may be a
254 | derivative work of the Library even though the source code is not.
255 | Whether this is true is especially significant if the work can be
256 | linked without the Library, or if the work is itself a library. The
257 | threshold for this to be true is not precisely defined by law.
258 |
259 | If such an object file uses only numerical parameters, data
260 | structure layouts and accessors, and small macros and small inline
261 | functions (ten lines or less in length), then the use of the object
262 | file is unrestricted, regardless of whether it is legally a derivative
263 | work. (Executables containing this object code plus portions of the
264 | Library will still fall under Section 6.)
265 |
266 | Otherwise, if the work is a derivative of the Library, you may
267 | distribute the object code for the work under the terms of Section 6.
268 | Any executables containing that work also fall under Section 6,
269 | whether or not they are linked directly with the Library itself.
270 |
271 | 6. As an exception to the Sections above, you may also combine or
272 | link a "work that uses the Library" with the Library to produce a
273 | work containing portions of the Library, and distribute that work
274 | under terms of your choice, provided that the terms permit
275 | modification of the work for the customer's own use and reverse
276 | engineering for debugging such modifications.
277 |
278 | You must give prominent notice with each copy of the work that the
279 | Library is used in it and that the Library and its use are covered by
280 | this License. You must supply a copy of this License. If the work
281 | during execution displays copyright notices, you must include the
282 | copyright notice for the Library among them, as well as a reference
283 | directing the user to the copy of this License. Also, you must do one
284 | of these things:
285 |
286 | a) Accompany the work with the complete corresponding
287 | machine-readable source code for the Library including whatever
288 | changes were used in the work (which must be distributed under
289 | Sections 1 and 2 above); and, if the work is an executable linked
290 | with the Library, with the complete machine-readable "work that
291 | uses the Library", as object code and/or source code, so that the
292 | user can modify the Library and then relink to produce a modified
293 | executable containing the modified Library. (It is understood
294 | that the user who changes the contents of definitions files in the
295 | Library will not necessarily be able to recompile the application
296 | to use the modified definitions.)
297 |
298 | b) Use a suitable shared library mechanism for linking with the
299 | Library. A suitable mechanism is one that (1) uses at run time a
300 | copy of the library already present on the user's computer system,
301 | rather than copying library functions into the executable, and (2)
302 | will operate properly with a modified version of the library, if
303 | the user installs one, as long as the modified version is
304 | interface-compatible with the version that the work was made with.
305 |
306 | c) Accompany the work with a written offer, valid for at
307 | least three years, to give the same user the materials
308 | specified in Subsection 6a, above, for a charge no more
309 | than the cost of performing this distribution.
310 |
311 | d) If distribution of the work is made by offering access to copy
312 | from a designated place, offer equivalent access to copy the above
313 | specified materials from the same place.
314 |
315 | e) Verify that the user has already received a copy of these
316 | materials or that you have already sent this user a copy.
317 |
318 | For an executable, the required form of the "work that uses the
319 | Library" must include any data and utility programs needed for
320 | reproducing the executable from it. However, as a special exception,
321 | the materials to be distributed need not include anything that is
322 | normally distributed (in either source or binary form) with the major
323 | components (compiler, kernel, and so on) of the operating system on
324 | which the executable runs, unless that component itself accompanies
325 | the executable.
326 |
327 | It may happen that this requirement contradicts the license
328 | restrictions of other proprietary libraries that do not normally
329 | accompany the operating system. Such a contradiction means you cannot
330 | use both them and the Library together in an executable that you
331 | distribute.
332 |
333 | 7. You may place library facilities that are a work based on the
334 | Library side-by-side in a single library together with other library
335 | facilities not covered by this License, and distribute such a combined
336 | library, provided that the separate distribution of the work based on
337 | the Library and of the other library facilities is otherwise
338 | permitted, and provided that you do these two things:
339 |
340 | a) Accompany the combined library with a copy of the same work
341 | based on the Library, uncombined with any other library
342 | facilities. This must be distributed under the terms of the
343 | Sections above.
344 |
345 | b) Give prominent notice with the combined library of the fact
346 | that part of it is a work based on the Library, and explaining
347 | where to find the accompanying uncombined form of the same work.
348 |
349 | 8. You may not copy, modify, sublicense, link with, or distribute
350 | the Library except as expressly provided under this License. Any
351 | attempt otherwise to copy, modify, sublicense, link with, or
352 | distribute the Library is void, and will automatically terminate your
353 | rights under this License. However, parties who have received copies,
354 | or rights, from you under this License will not have their licenses
355 | terminated so long as such parties remain in full compliance.
356 |
357 | 9. You are not required to accept this License, since you have not
358 | signed it. However, nothing else grants you permission to modify or
359 | distribute the Library or its derivative works. These actions are
360 | prohibited by law if you do not accept this License. Therefore, by
361 | modifying or distributing the Library (or any work based on the
362 | Library), you indicate your acceptance of this License to do so, and
363 | all its terms and conditions for copying, distributing or modifying
364 | the Library or works based on it.
365 |
366 | 10. Each time you redistribute the Library (or any work based on the
367 | Library), the recipient automatically receives a license from the
368 | original licensor to copy, distribute, link with or modify the Library
369 | subject to these terms and conditions. You may not impose any further
370 | restrictions on the recipients' exercise of the rights granted herein.
371 | You are not responsible for enforcing compliance by third parties with
372 | this License.
373 |
374 | 11. If, as a consequence of a court judgment or allegation of patent
375 | infringement or for any other reason (not limited to patent issues),
376 | conditions are imposed on you (whether by court order, agreement or
377 | otherwise) that contradict the conditions of this License, they do not
378 | excuse you from the conditions of this License. If you cannot
379 | distribute so as to satisfy simultaneously your obligations under this
380 | License and any other pertinent obligations, then as a consequence you
381 | may not distribute the Library at all. For example, if a patent
382 | license would not permit royalty-free redistribution of the Library by
383 | all those who receive copies directly or indirectly through you, then
384 | the only way you could satisfy both it and this License would be to
385 | refrain entirely from distribution of the Library.
386 |
387 | If any portion of this section is held invalid or unenforceable under any
388 | particular circumstance, the balance of the section is intended to apply,
389 | and the section as a whole is intended to apply in other circumstances.
390 |
391 | It is not the purpose of this section to induce you to infringe any
392 | patents or other property right claims or to contest validity of any
393 | such claims; this section has the sole purpose of protecting the
394 | integrity of the free software distribution system which is
395 | implemented by public license practices. Many people have made
396 | generous contributions to the wide range of software distributed
397 | through that system in reliance on consistent application of that
398 | system; it is up to the author/donor to decide if he or she is willing
399 | to distribute software through any other system and a licensee cannot
400 | impose that choice.
401 |
402 | This section is intended to make thoroughly clear what is believed to
403 | be a consequence of the rest of this License.
404 |
405 | 12. If the distribution and/or use of the Library is restricted in
406 | certain countries either by patents or by copyrighted interfaces, the
407 | original copyright holder who places the Library under this License may add
408 | an explicit geographical distribution limitation excluding those countries,
409 | so that distribution is permitted only in or among countries not thus
410 | excluded. In such case, this License incorporates the limitation as if
411 | written in the body of this License.
412 |
413 | 13. The Free Software Foundation may publish revised and/or new
414 | versions of the Lesser General Public License from time to time.
415 | Such new versions will be similar in spirit to the present version,
416 | but may differ in detail to address new problems or concerns.
417 |
418 | Each version is given a distinguishing version number. If the Library
419 | specifies a version number of this License which applies to it and
420 | "any later version", you have the option of following the terms and
421 | conditions either of that version or of any later version published by
422 | the Free Software Foundation. If the Library does not specify a
423 | license version number, you may choose any version ever published by
424 | the Free Software Foundation.
425 |
426 | 14. If you wish to incorporate parts of the Library into other free
427 | programs whose distribution conditions are incompatible with these,
428 | write to the author to ask for permission. For software which is
429 | copyrighted by the Free Software Foundation, write to the Free
430 | Software Foundation; we sometimes make exceptions for this. Our
431 | decision will be guided by the two goals of preserving the free status
432 | of all derivatives of our free software and of promoting the sharing
433 | and reuse of software generally.
434 |
435 | NO WARRANTY
436 |
437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
446 |
447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
456 | DAMAGES.
457 |
458 | END OF TERMS AND CONDITIONS
459 |
460 | How to Apply These Terms to Your New Libraries
461 |
462 | If you develop a new library, and you want it to be of the greatest
463 | possible use to the public, we recommend making it free software that
464 | everyone can redistribute and change. You can do so by permitting
465 | redistribution under these terms (or, alternatively, under the terms of the
466 | ordinary General Public License).
467 |
468 | To apply these terms, attach the following notices to the library. It is
469 | safest to attach them to the start of each source file to most effectively
470 | convey the exclusion of warranty; and each file should have at least the
471 | "copyright" line and a pointer to where the full notice is found.
472 |
473 | {description}
474 | Copyright (C) {year} {fullname}
475 |
476 | This library is free software; you can redistribute it and/or
477 | modify it under the terms of the GNU Lesser General Public
478 | License as published by the Free Software Foundation; either
479 | version 2.1 of the License, or (at your option) any later version.
480 |
481 | This library is distributed in the hope that it will be useful,
482 | but WITHOUT ANY WARRANTY; without even the implied warranty of
483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
484 | Lesser General Public License for more details.
485 |
486 | You should have received a copy of the GNU Lesser General Public
487 | License along with this library; if not, write to the Free Software
488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
489 | USA
490 |
491 | Also add information on how to contact you by electronic and paper mail.
492 |
493 | You should also get your employer (if you work as a programmer) or your
494 | school, if any, to sign a "copyright disclaimer" for the library, if
495 | necessary. Here is a sample; alter the names:
496 |
497 | Yoyodyne, Inc., hereby disclaims all copyright interest in the
498 | library `Frob' (a library for tweaking knobs) written by James Random
499 | Hacker.
500 |
501 | {signature of Ty Coon}, 1 April 1990
502 | Ty Coon, President of Vice
503 |
504 | That's all there is to it!
505 |
--------------------------------------------------------------------------------
/lgpl-2.1.txt:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 2.1, February 1999
3 |
4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | [This is the first released version of the Lesser GPL. It also counts
10 | as the successor of the GNU Library Public License, version 2, hence
11 | the version number 2.1.]
12 |
13 | Preamble
14 |
15 | The licenses for most software are designed to take away your
16 | freedom to share and change it. By contrast, the GNU General Public
17 | Licenses are intended to guarantee your freedom to share and change
18 | free software--to make sure the software is free for all its users.
19 |
20 | This license, the Lesser General Public License, applies to some
21 | specially designated software packages--typically libraries--of the
22 | Free Software Foundation and other authors who decide to use it. You
23 | can use it too, but we suggest you first think carefully about whether
24 | this license or the ordinary General Public License is the better
25 | strategy to use in any particular case, based on the explanations below.
26 |
27 | When we speak of free software, we are referring to freedom of use,
28 | not price. Our General Public Licenses are designed to make sure that
29 | you have the freedom to distribute copies of free software (and charge
30 | for this service if you wish); that you receive source code or can get
31 | it if you want it; that you can change the software and use pieces of
32 | it in new free programs; and that you are informed that you can do
33 | these things.
34 |
35 | To protect your rights, we need to make restrictions that forbid
36 | distributors to deny you these rights or to ask you to surrender these
37 | rights. These restrictions translate to certain responsibilities for
38 | you if you distribute copies of the library or if you modify it.
39 |
40 | For example, if you distribute copies of the library, whether gratis
41 | or for a fee, you must give the recipients all the rights that we gave
42 | you. You must make sure that they, too, receive or can get the source
43 | code. If you link other code with the library, you must provide
44 | complete object files to the recipients, so that they can relink them
45 | with the library after making changes to the library and recompiling
46 | it. And you must show them these terms so they know their rights.
47 |
48 | We protect your rights with a two-step method: (1) we copyright the
49 | library, and (2) we offer you this license, which gives you legal
50 | permission to copy, distribute and/or modify the library.
51 |
52 | To protect each distributor, we want to make it very clear that
53 | there is no warranty for the free library. Also, if the library is
54 | modified by someone else and passed on, the recipients should know
55 | that what they have is not the original version, so that the original
56 | author's reputation will not be affected by problems that might be
57 | introduced by others.
58 |
59 | Finally, software patents pose a constant threat to the existence of
60 | any free program. We wish to make sure that a company cannot
61 | effectively restrict the users of a free program by obtaining a
62 | restrictive license from a patent holder. Therefore, we insist that
63 | any patent license obtained for a version of the library must be
64 | consistent with the full freedom of use specified in this license.
65 |
66 | Most GNU software, including some libraries, is covered by the
67 | ordinary GNU General Public License. This license, the GNU Lesser
68 | General Public License, applies to certain designated libraries, and
69 | is quite different from the ordinary General Public License. We use
70 | this license for certain libraries in order to permit linking those
71 | libraries into non-free programs.
72 |
73 | When a program is linked with a library, whether statically or using
74 | a shared library, the combination of the two is legally speaking a
75 | combined work, a derivative of the original library. The ordinary
76 | General Public License therefore permits such linking only if the
77 | entire combination fits its criteria of freedom. The Lesser General
78 | Public License permits more lax criteria for linking other code with
79 | the library.
80 |
81 | We call this license the "Lesser" General Public License because it
82 | does Less to protect the user's freedom than the ordinary General
83 | Public License. It also provides other free software developers Less
84 | of an advantage over competing non-free programs. These disadvantages
85 | are the reason we use the ordinary General Public License for many
86 | libraries. However, the Lesser license provides advantages in certain
87 | special circumstances.
88 |
89 | For example, on rare occasions, there may be a special need to
90 | encourage the widest possible use of a certain library, so that it becomes
91 | a de-facto standard. To achieve this, non-free programs must be
92 | allowed to use the library. A more frequent case is that a free
93 | library does the same job as widely used non-free libraries. In this
94 | case, there is little to gain by limiting the free library to free
95 | software only, so we use the Lesser General Public License.
96 |
97 | In other cases, permission to use a particular library in non-free
98 | programs enables a greater number of people to use a large body of
99 | free software. For example, permission to use the GNU C Library in
100 | non-free programs enables many more people to use the whole GNU
101 | operating system, as well as its variant, the GNU/Linux operating
102 | system.
103 |
104 | Although the Lesser General Public License is Less protective of the
105 | users' freedom, it does ensure that the user of a program that is
106 | linked with the Library has the freedom and the wherewithal to run
107 | that program using a modified version of the Library.
108 |
109 | The precise terms and conditions for copying, distribution and
110 | modification follow. Pay close attention to the difference between a
111 | "work based on the library" and a "work that uses the library". The
112 | former contains code derived from the library, whereas the latter must
113 | be combined with the library in order to run.
114 |
115 | GNU LESSER GENERAL PUBLIC LICENSE
116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
117 |
118 | 0. This License Agreement applies to any software library or other
119 | program which contains a notice placed by the copyright holder or
120 | other authorized party saying it may be distributed under the terms of
121 | this Lesser General Public License (also called "this License").
122 | Each licensee is addressed as "you".
123 |
124 | A "library" means a collection of software functions and/or data
125 | prepared so as to be conveniently linked with application programs
126 | (which use some of those functions and data) to form executables.
127 |
128 | The "Library", below, refers to any such software library or work
129 | which has been distributed under these terms. A "work based on the
130 | Library" means either the Library or any derivative work under
131 | copyright law: that is to say, a work containing the Library or a
132 | portion of it, either verbatim or with modifications and/or translated
133 | straightforwardly into another language. (Hereinafter, translation is
134 | included without limitation in the term "modification".)
135 |
136 | "Source code" for a work means the preferred form of the work for
137 | making modifications to it. For a library, complete source code means
138 | all the source code for all modules it contains, plus any associated
139 | interface definition files, plus the scripts used to control compilation
140 | and installation of the library.
141 |
142 | Activities other than copying, distribution and modification are not
143 | covered by this License; they are outside its scope. The act of
144 | running a program using the Library is not restricted, and output from
145 | such a program is covered only if its contents constitute a work based
146 | on the Library (independent of the use of the Library in a tool for
147 | writing it). Whether that is true depends on what the Library does
148 | and what the program that uses the Library does.
149 |
150 | 1. You may copy and distribute verbatim copies of the Library's
151 | complete source code as you receive it, in any medium, provided that
152 | you conspicuously and appropriately publish on each copy an
153 | appropriate copyright notice and disclaimer of warranty; keep intact
154 | all the notices that refer to this License and to the absence of any
155 | warranty; and distribute a copy of this License along with the
156 | Library.
157 |
158 | You may charge a fee for the physical act of transferring a copy,
159 | and you may at your option offer warranty protection in exchange for a
160 | fee.
161 |
162 | 2. You may modify your copy or copies of the Library or any portion
163 | of it, thus forming a work based on the Library, and copy and
164 | distribute such modifications or work under the terms of Section 1
165 | above, provided that you also meet all of these conditions:
166 |
167 | a) The modified work must itself be a software library.
168 |
169 | b) You must cause the files modified to carry prominent notices
170 | stating that you changed the files and the date of any change.
171 |
172 | c) You must cause the whole of the work to be licensed at no
173 | charge to all third parties under the terms of this License.
174 |
175 | d) If a facility in the modified Library refers to a function or a
176 | table of data to be supplied by an application program that uses
177 | the facility, other than as an argument passed when the facility
178 | is invoked, then you must make a good faith effort to ensure that,
179 | in the event an application does not supply such function or
180 | table, the facility still operates, and performs whatever part of
181 | its purpose remains meaningful.
182 |
183 | (For example, a function in a library to compute square roots has
184 | a purpose that is entirely well-defined independent of the
185 | application. Therefore, Subsection 2d requires that any
186 | application-supplied function or table used by this function must
187 | be optional: if the application does not supply it, the square
188 | root function must still compute square roots.)
189 |
190 | These requirements apply to the modified work as a whole. If
191 | identifiable sections of that work are not derived from the Library,
192 | and can be reasonably considered independent and separate works in
193 | themselves, then this License, and its terms, do not apply to those
194 | sections when you distribute them as separate works. But when you
195 | distribute the same sections as part of a whole which is a work based
196 | on the Library, the distribution of the whole must be on the terms of
197 | this License, whose permissions for other licensees extend to the
198 | entire whole, and thus to each and every part regardless of who wrote
199 | it.
200 |
201 | Thus, it is not the intent of this section to claim rights or contest
202 | your rights to work written entirely by you; rather, the intent is to
203 | exercise the right to control the distribution of derivative or
204 | collective works based on the Library.
205 |
206 | In addition, mere aggregation of another work not based on the Library
207 | with the Library (or with a work based on the Library) on a volume of
208 | a storage or distribution medium does not bring the other work under
209 | the scope of this License.
210 |
211 | 3. You may opt to apply the terms of the ordinary GNU General Public
212 | License instead of this License to a given copy of the Library. To do
213 | this, you must alter all the notices that refer to this License, so
214 | that they refer to the ordinary GNU General Public License, version 2,
215 | instead of to this License. (If a newer version than version 2 of the
216 | ordinary GNU General Public License has appeared, then you can specify
217 | that version instead if you wish.) Do not make any other change in
218 | these notices.
219 |
220 | Once this change is made in a given copy, it is irreversible for
221 | that copy, so the ordinary GNU General Public License applies to all
222 | subsequent copies and derivative works made from that copy.
223 |
224 | This option is useful when you wish to copy part of the code of
225 | the Library into a program that is not a library.
226 |
227 | 4. You may copy and distribute the Library (or a portion or
228 | derivative of it, under Section 2) in object code or executable form
229 | under the terms of Sections 1 and 2 above provided that you accompany
230 | it with the complete corresponding machine-readable source code, which
231 | must be distributed under the terms of Sections 1 and 2 above on a
232 | medium customarily used for software interchange.
233 |
234 | If distribution of object code is made by offering access to copy
235 | from a designated place, then offering equivalent access to copy the
236 | source code from the same place satisfies the requirement to
237 | distribute the source code, even though third parties are not
238 | compelled to copy the source along with the object code.
239 |
240 | 5. A program that contains no derivative of any portion of the
241 | Library, but is designed to work with the Library by being compiled or
242 | linked with it, is called a "work that uses the Library". Such a
243 | work, in isolation, is not a derivative work of the Library, and
244 | therefore falls outside the scope of this License.
245 |
246 | However, linking a "work that uses the Library" with the Library
247 | creates an executable that is a derivative of the Library (because it
248 | contains portions of the Library), rather than a "work that uses the
249 | library". The executable is therefore covered by this License.
250 | Section 6 states terms for distribution of such executables.
251 |
252 | When a "work that uses the Library" uses material from a header file
253 | that is part of the Library, the object code for the work may be a
254 | derivative work of the Library even though the source code is not.
255 | Whether this is true is especially significant if the work can be
256 | linked without the Library, or if the work is itself a library. The
257 | threshold for this to be true is not precisely defined by law.
258 |
259 | If such an object file uses only numerical parameters, data
260 | structure layouts and accessors, and small macros and small inline
261 | functions (ten lines or less in length), then the use of the object
262 | file is unrestricted, regardless of whether it is legally a derivative
263 | work. (Executables containing this object code plus portions of the
264 | Library will still fall under Section 6.)
265 |
266 | Otherwise, if the work is a derivative of the Library, you may
267 | distribute the object code for the work under the terms of Section 6.
268 | Any executables containing that work also fall under Section 6,
269 | whether or not they are linked directly with the Library itself.
270 |
271 | 6. As an exception to the Sections above, you may also combine or
272 | link a "work that uses the Library" with the Library to produce a
273 | work containing portions of the Library, and distribute that work
274 | under terms of your choice, provided that the terms permit
275 | modification of the work for the customer's own use and reverse
276 | engineering for debugging such modifications.
277 |
278 | You must give prominent notice with each copy of the work that the
279 | Library is used in it and that the Library and its use are covered by
280 | this License. You must supply a copy of this License. If the work
281 | during execution displays copyright notices, you must include the
282 | copyright notice for the Library among them, as well as a reference
283 | directing the user to the copy of this License. Also, you must do one
284 | of these things:
285 |
286 | a) Accompany the work with the complete corresponding
287 | machine-readable source code for the Library including whatever
288 | changes were used in the work (which must be distributed under
289 | Sections 1 and 2 above); and, if the work is an executable linked
290 | with the Library, with the complete machine-readable "work that
291 | uses the Library", as object code and/or source code, so that the
292 | user can modify the Library and then relink to produce a modified
293 | executable containing the modified Library. (It is understood
294 | that the user who changes the contents of definitions files in the
295 | Library will not necessarily be able to recompile the application
296 | to use the modified definitions.)
297 |
298 | b) Use a suitable shared library mechanism for linking with the
299 | Library. A suitable mechanism is one that (1) uses at run time a
300 | copy of the library already present on the user's computer system,
301 | rather than copying library functions into the executable, and (2)
302 | will operate properly with a modified version of the library, if
303 | the user installs one, as long as the modified version is
304 | interface-compatible with the version that the work was made with.
305 |
306 | c) Accompany the work with a written offer, valid for at
307 | least three years, to give the same user the materials
308 | specified in Subsection 6a, above, for a charge no more
309 | than the cost of performing this distribution.
310 |
311 | d) If distribution of the work is made by offering access to copy
312 | from a designated place, offer equivalent access to copy the above
313 | specified materials from the same place.
314 |
315 | e) Verify that the user has already received a copy of these
316 | materials or that you have already sent this user a copy.
317 |
318 | For an executable, the required form of the "work that uses the
319 | Library" must include any data and utility programs needed for
320 | reproducing the executable from it. However, as a special exception,
321 | the materials to be distributed need not include anything that is
322 | normally distributed (in either source or binary form) with the major
323 | components (compiler, kernel, and so on) of the operating system on
324 | which the executable runs, unless that component itself accompanies
325 | the executable.
326 |
327 | It may happen that this requirement contradicts the license
328 | restrictions of other proprietary libraries that do not normally
329 | accompany the operating system. Such a contradiction means you cannot
330 | use both them and the Library together in an executable that you
331 | distribute.
332 |
333 | 7. You may place library facilities that are a work based on the
334 | Library side-by-side in a single library together with other library
335 | facilities not covered by this License, and distribute such a combined
336 | library, provided that the separate distribution of the work based on
337 | the Library and of the other library facilities is otherwise
338 | permitted, and provided that you do these two things:
339 |
340 | a) Accompany the combined library with a copy of the same work
341 | based on the Library, uncombined with any other library
342 | facilities. This must be distributed under the terms of the
343 | Sections above.
344 |
345 | b) Give prominent notice with the combined library of the fact
346 | that part of it is a work based on the Library, and explaining
347 | where to find the accompanying uncombined form of the same work.
348 |
349 | 8. You may not copy, modify, sublicense, link with, or distribute
350 | the Library except as expressly provided under this License. Any
351 | attempt otherwise to copy, modify, sublicense, link with, or
352 | distribute the Library is void, and will automatically terminate your
353 | rights under this License. However, parties who have received copies,
354 | or rights, from you under this License will not have their licenses
355 | terminated so long as such parties remain in full compliance.
356 |
357 | 9. You are not required to accept this License, since you have not
358 | signed it. However, nothing else grants you permission to modify or
359 | distribute the Library or its derivative works. These actions are
360 | prohibited by law if you do not accept this License. Therefore, by
361 | modifying or distributing the Library (or any work based on the
362 | Library), you indicate your acceptance of this License to do so, and
363 | all its terms and conditions for copying, distributing or modifying
364 | the Library or works based on it.
365 |
366 | 10. Each time you redistribute the Library (or any work based on the
367 | Library), the recipient automatically receives a license from the
368 | original licensor to copy, distribute, link with or modify the Library
369 | subject to these terms and conditions. You may not impose any further
370 | restrictions on the recipients' exercise of the rights granted herein.
371 | You are not responsible for enforcing compliance by third parties with
372 | this License.
373 |
374 | 11. If, as a consequence of a court judgment or allegation of patent
375 | infringement or for any other reason (not limited to patent issues),
376 | conditions are imposed on you (whether by court order, agreement or
377 | otherwise) that contradict the conditions of this License, they do not
378 | excuse you from the conditions of this License. If you cannot
379 | distribute so as to satisfy simultaneously your obligations under this
380 | License and any other pertinent obligations, then as a consequence you
381 | may not distribute the Library at all. For example, if a patent
382 | license would not permit royalty-free redistribution of the Library by
383 | all those who receive copies directly or indirectly through you, then
384 | the only way you could satisfy both it and this License would be to
385 | refrain entirely from distribution of the Library.
386 |
387 | If any portion of this section is held invalid or unenforceable under any
388 | particular circumstance, the balance of the section is intended to apply,
389 | and the section as a whole is intended to apply in other circumstances.
390 |
391 | It is not the purpose of this section to induce you to infringe any
392 | patents or other property right claims or to contest validity of any
393 | such claims; this section has the sole purpose of protecting the
394 | integrity of the free software distribution system which is
395 | implemented by public license practices. Many people have made
396 | generous contributions to the wide range of software distributed
397 | through that system in reliance on consistent application of that
398 | system; it is up to the author/donor to decide if he or she is willing
399 | to distribute software through any other system and a licensee cannot
400 | impose that choice.
401 |
402 | This section is intended to make thoroughly clear what is believed to
403 | be a consequence of the rest of this License.
404 |
405 | 12. If the distribution and/or use of the Library is restricted in
406 | certain countries either by patents or by copyrighted interfaces, the
407 | original copyright holder who places the Library under this License may add
408 | an explicit geographical distribution limitation excluding those countries,
409 | so that distribution is permitted only in or among countries not thus
410 | excluded. In such case, this License incorporates the limitation as if
411 | written in the body of this License.
412 |
413 | 13. The Free Software Foundation may publish revised and/or new
414 | versions of the Lesser General Public License from time to time.
415 | Such new versions will be similar in spirit to the present version,
416 | but may differ in detail to address new problems or concerns.
417 |
418 | Each version is given a distinguishing version number. If the Library
419 | specifies a version number of this License which applies to it and
420 | "any later version", you have the option of following the terms and
421 | conditions either of that version or of any later version published by
422 | the Free Software Foundation. If the Library does not specify a
423 | license version number, you may choose any version ever published by
424 | the Free Software Foundation.
425 |
426 | 14. If you wish to incorporate parts of the Library into other free
427 | programs whose distribution conditions are incompatible with these,
428 | write to the author to ask for permission. For software which is
429 | copyrighted by the Free Software Foundation, write to the Free
430 | Software Foundation; we sometimes make exceptions for this. Our
431 | decision will be guided by the two goals of preserving the free status
432 | of all derivatives of our free software and of promoting the sharing
433 | and reuse of software generally.
434 |
435 | NO WARRANTY
436 |
437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
446 |
447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
456 | DAMAGES.
457 |
458 | END OF TERMS AND CONDITIONS
459 |
460 | How to Apply These Terms to Your New Libraries
461 |
462 | If you develop a new library, and you want it to be of the greatest
463 | possible use to the public, we recommend making it free software that
464 | everyone can redistribute and change. You can do so by permitting
465 | redistribution under these terms (or, alternatively, under the terms of the
466 | ordinary General Public License).
467 |
468 | To apply these terms, attach the following notices to the library. It is
469 | safest to attach them to the start of each source file to most effectively
470 | convey the exclusion of warranty; and each file should have at least the
471 | "copyright" line and a pointer to where the full notice is found.
472 |
473 |
474 | Copyright (C)
475 |
476 | This library is free software; you can redistribute it and/or
477 | modify it under the terms of the GNU Lesser General Public
478 | License as published by the Free Software Foundation; either
479 | version 2.1 of the License, or (at your option) any later version.
480 |
481 | This library is distributed in the hope that it will be useful,
482 | but WITHOUT ANY WARRANTY; without even the implied warranty of
483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
484 | Lesser General Public License for more details.
485 |
486 | You should have received a copy of the GNU Lesser General Public
487 | License along with this library; if not, write to the Free Software
488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
489 |
490 | Also add information on how to contact you by electronic and paper mail.
491 |
492 | You should also get your employer (if you work as a programmer) or your
493 | school, if any, to sign a "copyright disclaimer" for the library, if
494 | necessary. Here is a sample; alter the names:
495 |
496 | Yoyodyne, Inc., hereby disclaims all copyright interest in the
497 | library `Frob' (a library for tweaking knobs) written by James Random Hacker.
498 |
499 | , 1 April 1990
500 | Ty Coon, President of Vice
501 |
502 | That's all there is to it!
503 |
--------------------------------------------------------------------------------
/ReadMe.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | GroundTraffic
10 |
26 |
27 |
28 |
29 |
This kit enables X-Plane scenery designers to add animated ground vehicle traffic to airport scenery packages. It requires X-Plane 10.0 or later.
43 |
44 |
How it works
45 |
This kit supplies a plugin that you can distribute with your scenery package. The plugin reads instructions from a text file that you create (and which you should also distribute with your scenery package) and animates X-Plane scenery objects according to those instructions. The objects to be animated can come from X-Plane's built-in library, from an add-on object library (e.g.OpenSceneryX), or from your scenery package.
46 |
47 |
Installation
48 |
49 |
50 |
Create a folder named plugins within your scenery package folder.
51 |
Copy the GroundTraffic folder from this kit into the plugins folder.
52 |
Don't copy this ReadMe.html file into your scenery package - this file is intended for you as a scenery designer and would likely confuse users of your scenery package.
53 |
54 |
55 |
Animation instructions
56 |
57 |
Use Notepad, TextEdit, or any other text editor to create a plain text file named GroundTraffic.txt in your scenery package folder. Save this blank file with an “ANSI”, “Western” or “UTF-8” encoding. (If using TextEdit, you may have to first choose Format → Make Plain Text to see those choices).
58 |
Add one or more “Routes” and/or “Highways” to this file and, optionally, a “Water” statement, “Debug” statement, and/or comments.
59 |
60 |
Water
61 |
The Water statement tells the plugin that some or all of your routes are on water. In practice this causes the plugin to activate sooner as the user approaches the airport (since you can see things at sea from a large distance) and, when “water reflection detail” is set to “medium” or above under X-Plane's Rendering Options, to draw objects with reflections. There is a performance cost to both of these activities, so don't use this statement unless you need to.
62 |
The Water statement just consists of the word “water” and should be preceded by a blank line:
The Debug statement tells the plugin to display and label routes; each waypoint is labelled with its sequence number, and each animated object is labelled with its line number from GroundTraffic.txt, its last waypoint and, if waiting, the reason why it is waiting. This is useful for checking that your routes' waypoints are at the locations that you intended and for investigating traffic jams.
70 |
The Debug statement just consists of the word “debug” and should be preceded by a blank line:
71 |
72 |
73 | debug
74 |
75 |
76 |
Comment
77 |
Lines starting with “#” are treated as comments and are ignored. For example:
A Route statement starts a new animation. It should be of the form “route speed offset heading object”, where:
82 |
83 |
speed
84 |
The speed of the animated object, in km/h.
85 |
offset
86 |
Offset in metres to shift the object forwards before animation.
87 |
heading
88 |
Rotation in degrees to be applied to the object before animation.
89 |
object
90 |
The name of the animated object. This can be the name of a library object from X-Plane's built-in library or from an add-on library, the name of an object in your scenery package, or the name of a “Train”. Note that library object and train names are case-sensitive.
91 |
92 |
For the animation to look correct objects should be modelled such that they are pointing North and are roughly centered at their origin (since the plugin rotates them about their origin).
93 |
94 |
If using your own objects, design them so they are pointing North (i.e. along the positive green axis in SketchUp or Blender), sitting at or just slightly below ground level to allow for sloped terrain, and centered at or a little forward of their axes' origin. Use 0 for the “offset” and “heading” values in this statement.
95 |
Objects in X-Plane's built-in library tend to be centered at their origin but are not all pointing North; supply a “heading” value to rotate such objects.
96 |
Objects in the OpenSceneryX library all point North but are not centered at their origin; supply an “offset” value of at least half the length of the object to correct for this.
97 |
For trains of objects, supply desired “offset” and “heading” values in the train Car statement; the values supplied here are not used.
98 |
99 |
For example, a route using an object from the scenery package, travelling at 30km/h (~18mph):
The Route statement should be preceded by a blank line and should be followed by a sequence of “waypoints” and “commands”. The Route ends with a blank line.
Animated objects move from one waypoint to the next at the speed specified in the Route statement. When the object passes the last waypoint it proceeds towards the first waypoint, forming a circular route (unless you specify a “reverse” command). Objects will wait at a waypoint if moving on would risk colliding with another object or getting in the way of an aircraft; refer to the guidance below if you plan to have routes that overlap with each other or with aircraft taxi paths.
118 |
Waypoints should be of the form “lat lon”. For example:
119 |
...
120 | 47.4484450 -122.3001950
121 | ...
122 |
You can use OverlayEditor or WED to map out your route, typing the the waypoint locations into GroundTraffic.txt as you go. You may also want to consider placing a “line” (e.g. one of opensceneryx/lines/airport/zone_outlines/...) in OverlayEditor or WED to record your route; this will make it easier if you want to adjust your route in the future. But remember to remove or hide these lines before publishing your scenery package.
123 |
Alternatively, you can use online mapping tools such as this to map out your route.
124 |
You can use the Debug statement to visualise your routes in X-Plane.
125 |
126 |
Pause command
127 |
The Pause command instructs the animated object to wait at the preceding waypoint for a while before moving on. Optionally, you can cause the value of a DataRef to change while the animated object is waiting, and change back before it proceeds.
128 |
The Pause command should be of the form “pause time set name slope curve duration”, where:
Waiting at a waypoint for one minute while setting the value of the DataRef marginal/groundtraffic/var[0] such that it rises from 0 to 1 over five seconds, stays at 1, then starts going back to 0 five seconds before the object proceeds:
141 |
...
142 | 47.4380074 -122.3040742
143 | pause 60 set var[0] rise linear 5
144 | ...
145 |
146 |
147 |
At command
148 |
The At command instructs the animated object to wait at the preceeding waypoint until a particular time of day. It should be of the form “at HH:MM on days”, where:
149 |
150 |
HH:MM
151 |
Times of day at which to proceed with the animation. Up to 24 times can be specified, in local time, and using a 24 hour clock.
152 |
on days (optional)
153 |
Days on which to proceed with the animation. Specified in English.
An animation that waits until 8am or 8pm on a weekday:
161 |
...
162 | 47.4559849 -122.3028592
163 | at 08:00 20:00 on Mon Tue Wed Thu Fri
164 | ...
165 |
166 |
Backup command
167 |
The Backup command instructs the animated object to reverse from the preceding waypoint as far as the next waypoint, and thereafter move forward as normal. If the preceding waypoint also has a Pause command the object points forwards while waiting, and then backs-up after waiting.
168 |
The Backup command just consists of the word “backup”.
For best results the waypoints before and after backing-up should be at the same location, as in the above examples, or at least in a straight line.
188 |
189 |
Normally, when the animated object passes the last waypoint it proceeds towards the first waypoint, forming a circular route. The Reverse command instead instructs the object to change direction at the last waypoint and re-trace its steps.
191 |
The Reverse command just consists of the word “reverse” and must be at the end of the Route. For example:
192 |
...
193 | reverse
194 |
195 |
196 |
Note: You can't use the Reverse command in a route that contains Backup commands.
The Set command causes the value of a DataRef to change when the animated object arrives at the preceding waypoint. It should be of the form “set name slope curve duration”, where:
200 |
201 |
name
202 |
var[0] ... var[9] or the name of a custom DataRef.
203 |
slope
204 |
rise or fall - whether the value the DataRef rises from 0.0 to 1.0, or falls from 1.0 to 0.0.
205 |
curve
206 |
linear or sine - whether the value the DataRef changes linearly or like ∫ over the duration.
207 |
duration
208 |
The time in seconds that the DataRef takes to change value. This can be 0 if you want the DataRef to change value instantly.
209 |
210 |
If you specify a name of the form var[n] then this command controls the “array” DataRef marginal/groundtraffic/var[n], which can be used to drive animations in a 3D modelling application that supports X-Plane animations. Each object will see values for this DataRef that are specific to the route that the object is following; so it is safe to re-use this DataRef across different objects and routes. For example, within one GroundTraffic.txt file, you could use marginal/groundtraffic/var[0] to control an animated belt in one or more beltloader objects, and also use marginal/groundtraffic/var[0] to control a refueling animation in one or more fuel truck objects. However, because the values returned for this DataRef are specific to a route, you can't usefully use it in a static object that is placed conventionally within an X-Plane scenery package.
211 |
Alternatively you can specify the name of a custom DataRef of your choice, but which should be unique to this scenery package. This DataRef can be used to animate objects that are used in a route and/or static objects that are placed conventionally within an X-Plane scenery package. Because all objects (either static or animated by this plugin) will see the same value for your custom DataRef it doesn't make sense to set the same custom DataRef in more than one route.
212 |
For example, setting the value of the DataRef marginal/groundtraffic/var[1] such that it rises from 0 to 1 over five seconds on hitting a waypoint:
213 |
...
214 | 47.4380074 -122.3040742
215 | set var[1] rise linear 5
216 | ...
217 |
218 |
Setting the value of a custom DataRef such that it falls from 1 to 0 over two seconds on hitting a waypoint:
219 |
...
220 | 47.4348578 -122.3034624
221 | set my/custom/dataref fall sine 2
222 | ...
223 |
224 |
The “Pause ... set” command also supports changing the value of a custom DataRef when the animated object arrives at a waypoint. The “Pause ... set” command restores the DataRef to its previous value before the object moves on from the waypoint; this command does not.
The When command instructs the animated object to wait at the preceeding waypoint until a DataRef is within a specified range. It should be of the form “when name from to”, where:
228 |
229 |
name
230 |
The name of a DataRef published by the sim, the name of a custom DataRef published by the “Set” or “Pause ... set” commands in this plugin, or the name of a custom DataRef published by another plugin. To access an array DataRef, append the array index within square brackets “[n]” to the name.
231 |
from to
232 |
Range of values for the DataRef for which the animation proceeds.
233 |
234 |
For example, an animation that only takes place in daylight:
The When command can be used in conjunction with the Set command to synchronise the motions of objects on different routes. For example, to trigger an object on route B to move when the object on route A reaches a waypoint:
240 |
# route A
241 | ...
242 | # when we get to this waypoint signal the object on route B
243 | 47.4484450 -122.3001950
244 | set my/scenerypackage/signalB rise linear 0
245 | ...
246 | # reset the signal for next time around
247 | 47.4471804 -122.3023423
248 | set my/scenerypackage/signalB fall linear 0
249 | ...
250 |
251 | # route B
252 | ...
253 | # wait here until object on route A signals to us
254 | 47.4559849 -122.3028592
255 | when my/scenerypackage/signalB 1 1
256 | ...
257 |
258 |
259 |
260 |
And command
261 |
The And command can be used to add additional conditions to a When command. It should be of the form “and name from to”, where:
Instead of animating a single object along a Route, you can animate a number of objects to follow each other in succession like train cars/coaches follow their locomotive.
276 |
A Train statement starts a description of a train of connected objects. It should be of the form “train name”, where:
277 |
278 |
name
279 |
The name of your train. Use this name in a Route statement to animate this train. To avoid any ambiguity don't name your train with the same name as a library object, an object in your scenery package, or another train.
280 |
281 |
For example a suitable name for a train consisting of a tug and four luggage carts:
The Train statement should be preceded by a blank line and should be followed by a list of the “Car” statements. The Train description ends with a blank line.
287 |
288 |
Train Car
289 |
A train Car statement should be of the form “lag offset heading object”, where:
290 |
291 |
lag
292 |
Distance in metres that the object should lag behind the lead object in the train.
293 |
offset
294 |
Offset in metres to be applied to the object before animation.
295 |
heading
296 |
Rotation in degrees to be applied to the object before animation.
297 |
object
298 |
The name of the animated object. This can be the name of a library object from X-Plane's built-in library or from an add-on library, or the name of an object in your scenery package. It should not be the name of this or of another Train.
299 |
300 |
To determine how far an object should lag behind the the lead object you can open/import the objects into a 3D modelling application and measure how far (in metres) you have to move the object behind the lead object for it to appear to “link up” correctly. If either object needs an offset to be centered on its axes then adjust for this before measuring. Repeat the process for further objects.
301 |
For example a train consisting of two objects, both of which need to be rotated 180°, the second of which is 3.36m behind the first:
The plugin animates train Car objects as if they are connected to each other so don't leave huge gaps between Cars. In particular, if you want to send two or more separate objects down the same route don't (ab)use the Train statement; just duplicate the route (and optionally change the order of the waypoints in the copy/copies to space out the objects) or use a Highway.
Instead of animating a single object or train of objects, you can create a “highway” filled with a constant flow of one-way traffic. Highways are similar to Routes, except that a Highway description cannot contain any commands and traffic on a Highway does not stop to avoid collisions with other Highways or Routes.
313 |
A Highway statement starts a description of a traffic flow. It should be of the form “highway speed spacing”, where:
314 |
315 |
speed
316 |
The speed of the animated objects, in km/h.
317 |
spacing
318 |
Average distance in metres between objects when “number of cars” is at the maximum setting under X-Plane's Rendering Options. Lower settings for “number of cars” will result in a larger distance between objects.
319 |
320 |
321 |
For example a highway with traffic moving at 65km/h (~40mph) and objects every 50 metres:
322 |
323 |
324 | highway 65 50
325 | ...
326 |
The Highway statement should be preceded by a blank line and should be followed by a list of highway “Car” statements, followed by a sequence of “waypoints”. The Highway description ends with a blank line.
327 |
328 |
Highway Car
329 |
A highway Car statement should be of the form “offset heading object”, where:
330 |
331 |
offset
332 |
Offset in metres to be applied to the object before animation.
333 |
heading
334 |
Rotation in degrees to be applied to the object before animation.
335 |
object
336 |
The name of the animated object. This can be the name of a library object from X-Plane's built-in library or from an add-on library, or the name of an object in your scenery package. It should not be the name of a Train. Note that library object names are case-sensitive.
337 |
338 |
For example a mix of traffic consisting of some cars, some more cars plus some trucks, and some Ford Transit vans shifted forwards 2.5m so that they rotate about their center:
The plugin fills your highway with a random mix of the objects listed in the Car statements, so the order of the Car statements is not significant.
348 |
349 |
Highway Waypoint
350 |
Animated objects move from one waypoint to the next at the speed specified in the Highway statement. When an object passes the last waypoint it disappears.
351 |
Highway Waypoints should be of the form “lat lon”. For example:
352 |
...
353 | 47.4484450 -122.3001950
354 | ...
355 |
356 |
Animation DataRefs
357 |
358 |
The plugin publishes the following DataRefs that you can use to create animated objects in a 3D modelling application that supports X-Plane animations:
359 |
360 |
marginal/groundtraffic/distance
361 |
Distance travelled from the first waypoint, in metres. Resets to zero every time the object passes the first waypoint. See below for how to use this to animate rotating wheels.
362 |
marginal/groundtraffic/speed
363 |
Speed of the object, in metres/second. This returns zero if the object is stationary for any reason, up to the speed that you specified in the Route statement (converted to [m/s]) if it is moving, or negative if it is backing-up (which is useful for displaying reversing lights).
364 |
marginal/groundtraffic/steer
365 |
Turn rate of the object, in degrees. This returns zero if the object is moving in a straight line, and between zero and half the turn angle if the object is negotiating a turn; e.g. if the object is negotiating a right-angled turn, this will return up to ±45. This is useful for animating articulated vehicles / semi-trailer trucks.
366 |
marginal/groundtraffic/var[0] ... var[9]
367 |
DataRef whose value is controlled by the “Set” and “Pause ... set” commands.
368 |
marginal/groundtraffic/waypoint/last
369 |
The last waypoint in the Route (counting from zero) visited by the object.
370 |
marginal/groundtraffic/waypoint/last/distance
371 |
The distance from the last waypoint, in metres. This returns zero if the object is stationary at a waypoint.
372 |
marginal/groundtraffic/waypoint/next
373 |
The next waypoint in the Route (counting from zero) to be visited by the object. This is one greater than the last waypoint unless the object is reversing its route or is circling back to the first waypoint.
374 |
marginal/groundtraffic/waypoint/next/distance
375 |
The distance to the next waypoint, in metres.
376 |
377 |
These DataRefs return values specific to the route that the object is following; so they are only useful in animating objects on routes controlled by this plugin, not in static objects that are placed conventionally within an X-Plane scenery package. (You can use the “Set” and/or “Pause ... set” commands with a custom DataRef name to publish DataRefs for use in static objects). You can examine the values of these DataRefs using DataRefEditor or Data Ref Tool, but they will only display the values for the first route listed in GroundTraffic.txt.
378 |
The objects in a Train or Highway will receive different values for some of these DataRefs (e.g. the value returned by marginal/groundtraffic/distance takes into account the “lag” specified in the object's Train Car statement). But all objects in the train share the same marginal/groundtraffic/var[n] values.
379 |
380 |
Animating rotating wheels
381 |
The speed of rotation of a wheel depends on its size; a smaller wheel needs to rotate more quickly to cover a given distance than a larger wheel. So in a 3D modelling application measure the diameter of the wheel (in metres) and multiple this value by π to obtain the wheel's circumference.
382 |
Set up an animation for the wheel containing two keyframes. Rotate the wheel 90° forwards around its axle between the two keyframes. Specify the X-Plane animation values as follows:
383 |
384 |
DataRef: marginal/groundtraffic/distance
385 |
Keyframe#0: DataRef value = 0.
386 |
Keyframe#1: DataRef value = one quarter of the circumference of the wheel [m].
387 |
Loop DataRef value = the circumference of the wheel [m].
Objects will try to avoid crashing into each other by waiting at a waypoint if an object on another route is crossing ahead. So where routes cross don't leave a large distance between the waypoints on either side of the crossing point otherwise an object might have to wait for a long time for the crossing object to clear:
399 |
400 |
416 |
417 |
Similarly, objects will try to avoid getting in the way of the user's and of AI aircraft. So where a route crosses a taxi or apron path don't leave a large distance between the waypoints on either side of the crossing point.
418 |
Where two or more routes share exactly the same waypoint co-ordinates for all or part of their length this is treated as a shared path rather than as a “crossing”; objects will follow each other along the shared path without waiting for other objects to clear:
419 |
420 |
427 |
428 |
429 |
Bridges & “Hard” surfaces
430 |
431 |
The animated objects will always go over “Hard” surfaces in static objects that are placed conventionally within an X-Plane scenery package. At your choice, animated objects can be made to go over or under the bridges that are part of X-Plane's road and rail networks, and over or under “Hard Deck” surfaces in static objects.
432 |
433 |
Going over X-Plane's bridges:
434 |
Place the first waypoint in the route at ground-level. Then add waypoints such that your route follows the path of the bridge. Since objects travel in a straight line between waypoints, if the bridge is curved you will need to add sufficient waypoints to ensure that the object doesn't fall off the bridge between waypoints. Note: If you turn on Debug the waypoints are shown at ground-level, but the object will follow the bridge above unless you let it fall off.
435 |
Going over static objects:
436 |
In a 3D modelling application mark the faces of your object that represent the road surface as “Hard” if the object represents something solid (e.g. an embankment) or as “Hard Deck” if the object represents something under which traffic can cross (e.g. a bridge, overpass or elevated deck). If using “Hard Deck” note that the maximum gradient that objects will follow is 1:4 or 25%. Once you've placed the static object in your scenery package (e.g. using OverlayEditor or WED) then place your waypoints as for X-Plane's bridges.
437 |
Going under X-Plane's bridges:
438 |
Animated objects will cross under X-Plane's bridges provided that there is sufficient clearance.
439 |
Going under static objects:
440 |
Animated objects will ignore static objects (i.e. cross under them or plough right through them) unless the static object contains “Hard” and/or “Hard Deck” surfaces. Objects will cross under “Hard Deck” surfaces provided that there is sufficient clearance.
441 |
442 |
Animated objects will ignore any “Hard” and “Hard Deck” surfaces in other objects that are animated by this or by another plugin.
443 |
444 |
Troubleshooting
445 |
446 |
You can check that the plugin has been loaded and is operating correctly by opening the file Log.txt in the X-Plane folder. You should see:
If the plugin is operating correctly it produces no other output in the log. However if the plugin has a problem reading your GroundTraffic.txt file you will see one or more entries starting with “GroundTraffic:” in the log and the plugin will not perform any animation. For example:
450 |
GroundTraffic: Empty route at line 15
451 |
The plugin examines your GroundTraffic.txt file when you make a selection from the Location → Select Global Airport dialog; if you have edited the file then the plugin will re-read it and re-start the animations. Or you can force the plugin to re-read the file and re-start the animations by disabling and re-enabling it in the Plugin → Plugin Admin → Enable/Disable dialog.
This kit is licensed under the GNU LGPL v2.1 license. In short, you can distribute the plugin provided by this kit in free or commerical scenery packages providing that, in the documentation that accompanies your scenery package, you:
460 |
461 |
Include a copy of, or a link to the LGPL v2.1 license that covers the plugin.
If you modify the plugin provided by this kit you must publish the source code to your changes as specified in sections 2 and 3 of the LGPL v2.1 license.
465 |
The author would appreciate a courtesy copy of any commercial scenery that you make using this kit, but you are under no obligation.