trails in progress
Former-commit-id: 86a719985c2478b16eae3d8de543880ffa1ba95f Former-commit-id: c01b937077dc0891bc6d7b98903fb2bcbb040a9e
This commit is contained in:
parent
c28bebc294
commit
fc035a8c93
1
sdl1090/draw.aux
Normal file
1
sdl1090/draw.aux
Normal file
|
@ -0,0 +1 @@
|
||||||
|
\relax
|
101
sdl1090/draw.c
101
sdl1090/draw.c
|
@ -10,9 +10,24 @@ void CROSSVP(double *v, double *u, double *w)
|
||||||
v[2] = u[0]*w[1] - u[1]*(w)[0];
|
v[2] = u[0]*w[1] - u[1]*(w)[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawPlaneHeading(int x, int y, double heading, int signal, char *flight)
|
|
||||||
|
SDL_Point screenCoords(double dx, double dy) {
|
||||||
|
SDL_Point out;
|
||||||
|
out.x = round(320.0 * (0.5 + (dx / 64.0)));
|
||||||
|
out.y = round(240.0 * (0.5 + (dy / 48.0)));
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawPlaneHeading(double dx, double dy, double heading, int signal, char *flight)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
SDL_Point center = screenCoords(dx,dy);
|
||||||
|
|
||||||
|
if(center.x < 0 || center.x >= 320 || center.y < 0 || center.y >= 240 ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(signal > 127) {
|
if(signal > 127) {
|
||||||
signal = 127;
|
signal = 127;
|
||||||
}
|
}
|
||||||
|
@ -38,47 +53,91 @@ void drawPlaneHeading(int x, int y, double heading, int signal, char *flight)
|
||||||
|
|
||||||
//body
|
//body
|
||||||
|
|
||||||
x1 = x + round(-body*vec[0]);
|
x1 = center.x + round(-body*vec[0]);
|
||||||
y1 = y + round(-body*vec[1]);
|
y1 = center.y + round(-body*vec[1]);
|
||||||
x2 = x + round(body*vec[0]);
|
x2 = center.x + round(body*vec[0]);
|
||||||
y2 = y + round(body*vec[1]);
|
y2 = center.y + round(body*vec[1]);
|
||||||
|
|
||||||
SDL_RenderDrawLine(game.renderer, x1, y1, x2, y2);
|
SDL_RenderDrawLine(game.renderer, x1, y1, x2, y2);
|
||||||
|
|
||||||
//wing
|
//wing
|
||||||
|
|
||||||
x1 = x + round(-wing*out[0]);
|
x1 = center.x + round(-wing*out[0]);
|
||||||
y1 = y + round(-wing*out[1]);
|
y1 = center.y + round(-wing*out[1]);
|
||||||
x2 = x + round(wing*out[0]);
|
x2 = center.x + round(wing*out[0]);
|
||||||
y2 = y + round(wing*out[1]);
|
y2 = center.y + round(wing*out[1]);
|
||||||
|
|
||||||
SDL_RenderDrawLine(game.renderer, x1, y1, x2, y2);
|
SDL_RenderDrawLine(game.renderer, x1, y1, x2, y2);
|
||||||
|
|
||||||
//tail
|
//tail
|
||||||
|
|
||||||
x1 = x + round(-body*vec[0]) + round(-tail*out[0]);
|
x1 = center.x + round(-body*vec[0]) + round(-tail*out[0]);
|
||||||
y1 = y + round(-body*vec[1]) + round(-tail*out[1]);
|
y1 = center.y + round(-body*vec[1]) + round(-tail*out[1]);
|
||||||
x2 = x + round(-body*vec[0]) + round(tail*out[0]);
|
x2 = center.x + round(-body*vec[0]) + round(tail*out[0]);
|
||||||
y2 = y + round(-body*vec[1]) + round(tail*out[1]);
|
y2 = center.y + round(-body*vec[1]) + round(tail*out[1]);
|
||||||
|
|
||||||
SDL_RenderDrawLine(game.renderer, x1, y1, x2, y2);
|
SDL_RenderDrawLine(game.renderer, x1, y1, x2, y2);
|
||||||
|
|
||||||
|
SDL_Color color = { parula[signal][0], parula[signal][1], parula[signal][2], 255};
|
||||||
|
|
||||||
SDL_Color color = { parula[signal][0], parula[signal][1], parula[signal][2]};
|
drawString(flight, center.x + 10, center.y + 10, game.font, color);
|
||||||
|
|
||||||
drawString(flight, x, y - 10, game.font, color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawPlane(int x, int y, int signal)
|
void drawPlane(double dx, double dy, int signal)
|
||||||
{
|
{
|
||||||
SDL_SetRenderDrawColor(game.renderer, 255, 255, 255, SDL_ALPHA_OPAQUE);
|
|
||||||
|
SDL_Point center = screenCoords(dx,dy);
|
||||||
|
|
||||||
|
if(center.x < 0 || center.x >= 320 || center.y < 0 || center.y >= 240 ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(signal > 127) {
|
||||||
|
signal = 127;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_SetRenderDrawColor(game.renderer, parula[signal][0], parula[signal][1], parula[signal][2], SDL_ALPHA_OPAQUE);
|
||||||
|
|
||||||
int length = 3.0;
|
int length = 3.0;
|
||||||
|
|
||||||
double vec[3];
|
SDL_RenderDrawLine(game.renderer, center.x-length , center.y , center.x+length , center.y );
|
||||||
|
SDL_RenderDrawLine(game.renderer, center.x , center.y-length , center.x , center.y+length );
|
||||||
|
}
|
||||||
|
|
||||||
SDL_RenderDrawLine(game.renderer, x-length , y , x+length , y );
|
void drawTrail(double *oldDx, double *oldDy, int idx) {
|
||||||
SDL_RenderDrawLine(game.renderer, x , y-length , x , y+length );
|
int currentIdx, prevIdx;
|
||||||
|
|
||||||
|
SDL_Point current, prev;
|
||||||
|
|
||||||
|
for(int i=1; i < 32; i++) {
|
||||||
|
currentIdx = (idx - (i - 1)) % 32;
|
||||||
|
prevIdx = (idx - (i - 2)) % 32;
|
||||||
|
|
||||||
|
if(oldDx[currentIdx] == 0 && oldDy[currentIdx] == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//SDL_SetRenderDrawColor(game.renderer, (i<<3)-1, (i<<3)-1, (i<<3)-1, SDL_ALPHA_OPAQUE);
|
||||||
|
SDL_SetRenderDrawColor(game.renderer, 0,60,60, SDL_ALPHA_OPAQUE);
|
||||||
|
|
||||||
|
current = screenCoords(oldDx[currentIdx], oldDy[currentIdx]);
|
||||||
|
prev = screenCoords(oldDx[prevIdx], oldDy[prevIdx]);
|
||||||
|
|
||||||
|
if(current.x < 0 || current.x >= 320 || current.y < 0 || current.y >= 240 ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(prev.x < 0 || prev.x >= 320 || prev.y < 0 || prev.y >= 240 ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_RenderDrawLine(game.renderer, prev.x, prev.y, current.x, current.y);
|
||||||
|
|
||||||
|
SDL_SetRenderDrawColor(game.renderer, 255,0,0, SDL_ALPHA_OPAQUE);
|
||||||
|
|
||||||
|
SDL_Rect spot = {.x = current.x-1, .y = current.y-1, .w = 2, .h = 2};
|
||||||
|
SDL_RenderFillRect(game.renderer, &spot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
12
sdl1090/draw.fdb_latexmk
Normal file
12
sdl1090/draw.fdb_latexmk
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# Fdb version 3
|
||||||
|
["pdflatex"] 1505364769 "/Users/nmatsuda/Git/spidr/sdl1090/draw.c" "/Users/nmatsuda/Git/spidr/sdl1090/draw.pdf" "draw" 1505364770
|
||||||
|
"/Users/nmatsuda/Git/spidr/sdl1090/draw.aux" 1505364769 8 a94a2480d3289e625eea47cd1b285758 ""
|
||||||
|
"/Users/nmatsuda/Git/spidr/sdl1090/draw.c" 1505364769 4129 31ebf842dcce304f940dd8201c176862 ""
|
||||||
|
"/usr/local/texlive/2015/texmf-dist/web2c/texmf.cnf" 1428852030 31983 18aeec08f48baa3cf3508d538dd5f459 ""
|
||||||
|
"/usr/local/texlive/2015/texmf-var/web2c/pdftex/pdflatex.fmt" 1432479681 3849859 39a7d258195bde2394e244961601fbc5 ""
|
||||||
|
"/usr/local/texlive/2015/texmf.cnf" 1432479636 577 0d611272082f3cdb8e80e09a3c69cf07 ""
|
||||||
|
"draw.c" 1505364769 4129 31ebf842dcce304f940dd8201c176862 ""
|
||||||
|
(generated)
|
||||||
|
"/Users/nmatsuda/Git/spidr/sdl1090/draw.log"
|
||||||
|
"draw.log"
|
||||||
|
"/Users/nmatsuda/Git/spidr/sdl1090/draw.pdf"
|
6
sdl1090/draw.fls
Normal file
6
sdl1090/draw.fls
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
PWD /Users/nmatsuda/Git/spidr/sdl1090
|
||||||
|
INPUT /usr/local/texlive/2015/texmf.cnf
|
||||||
|
INPUT /usr/local/texlive/2015/texmf-dist/web2c/texmf.cnf
|
||||||
|
INPUT /usr/local/texlive/2015/texmf-var/web2c/pdftex/pdflatex.fmt
|
||||||
|
INPUT /Users/nmatsuda/Git/spidr/sdl1090/draw.c
|
||||||
|
OUTPUT /Users/nmatsuda/Git/spidr/sdl1090/draw.log
|
1
sdl1090/draw.log.REMOVED.git-id
Normal file
1
sdl1090/draw.log.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
fca1e79ced7e4bc0ee43c01bdd40d67f708ae6bb
|
1
sdl1090/dump1090.aux
Normal file
1
sdl1090/dump1090.aux
Normal file
|
@ -0,0 +1 @@
|
||||||
|
\relax
|
14
sdl1090/dump1090.fdb_latexmk
Normal file
14
sdl1090/dump1090.fdb_latexmk
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# Fdb version 3
|
||||||
|
["pdflatex"] 1505360723 "/Users/nmatsuda/Git/spidr/sdl1090/dump1090.h" "/Users/nmatsuda/Git/spidr/sdl1090/dump1090.pdf" "dump1090" 1505360725
|
||||||
|
"/Users/nmatsuda/Git/spidr/sdl1090/dump1090.aux" 1505360723 8 a94a2480d3289e625eea47cd1b285758 ""
|
||||||
|
"/Users/nmatsuda/Git/spidr/sdl1090/dump1090.h" 1505360723 21883 5718524b7196565a03bf7fd58401e7f6 ""
|
||||||
|
"/usr/local/texlive/2015/texmf-dist/web2c/texmf.cnf" 1428852030 31983 18aeec08f48baa3cf3508d538dd5f459 ""
|
||||||
|
"/usr/local/texlive/2015/texmf-var/fonts/map/pdftex/updmap/pdftex.map" 1432479641 1764542 91654ba72bdb667e84ea24f076ae16d8 ""
|
||||||
|
"/usr/local/texlive/2015/texmf-var/web2c/pdftex/pdflatex.fmt" 1432479681 3849859 39a7d258195bde2394e244961601fbc5 ""
|
||||||
|
"/usr/local/texlive/2015/texmf.cnf" 1432479636 577 0d611272082f3cdb8e80e09a3c69cf07 ""
|
||||||
|
"dump1090.h" 1505360723 21883 5718524b7196565a03bf7fd58401e7f6 ""
|
||||||
|
(generated)
|
||||||
|
"/Users/nmatsuda/Git/spidr/sdl1090/dump1090.log"
|
||||||
|
"dump1090.log"
|
||||||
|
"dump1090.pdf"
|
||||||
|
"/Users/nmatsuda/Git/spidr/sdl1090/dump1090.pdf"
|
8
sdl1090/dump1090.fls
Normal file
8
sdl1090/dump1090.fls
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
PWD /Users/nmatsuda/Git/spidr/sdl1090
|
||||||
|
INPUT /usr/local/texlive/2015/texmf.cnf
|
||||||
|
INPUT /usr/local/texlive/2015/texmf-dist/web2c/texmf.cnf
|
||||||
|
INPUT /usr/local/texlive/2015/texmf-var/web2c/pdftex/pdflatex.fmt
|
||||||
|
INPUT /Users/nmatsuda/Git/spidr/sdl1090/dump1090.h
|
||||||
|
OUTPUT /Users/nmatsuda/Git/spidr/sdl1090/dump1090.log
|
||||||
|
OUTPUT /Users/nmatsuda/Git/spidr/sdl1090/dump1090.pdf
|
||||||
|
INPUT /usr/local/texlive/2015/texmf-var/fonts/map/pdftex/updmap/pdftex.map
|
|
@ -223,6 +223,9 @@ struct aircraft {
|
||||||
uint64_t odd_cprtime;
|
uint64_t odd_cprtime;
|
||||||
uint64_t even_cprtime;
|
uint64_t even_cprtime;
|
||||||
double lat, lon; // Coordinated obtained from CPR encoded data
|
double lat, lon; // Coordinated obtained from CPR encoded data
|
||||||
|
double dx, dy; // distance in km
|
||||||
|
double oldDx[32], oldDy[32]; // position history
|
||||||
|
uint8_t oldIdx; // index for ring buffer
|
||||||
int bFlags; // Flags related to valid fields in this structure
|
int bFlags; // Flags related to valid fields in this structure
|
||||||
struct aircraft *next; // Next aircraft in our linked list
|
struct aircraft *next; // Next aircraft in our linked list
|
||||||
};
|
};
|
||||||
|
|
1
sdl1090/dump1090.log.REMOVED.git-id
Normal file
1
sdl1090/dump1090.log.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ad971cbbab08e7bc43c68649b1796aa31b989e1e
|
|
@ -28,7 +28,6 @@ void closeFont(TTF_Font *font)
|
||||||
|
|
||||||
void drawString(char * text, int x, int y, TTF_Font *font, SDL_Color color)
|
void drawString(char * text, int x, int y, TTF_Font *font, SDL_Color color)
|
||||||
{
|
{
|
||||||
SDL_Rect dest;
|
|
||||||
SDL_Surface *surface;
|
SDL_Surface *surface;
|
||||||
|
|
||||||
// surface = TTF_RenderUTF8_Shaded(font, text, foregroundColor, backgroundColor);
|
// surface = TTF_RenderUTF8_Shaded(font, text, foregroundColor, backgroundColor);
|
||||||
|
|
|
@ -32,8 +32,9 @@
|
||||||
#include "structs.h"
|
#include "structs.h"
|
||||||
|
|
||||||
Game game;
|
Game game;
|
||||||
extern void drawPlaneHeading(int , int , double, int, char *);
|
extern void drawPlaneHeading(double , double , double, int, char *);
|
||||||
extern void drawPlane(int , int, int);
|
extern void drawPlane(double , double, int);
|
||||||
|
extern void drawTrail(double *, double *, int);
|
||||||
extern void drawGrid();
|
extern void drawGrid();
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,6 +146,11 @@ struct aircraft *interactiveCreateAircraft(struct modesMessage *mm) {
|
||||||
// Now initialise things that should not be 0/NULL to their defaults
|
// Now initialise things that should not be 0/NULL to their defaults
|
||||||
a->addr = mm->addr;
|
a->addr = mm->addr;
|
||||||
a->lat = a->lon = 0.0;
|
a->lat = a->lon = 0.0;
|
||||||
|
|
||||||
|
a->oldIdx = 0;
|
||||||
|
memset(a->oldDx, 0, sizeof(a->oldDx));
|
||||||
|
memset(a->oldDy, 0, sizeof(a->oldDy));
|
||||||
|
|
||||||
memset(a->signalLevel, mm->signalLevel, 8); // First time, initialise everything
|
memset(a->signalLevel, mm->signalLevel, 8); // First time, initialise everything
|
||||||
// to the first signal strength
|
// to the first signal strength
|
||||||
|
|
||||||
|
@ -380,6 +386,17 @@ struct aircraft *interactiveReceiveData(struct modesMessage *mm) {
|
||||||
mm->bFlags |= MODES_ACFLAGS_LATLON_VALID;
|
mm->bFlags |= MODES_ACFLAGS_LATLON_VALID;
|
||||||
mm->fLat = a->lat;
|
mm->fLat = a->lat;
|
||||||
mm->fLon = a->lon;
|
mm->fLon = a->lon;
|
||||||
|
|
||||||
|
double dLon = a->lon+87.6651033;
|
||||||
|
double dLat = a->lat-41.9809263;
|
||||||
|
|
||||||
|
a->dx = 6371.0 * dLon * M_PI / 180.0f * cos(((a->lat+41.9809263)/2.0f) * M_PI / 180.0f);
|
||||||
|
a->dy = 6371.0 * dLat * M_PI / 180.0f;
|
||||||
|
|
||||||
|
a->oldDx[a->oldIdx] = a->dx;
|
||||||
|
a->oldDy[a->oldIdx] = a->dy;
|
||||||
|
|
||||||
|
a->oldIdx = (a->oldIdx+1) % 32;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,29 +532,18 @@ void interactiveShowData(void) {
|
||||||
if (flags & MODEAC_MSG_MODEC_HIT) {strMode[3] = 'c';}
|
if (flags & MODEAC_MSG_MODEC_HIT) {strMode[3] = 'c';}
|
||||||
|
|
||||||
if (a->bFlags & MODES_ACFLAGS_LATLON_VALID) {
|
if (a->bFlags & MODES_ACFLAGS_LATLON_VALID) {
|
||||||
double dLon = a->lon+87.6651033;
|
|
||||||
double dLat = a->lat-41.9809263;
|
|
||||||
|
|
||||||
double x = 6371.0 * dLon * M_PI / 180.0f * cos(((a->lat+41.9809263)/2.0f) * M_PI / 180.0f);
|
snprintf(strLat, 8,"%7.03f", a->dx);
|
||||||
double y = 6371.0 * dLat * M_PI / 180.0f;
|
snprintf(strLon, 9,"%8.03f", a->dy);
|
||||||
// d = sqrt(x*x + y*y) * 6371.0;
|
|
||||||
|
|
||||||
snprintf(strLat, 8,"%7.03f", x);
|
|
||||||
snprintf(strLon, 9,"%8.03f", y);
|
|
||||||
|
|
||||||
int px = round(320.0 * (0.5 + (x / 64.0)));
|
|
||||||
int py = round(240.0 * (0.5 + (y / 48.0)));
|
|
||||||
|
|
||||||
if(px >= 0 && px < 320 && py >= 0 && py < 240 ) {
|
|
||||||
|
|
||||||
|
|
||||||
if(MODES_ACFLAGS_HEADING_VALID) {
|
if(MODES_ACFLAGS_HEADING_VALID) {
|
||||||
drawPlaneHeading(px, py,a->track, signalAverage, a->flight);
|
drawPlaneHeading(a->dx, a->dy,a->track, signalAverage, a->flight);
|
||||||
} else {
|
} else {
|
||||||
drawPlane(px, py, signalAverage);
|
drawPlane(a->dx, a->dy, signalAverage);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drawTrail(a->oldDx, a->oldDy, a->oldIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a->bFlags & MODES_ACFLAGS_AOG) {
|
if (a->bFlags & MODES_ACFLAGS_AOG) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
cf33382ed17a81af7f3feeb37ef6816982a101e5
|
1efd85596b2ba325841ccd3511d70639b9feaec8
|
|
@ -341,7 +341,6 @@ int main(int argc, char **argv) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
unsigned int frameLimit = SDL_GetTicks() + 16;
|
|
||||||
int go;
|
int go;
|
||||||
|
|
||||||
/* Start up SDL */
|
/* Start up SDL */
|
||||||
|
|
Loading…
Reference in a new issue