diff --git a/README.md b/README.md index fbcc19c..28be6b5 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,19 @@ Work in progress. Goals are: parsing an IGC file containing flight data, giving analytics about the flight, and if I really have time to kill, making some kind of (3D??) view of the flight.. -# Dependencies +TODO: +- convert sexagesimal (deg/min/sec) coordinates to decimal degrees +- convert decimal degrees to cartesian (x, y, z) coordinates +- choose scale to represent X meters as Y world units +- get those new units (cartesian & world units) as data fields in the doubly linked list (so we can print GPS coords & draw 3d points using the same data structure) +- draw points in the 3d world +- draw lines between these points +- make camera controls: N for Next, P for Previous +- Text information: average horizontal/vertical speed etc. +- Plane mesh +- Ground texture + +## Dependencies These are mainly for building the project, and for Raylib (the 3D graphic library): @@ -23,7 +35,7 @@ make PLATFORM=PLATFORM_DESKTOP cp libraylib.a PATH/TO/igcp/lib/ ``` -# Compilation & Usage +## Compilation & Usage Now you can compile igcp and use it: diff --git a/makefile b/makefile index 40c5c9a..f6e56d1 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ all: - gcc -Wall -g src/linkage.c src/igc.c src/main.c -I./include -L./lib -lraylib -lGL -lEGL -lGLESv2 -lm -lpthread -ldl -lrt -lX11 + gcc -Wall -g src/graphics.c src/linkage.c src/igc.c src/main.c -I./include -L./lib -lraylib -lGL -lEGL -lGLESv2 -lm -lpthread -ldl -lrt -lX11 clean: rm a.out diff --git a/src/graphics.c b/src/graphics.c new file mode 100644 index 0000000..b06e299 --- /dev/null +++ b/src/graphics.c @@ -0,0 +1,56 @@ +/* + * IGC parser + * @brief parse IGC file, get all data points, compute average horizontal/vertical speed, print to STDOUT + * + * As per standard: https://xp-soaring.github.io/igc_file_format/igc_format_2008.html + * https://xp-soaring.github.io/igc_file_format/igc_fr_specification_with_al8_2023-2-1_0.pdf + * + * @author xamidev + * @license GNU GPL v3 + */ + +#include "raylib.h" + +void start_graphics() +{ + SetTraceLogLevel(4); + const int screenWidth = 800; + const int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "camera"); + + Camera3D camera = {0}; + camera.position = (Vector3){10.0f, 10.0f, 10.0f}; + camera.target = (Vector3){0.0f, 0.0f, 0.0f}; + camera.up = (Vector3){0.0f, 1.0f, 0.0f}; + camera.fovy = 45.0f; + camera.projection = CAMERA_PERSPECTIVE; + + Vector3 cubePosition = {0.0f, 0.0f, 0.0f}; + DisableCursor(); + SetTargetFPS(60); + + while (!WindowShouldClose()) + { + // Update + // Variables should update HERE + UpdateCamera(&camera, CAMERA_FREE); + + // Draw + BeginDrawing(); + ClearBackground(RAYWHITE); + BeginMode3D(camera); + + DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); + DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); + DrawGrid(10, 1.0f); + + EndMode3D(); + DrawText("3rd Dimension", 10, 40, 20, DARKGRAY); + DrawFPS(10, 10); + EndDrawing(); + } + + CloseWindow(); + return; +} diff --git a/src/graphics.h b/src/graphics.h new file mode 100644 index 0000000..9be0228 --- /dev/null +++ b/src/graphics.h @@ -0,0 +1,17 @@ +/* + * IGC parser + * @brief parse IGC file, get all data points, compute average horizontal/vertical speed, print to STDOUT + * + * As per standard: https://xp-soaring.github.io/igc_file_format/igc_format_2008.html + * https://xp-soaring.github.io/igc_file_format/igc_fr_specification_with_al8_2023-2-1_0.pdf + * + * @author xamidev + * @license GNU GPL v3 + */ + +#ifndef GRAPHICS_H +#define GRAPHICS_H + +void start_graphics(); + +#endif diff --git a/src/main.c b/src/main.c index b0db484..7977180 100644 --- a/src/main.c +++ b/src/main.c @@ -9,14 +9,13 @@ * @license GNU GPL v3 */ -#include "raylib.h" - #include #include #include #include #include "igc.h" #include "linkage.h" +#include "graphics.h" int main(int argc, char* argv[]) { @@ -43,19 +42,7 @@ int main(int argc, char* argv[]) print_datapoint_list(head); - // Raylib test window - SetTraceLogLevel(4); - const int screenWidth = 800; - const int screenHeight = 600; - InitWindow(screenWidth, screenHeight, "Raylib basic window"); - SetTargetFPS(60); - while (!WindowShouldClose()) { - BeginDrawing(); - ClearBackground(RAYWHITE); - DrawText("It works!", 20, 20, 20, BLACK); - EndDrawing(); - } - CloseWindow(); + start_graphics(); return EXIT_SUCCESS; }