7 Commits

Author SHA1 Message Date
69d5ef09bf ignore future compile command files 2025-09-15 09:21:09 -05:00
2b9316f9d2 remove compile_commands.json. update glfw 2025-09-15 09:19:59 -05:00
2c20254c23 readme mods 2025-09-12 09:43:28 -05:00
90c3023618 readme mods 2025-09-11 14:47:54 -05:00
60ad2c5da5 readme mods 2025-09-11 14:37:56 -05:00
bedb7d93e9 remove unneeded files 2025-09-11 14:31:16 -05:00
7f0d52c3a0 Add readme and example csharp dll interface class. 2025-09-11 14:30:05 -05:00
8 changed files with 102 additions and 60 deletions

View File

@@ -1,8 +0,0 @@
# Format Style Options - Created with Clang Power Tools
---
BasedOnStyle: WebKit
BreakBeforeBraces: Attach
ColumnLimit: 110
SortIncludes: false
SpaceAfterTemplateKeyword: false
...

1
.gitignore vendored
View File

@@ -13,3 +13,4 @@ x64**
.cache**
tags
bin/*
compile_commands.json

68
LivePlotter.cs Normal file
View File

@@ -0,0 +1,68 @@
using System;
using System.Numerics;
using System.Runtime.InteropServices;
using Common.Data;
using pointid = System.UInt64;
namespace TysonPalletScanner
{
public class LivePlotter
{
[DllImport("LivePlotter.dll")]
public static extern bool start(int win_w, int win_h);
[DllImport("LivePlotter.dll")]
public static extern bool stop();
[DllImport("LivePlotter.dll")]
public static extern pointid create_point(float x, float y, float z);
[DllImport("LivePlotter.dll")]
public static extern void set_color(pointid id, float r, float g, float b);
[DllImport("LivePlotter.dll")]
public static extern void set_scale(pointid id, float scale);
[DllImport("LivePlotter.dll")]
public static extern void update_point(pointid id, float x, float y, float z);
[DllImport("LivePlotter.dll")]
public static extern void set_lifetime(pointid id, float new_lifetime_s);
[DllImport("LivePlotter.dll")]
public static extern void clear_point(pointid id);
public static void PlotCameraPoses()
{
string[] lines = File.ReadAllLines("poses.csv");
for (int camera_i = 1; camera_i < lines.Length; camera_i++)
{
string[] words = lines[camera_i].Split(',');
float x = float.Parse(words[0]);
float y = float.Parse(words[1]);
float z = float.Parse(words[2]);
float w = float.Parse(words[3]);
float i = float.Parse(words[4]);
float j = float.Parse(words[5]);
float k = float.Parse(words[6]);
Pose pose = new(new Quaternion(i, j, k, w), new Vector3(x, y, z));
for (int m = 0; m < 3; m++)
{
for (int n = 0; n < 25; n++)
{
Vector3 local = new(0);
local[m] = n * 10.0f;
Vector3 global = pose * local;
pointid id = create_point(global.X, global.Y, global.Z);
Vector3 color = new(0);
color[m] = 1.0f;
set_color(id, color.X, color.Y, color.Z);
set_scale(id, 15);
}
}
}
}
}
}

32
README.md Normal file
View File

@@ -0,0 +1,32 @@
# Overview
LivePlotter is an opengl-based, 3d point plotting DLL. It is designed to be integrated into any project that needs to see 3d points plotted and updated in real time. It supposts simple camera control: rotate, pan, and zoom. Points can be given a "lifetime" during which their opacity will fade. The opacity of these points can be restored by updating their position. This allows an intuite representation of sensor readings (where the opacity of the point represents the age of the reading).
This DLL is designed to integrate easily into a C# application. A class that acomplishes this included. See [LivePlotter.cs](./LivePlotter.cs). Unfortunately the DLL also expects the presence of several other files currently, so you'll need to ensure **EVERYTHING** from the bin/ folder (that contains `LivePlotter.dll`) is in your project's build output directory.
![til](./demo.gif)
*Please note that this project is still considered a work in progress. I will avoid making api-breaking changes. Functionality may be added and code refactoring may occur in the future since I plan to use this for several projects*
# Acquiring the DLL
There are two main ways to get the DLL...
## Download from releases (recommended)
Download the DLL from the latest release on the [releases page](https://git.the-embedded-lab.com/shamilton/LivePlotter/releases).
## Build from source (not recommended)
Building is a tad messy atm. I despise Visual Studio and like to manage my own build process. I prefer something simple like a script to build and that's currently what I have, but it's not nearly as clean as I'd like. I hope to fix this mess in the future.
1. You'll need git bash and an installation of MSVC (likely via downloading/installing Visual Studio and then installing the C++ build tools).
2. Get the source code. `git clone --recurse-submodules https://git.the-embedded-lab.com/shamilton/LivePlotter.git`
3. Build the glfw library. `cd ext/glfw`. `mkdir build && cd build && cmake ..`. Open GLFW.sln and build the solution.
4. Find `vcvars64.bat` in your installation and modify the path in [run_before_build.bat](./run_before_build.bat) to point to it.
5. Open git bash to the root directory of the project.
6. Run `./run_before_build.bat` then `build.sh`
7. A folder bin/ should exist with `LivePlotter.dll` inside.
8. Copy the entire contents of the bin folder (preferably minus the intermediate build files... sorry) to your project's build output directory
If issues arise, please feel free to create an issue on this repository.

View File

@@ -1,8 +0,0 @@
[
{ "directory": "C:/Users/seth/Documents/repos/LivePlotter", "command": "cl src/body.cpp -I inc -I ext/glm -I ext/glfw/include -Od -std:c++20 -Fo", "file": "src/body.cpp" },
{ "directory": "C:/Users/seth/Documents/repos/LivePlotter", "command": "cl src/camera.cpp -I inc -I ext/glm -I ext/glfw/include -Od -std:c++20 -Fo", "file": "src/camera.cpp" },
{ "directory": "C:/Users/seth/Documents/repos/LivePlotter", "command": "cl src/demo/demo.cpp -I inc -I ext/glm -I ext/glfw/include -Od -std:c++20 -Fo", "file": "src/demo/demo.cpp" },
{ "directory": "C:/Users/seth/Documents/repos/LivePlotter", "command": "cl src/live_plotter.cpp -I inc -I ext/glm -I ext/glfw/include -Od -std:c++20 -Fo", "file": "src/live_plotter.cpp" },
{ "directory": "C:/Users/seth/Documents/repos/LivePlotter", "command": "cl src/shaders.cpp -I inc -I ext/glm -I ext/glfw/include -Od -std:c++20 -Fo", "file": "src/shaders.cpp" },
{ "directory": "C:/Users/seth/Documents/repos/LivePlotter", "command": "cl src/util.cpp -I inc -I ext/glm -I ext/glfw/include -Od -std:c++20 -Fo", "file": "src/util.cpp" },
]

View File

@@ -1,28 +0,0 @@
{
"rdocCaptureSettings": 1,
"settings": {
"autoStart": false,
"commandLine": "",
"environment": [
],
"executable": "C:\\Users\\sethh\\Documents\\repos\\LivePlotter\\bin\\demo.exe",
"inject": false,
"numQueuedFrames": 0,
"options": {
"allowFullscreen": true,
"allowVSync": true,
"apiValidation": false,
"captureAllCmdLists": false,
"captureCallstacks": false,
"captureCallstacksOnlyDraws": false,
"debugOutputMute": true,
"delayForDebugger": 0,
"hookIntoChildren": false,
"refAllResources": false,
"softMemoryLimit": 0,
"verifyBufferAccess": false
},
"queuedFrameCap": 0,
"workingDir": ""
}
}

View File

@@ -1,15 +0,0 @@
// raddbg 0.9.21 project file
recent_file: path: "src/live_plotter.cpp"
recent_file: path: "src/camera.cpp"
recent_file: path: "src/body.cpp"
recent_file: path: "src/shaders.cpp"
recent_file: path: "../../../../../Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/include/variant"
recent_file: path: "../../../../../Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/include/type_traits"
recent_file: path: "src/demo/demo.cpp"
target:
{
executable: "bin/demo.exe"
working_directory: bin
enabled: 1
}