Test 3D camera
This commit is contained in:
16
README.md
16
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:
|
||||
|
||||
|
||||
2
makefile
2
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
|
||||
|
||||
56
src/graphics.c
Normal file
56
src/graphics.c
Normal file
@@ -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 <xamidev@riseup.net>
|
||||
* @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;
|
||||
}
|
||||
17
src/graphics.h
Normal file
17
src/graphics.h
Normal file
@@ -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 <xamidev@riseup.net>
|
||||
* @license GNU GPL v3
|
||||
*/
|
||||
|
||||
#ifndef GRAPHICS_H
|
||||
#define GRAPHICS_H
|
||||
|
||||
void start_graphics();
|
||||
|
||||
#endif
|
||||
17
src/main.c
17
src/main.c
@@ -9,14 +9,13 @@
|
||||
* @license GNU GPL v3
|
||||
*/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user