From 59162408f1209d9113f9fbee09c3a3ea51c0bb3b Mon Sep 17 00:00:00 2001 From: Seth Hamilton Date: Mon, 25 Aug 2025 03:09:32 -0500 Subject: [PATCH 1/4] A serious refactor. Moved the entire window management process to another thread. Made a plotting interface with DLL exports. Refactored camera and changed transformation approach based on Jordan's suggestions --- LivePlotter.sln | 11 +- LivePlotter.vcxproj | 64 ++++++++ LivePlotter.vcxproj.filters | 6 + LivePlotter.vcxproj.user | 3 + compile_commands.json | 48 +++--- inc/camera.hpp | 24 +++ inc/camera_poses.hpp | 3 +- inc/live_plotter.hpp | 12 ++ inc/util.hpp | 11 +- src/body.cpp | 17 +-- src/camera.cpp | 48 ++++++ src/camera_poses.cpp | 36 ++--- src/live_plotter.cpp | 288 ++++++++++++++++++++++++++++++++++++ src/main.cpp | 283 ++++++----------------------------- src/util.cpp | 5 +- 15 files changed, 566 insertions(+), 293 deletions(-) create mode 100644 inc/camera.hpp create mode 100644 inc/live_plotter.hpp create mode 100644 src/camera.cpp create mode 100644 src/live_plotter.cpp diff --git a/LivePlotter.sln b/LivePlotter.sln index 066340c..87d89b1 100644 --- a/LivePlotter.sln +++ b/LivePlotter.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.12.35707.178 d17.12 +VisualStudioVersion = 17.12.35707.178 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LivePlotter", "LivePlotter.vcxproj", "{74C0F84F-216F-4A12-9F91-6AFC83CF9257}" EndProject @@ -9,6 +9,8 @@ Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 + DLLDebug|x64 = DLLDebug|x64 + DLLDebug|x86 = DLLDebug|x86 Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection @@ -17,6 +19,10 @@ Global {74C0F84F-216F-4A12-9F91-6AFC83CF9257}.Debug|x64.Build.0 = Debug|x64 {74C0F84F-216F-4A12-9F91-6AFC83CF9257}.Debug|x86.ActiveCfg = Debug|Win32 {74C0F84F-216F-4A12-9F91-6AFC83CF9257}.Debug|x86.Build.0 = Debug|Win32 + {74C0F84F-216F-4A12-9F91-6AFC83CF9257}.DLLDebug|x64.ActiveCfg = DebugDLL|x64 + {74C0F84F-216F-4A12-9F91-6AFC83CF9257}.DLLDebug|x64.Build.0 = DebugDLL|x64 + {74C0F84F-216F-4A12-9F91-6AFC83CF9257}.DLLDebug|x86.ActiveCfg = DebugDLL|Win32 + {74C0F84F-216F-4A12-9F91-6AFC83CF9257}.DLLDebug|x86.Build.0 = DebugDLL|Win32 {74C0F84F-216F-4A12-9F91-6AFC83CF9257}.Release|x64.ActiveCfg = Release|x64 {74C0F84F-216F-4A12-9F91-6AFC83CF9257}.Release|x64.Build.0 = Release|x64 {74C0F84F-216F-4A12-9F91-6AFC83CF9257}.Release|x86.ActiveCfg = Release|Win32 @@ -25,4 +31,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C971CF76-7BA3-45CC-A602-A49CCD685470} + EndGlobalSection EndGlobal diff --git a/LivePlotter.vcxproj b/LivePlotter.vcxproj index 7fe3a9d..a2131d0 100644 --- a/LivePlotter.vcxproj +++ b/LivePlotter.vcxproj @@ -1,6 +1,14 @@ + + DebugDLL + Win32 + + + DebugDLL + x64 + Debug Win32 @@ -32,6 +40,12 @@ v143 Unicode + + Application + true + v143 + Unicode + Application false @@ -45,6 +59,12 @@ v143 Unicode + + DynamicLibrary + true + v143 + Unicode + Application false @@ -60,12 +80,18 @@ + + + + + + @@ -77,6 +103,13 @@ $(SolutionDir)obj\$(Platform)\$(Configuration)\ $(SolutionDir)src;$(SourcePath) + + $(SolutionDir)lib;$(SolutionDir)ext\pthreads4w-code\build\Debug;$(SolutionDir)ext\glfw\build\src\Debug;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64) + $(SolutionDir)ext\pthreads4w-code;$(SolutionDir)ext\glm;$(SolutionDir)ext\glfw\include;$(SolutionDir)inc;$(IncludePath) + $(SolutionDir)bin\$(Platform)\$(Configuration)\ + $(SolutionDir)obj\$(Platform)\$(Configuration)\ + $(SolutionDir)src;$(SourcePath) + Level3 @@ -89,6 +122,18 @@ true + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + Level3 @@ -122,6 +167,23 @@ xcopy /y "$(SolutionDir)poses.csv" "$(OutDir)" && xcopy /y "$(SolutionDir)ext\pthreads4w-code\build\Debug\pthreadVC3d.dll" "$(OutDir)" + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp20 + + + Console + true + ext\pthreads4w-code\build\Debug\pthreadVC3d.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies) + + + xcopy /y "$(SolutionDir)poses.csv" "$(OutDir)" && xcopy /y "$(SolutionDir)ext\pthreads4w-code\build\Debug\pthreadVC3d.dll" "$(OutDir)" + + Level3 @@ -140,8 +202,10 @@ + + diff --git a/LivePlotter.vcxproj.filters b/LivePlotter.vcxproj.filters index 4918bcd..41e5b53 100644 --- a/LivePlotter.vcxproj.filters +++ b/LivePlotter.vcxproj.filters @@ -33,5 +33,11 @@ Source Files + + Source Files + + + Source Files + \ No newline at end of file diff --git a/LivePlotter.vcxproj.user b/LivePlotter.vcxproj.user index 9573012..0eec2e4 100644 --- a/LivePlotter.vcxproj.user +++ b/LivePlotter.vcxproj.user @@ -3,4 +3,7 @@ WindowsLocalDebugger + + WindowsLocalDebugger + \ No newline at end of file diff --git a/compile_commands.json b/compile_commands.json index 58d3b2f..e53e069 100644 --- a/compile_commands.json +++ b/compile_commands.json @@ -1,37 +1,49 @@ [ { - "directory": "C:/Users/sethh/Documents/repos/LivePlotter/", - "command": "\"C:/Users/sethh/AppData/Roaming/ClangPowerTools/LLVM_Lite/Bin/clang++.exe\" -x c++ \"C:/Users/sethh/Documents/repos/LivePlotter/src/shaders.cpp\" -std=c++20 -Wall -fms-compatibility-version=19.10 -Wmicrosoft -Wno-invalid-token-paste -Wno-unknown-pragmas -Wno-unused-value -fsyntax-only \"-DUNICODE\" \"-D_UNICODE\" \"-D_MT\" \"-D_DLL\" \"-D_DEBUG\" \"-D_CONSOLE\" \"-D_DEBUG_FUNCTIONAL_MACHINERY\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/include\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/atlmfc/include\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/VS/include\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/um\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/shared\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/winrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/cppwinrt\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/ext/pthreads4w-code\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/ext/glm\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/ext/glfw/include\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/inc\"", - "file": "C:/Users/sethh/Documents/repos/LivePlotter/src/shaders.cpp" + "directory": "C:/Users/seth/Documents/repos/LivePlotter/", + "command": "\"C:/Users/seth/AppData/Roaming/ClangPowerTools/LLVM_Lite/Bin/clang++.exe\" -x c++ \"C:/Users/seth/Documents/repos/LivePlotter/src/util.cpp\" -std=c++20 -Wall -fms-compatibility-version=19.10 -Wmicrosoft -Wno-invalid-token-paste -Wno-unknown-pragmas -Wno-unused-value -fsyntax-only \"-DUNICODE\" \"-D_UNICODE\" \"-D_MT\" \"-D_DLL\" \"-D_DEBUG\" \"-D_CONSOLE\" \"-D_DEBUG_FUNCTIONAL_MACHINERY\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/include\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/atlmfc/include\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Auxiliary/VS/include\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/ucrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/shared\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/winrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/cppwinrt\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/pthreads4w-code\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/glm\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/glfw/include\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/inc\"", + "file": "C:/Users/seth/Documents/repos/LivePlotter/src/util.cpp" } , { - "directory": "C:/Users/sethh/Documents/repos/LivePlotter/", - "command": "\"C:/Users/sethh/AppData/Roaming/ClangPowerTools/LLVM_Lite/Bin/clang++.exe\" -x c++ \"C:/Users/sethh/Documents/repos/LivePlotter/src/main.cpp\" -std=c++20 -Wall -fms-compatibility-version=19.10 -Wmicrosoft -Wno-invalid-token-paste -Wno-unknown-pragmas -Wno-unused-value -fsyntax-only \"-DUNICODE\" \"-D_UNICODE\" \"-D_MT\" \"-D_DLL\" \"-D_DEBUG\" \"-D_CONSOLE\" \"-D_DEBUG_FUNCTIONAL_MACHINERY\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/include\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/atlmfc/include\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/VS/include\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/um\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/shared\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/winrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/cppwinrt\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/ext/pthreads4w-code\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/ext/glm\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/ext/glfw/include\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/inc\"", - "file": "C:/Users/sethh/Documents/repos/LivePlotter/src/main.cpp" + "directory": "C:/Users/seth/Documents/repos/LivePlotter/", + "command": "\"C:/Users/seth/AppData/Roaming/ClangPowerTools/LLVM_Lite/Bin/clang++.exe\" -x c++ \"C:/Users/seth/Documents/repos/LivePlotter/src/camera_poses.cpp\" -std=c++20 -Wall -fms-compatibility-version=19.10 -Wmicrosoft -Wno-invalid-token-paste -Wno-unknown-pragmas -Wno-unused-value -fsyntax-only \"-DUNICODE\" \"-D_UNICODE\" \"-D_MT\" \"-D_DLL\" \"-D_DEBUG\" \"-D_CONSOLE\" \"-D_DEBUG_FUNCTIONAL_MACHINERY\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/include\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/atlmfc/include\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Auxiliary/VS/include\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/ucrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/shared\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/winrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/cppwinrt\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/pthreads4w-code\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/glm\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/glfw/include\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/inc\"", + "file": "C:/Users/seth/Documents/repos/LivePlotter/src/camera_poses.cpp" } , { - "directory": "C:/Users/sethh/Documents/repos/LivePlotter/", - "command": "\"C:/Users/sethh/AppData/Roaming/ClangPowerTools/LLVM_Lite/Bin/clang++.exe\" -x c++ \"C:/Users/sethh/Documents/repos/LivePlotter/src/util.cpp\" -std=c++20 -Wall -fms-compatibility-version=19.10 -Wmicrosoft -Wno-invalid-token-paste -Wno-unknown-pragmas -Wno-unused-value -fsyntax-only \"-DUNICODE\" \"-D_UNICODE\" \"-D_MT\" \"-D_DLL\" \"-D_DEBUG\" \"-D_CONSOLE\" \"-D_DEBUG_FUNCTIONAL_MACHINERY\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/include\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/atlmfc/include\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/VS/include\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/um\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/shared\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/winrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/cppwinrt\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/ext/pthreads4w-code\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/ext/glm\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/ext/glfw/include\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/inc\"", - "file": "C:/Users/sethh/Documents/repos/LivePlotter/src/util.cpp" + "directory": "C:/Users/seth/Documents/repos/LivePlotter/", + "command": "\"C:/Users/seth/AppData/Roaming/ClangPowerTools/LLVM_Lite/Bin/clang++.exe\" -x c++ \"C:/Users/seth/Documents/repos/LivePlotter/src/shaders.cpp\" -std=c++20 -Wall -fms-compatibility-version=19.10 -Wmicrosoft -Wno-invalid-token-paste -Wno-unknown-pragmas -Wno-unused-value -fsyntax-only \"-DUNICODE\" \"-D_UNICODE\" \"-D_MT\" \"-D_DLL\" \"-D_DEBUG\" \"-D_CONSOLE\" \"-D_DEBUG_FUNCTIONAL_MACHINERY\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/include\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/atlmfc/include\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Auxiliary/VS/include\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/ucrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/shared\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/winrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/cppwinrt\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/pthreads4w-code\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/glm\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/glfw/include\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/inc\"", + "file": "C:/Users/seth/Documents/repos/LivePlotter/src/shaders.cpp" } , { - "directory": "C:/Users/sethh/Documents/repos/LivePlotter/", - "command": "\"C:/Users/sethh/AppData/Roaming/ClangPowerTools/LLVM_Lite/Bin/clang++.exe\" -x c++ \"C:/Users/sethh/Documents/repos/LivePlotter/src/tcp_server.cpp\" -std=c++20 -Wall -fms-compatibility-version=19.10 -Wmicrosoft -Wno-invalid-token-paste -Wno-unknown-pragmas -Wno-unused-value -fsyntax-only \"-DUNICODE\" \"-D_UNICODE\" \"-D_MT\" \"-D_DLL\" \"-D_DEBUG\" \"-D_CONSOLE\" \"-D_DEBUG_FUNCTIONAL_MACHINERY\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/include\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/atlmfc/include\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/VS/include\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/um\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/shared\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/winrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/cppwinrt\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/ext/pthreads4w-code\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/ext/glm\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/ext/glfw/include\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/inc\"", - "file": "C:/Users/sethh/Documents/repos/LivePlotter/src/tcp_server.cpp" + "directory": "C:/Users/seth/Documents/repos/LivePlotter/", + "command": "\"C:/Users/seth/AppData/Roaming/ClangPowerTools/LLVM_Lite/Bin/clang++.exe\" -x c++ \"C:/Users/seth/Documents/repos/LivePlotter/src/body.cpp\" -std=c++20 -Wall -fms-compatibility-version=19.10 -Wmicrosoft -Wno-invalid-token-paste -Wno-unknown-pragmas -Wno-unused-value -fsyntax-only \"-DUNICODE\" \"-D_UNICODE\" \"-D_MT\" \"-D_DLL\" \"-D_DEBUG\" \"-D_CONSOLE\" \"-D_DEBUG_FUNCTIONAL_MACHINERY\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/include\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/atlmfc/include\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Auxiliary/VS/include\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/ucrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/shared\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/winrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/cppwinrt\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/pthreads4w-code\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/glm\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/glfw/include\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/inc\"", + "file": "C:/Users/seth/Documents/repos/LivePlotter/src/body.cpp" } , { - "directory": "C:/Users/sethh/Documents/repos/LivePlotter/", - "command": "\"C:/Users/sethh/AppData/Roaming/ClangPowerTools/LLVM_Lite/Bin/clang++.exe\" -x c \"C:/Users/sethh/Documents/repos/LivePlotter/src/glad.c\" -Wall -fms-compatibility-version=19.10 -Wmicrosoft -Wno-invalid-token-paste -Wno-unknown-pragmas -Wno-unused-value -fsyntax-only \"-DUNICODE\" \"-D_UNICODE\" \"-D_MT\" \"-D_DLL\" \"-D_DEBUG\" \"-D_CONSOLE\" \"-D_DEBUG_FUNCTIONAL_MACHINERY\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/include\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/atlmfc/include\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/VS/include\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/um\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/shared\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/winrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/cppwinrt\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/ext/pthreads4w-code\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/ext/glm\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/ext/glfw/include\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/inc\"", - "file": "C:/Users/sethh/Documents/repos/LivePlotter/src/glad.c" + "directory": "C:/Users/seth/Documents/repos/LivePlotter/", + "command": "\"C:/Users/seth/AppData/Roaming/ClangPowerTools/LLVM_Lite/Bin/clang++.exe\" -x c++ \"C:/Users/seth/Documents/repos/LivePlotter/src/live_plotter.cpp\" -std=c++20 -Wall -fms-compatibility-version=19.10 -Wmicrosoft -Wno-invalid-token-paste -Wno-unknown-pragmas -Wno-unused-value -fsyntax-only \"-DUNICODE\" \"-D_UNICODE\" \"-D_MT\" \"-D_DLL\" \"-D_DEBUG\" \"-D_CONSOLE\" \"-D_DEBUG_FUNCTIONAL_MACHINERY\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/include\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/atlmfc/include\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Auxiliary/VS/include\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/ucrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/shared\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/winrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/cppwinrt\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/pthreads4w-code\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/glm\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/glfw/include\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/inc\"", + "file": "C:/Users/seth/Documents/repos/LivePlotter/src/live_plotter.cpp" } , { - "directory": "C:/Users/sethh/Documents/repos/LivePlotter/", - "command": "\"C:/Users/sethh/AppData/Roaming/ClangPowerTools/LLVM_Lite/Bin/clang++.exe\" -x c++ \"C:/Users/sethh/Documents/repos/LivePlotter/src/body.cpp\" -std=c++20 -Wall -fms-compatibility-version=19.10 -Wmicrosoft -Wno-invalid-token-paste -Wno-unknown-pragmas -Wno-unused-value -fsyntax-only \"-DUNICODE\" \"-D_UNICODE\" \"-D_MT\" \"-D_DLL\" \"-D_DEBUG\" \"-D_CONSOLE\" \"-D_DEBUG_FUNCTIONAL_MACHINERY\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/include\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/atlmfc/include\" -isystem\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/VS/include\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/um\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/shared\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/winrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/cppwinrt\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/ext/pthreads4w-code\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/ext/glm\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/ext/glfw/include\" -isystem\"C:/Users/sethh/Documents/repos/LivePlotter/inc\"", - "file": "C:/Users/sethh/Documents/repos/LivePlotter/src/body.cpp" + "directory": "C:/Users/seth/Documents/repos/LivePlotter/", + "command": "\"C:/Users/seth/AppData/Roaming/ClangPowerTools/LLVM_Lite/Bin/clang++.exe\" -x c++ \"C:/Users/seth/Documents/repos/LivePlotter/src/main.cpp\" -std=c++20 -Wall -fms-compatibility-version=19.10 -Wmicrosoft -Wno-invalid-token-paste -Wno-unknown-pragmas -Wno-unused-value -fsyntax-only \"-DUNICODE\" \"-D_UNICODE\" \"-D_MT\" \"-D_DLL\" \"-D_DEBUG\" \"-D_CONSOLE\" \"-D_DEBUG_FUNCTIONAL_MACHINERY\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/include\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/atlmfc/include\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Auxiliary/VS/include\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/ucrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/shared\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/winrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/cppwinrt\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/pthreads4w-code\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/glm\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/glfw/include\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/inc\"", + "file": "C:/Users/seth/Documents/repos/LivePlotter/src/main.cpp" + } + , + { + "directory": "C:/Users/seth/Documents/repos/LivePlotter/", + "command": "\"C:/Users/seth/AppData/Roaming/ClangPowerTools/LLVM_Lite/Bin/clang++.exe\" -x c \"C:/Users/seth/Documents/repos/LivePlotter/src/glad.c\" -Wall -fms-compatibility-version=19.10 -Wmicrosoft -Wno-invalid-token-paste -Wno-unknown-pragmas -Wno-unused-value -fsyntax-only \"-DUNICODE\" \"-D_UNICODE\" \"-D_MT\" \"-D_DLL\" \"-D_DEBUG\" \"-D_CONSOLE\" \"-D_DEBUG_FUNCTIONAL_MACHINERY\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/include\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/atlmfc/include\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Auxiliary/VS/include\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/ucrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/shared\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/winrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/cppwinrt\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/pthreads4w-code\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/glm\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/glfw/include\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/inc\"", + "file": "C:/Users/seth/Documents/repos/LivePlotter/src/glad.c" + } + , + { + "directory": "C:/Users/seth/Documents/repos/LivePlotter/", + "command": "\"C:/Users/seth/AppData/Roaming/ClangPowerTools/LLVM_Lite/Bin/clang++.exe\" -x c++ \"C:/Users/seth/Documents/repos/LivePlotter/src/camera.cpp\" -std=c++20 -Wall -fms-compatibility-version=19.10 -Wmicrosoft -Wno-invalid-token-paste -Wno-unknown-pragmas -Wno-unused-value -fsyntax-only \"-DUNICODE\" \"-D_UNICODE\" \"-D_MT\" \"-D_DLL\" \"-D_DEBUG\" \"-D_CONSOLE\" \"-D_DEBUG_FUNCTIONAL_MACHINERY\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/include\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/atlmfc/include\" -isystem\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Auxiliary/VS/include\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/ucrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/shared\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/winrt\" -isystem\"C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/cppwinrt\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/pthreads4w-code\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/glm\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/ext/glfw/include\" -isystem\"C:/Users/seth/Documents/repos/LivePlotter/inc\"", + "file": "C:/Users/seth/Documents/repos/LivePlotter/src/camera.cpp" } ] diff --git a/inc/camera.hpp b/inc/camera.hpp new file mode 100644 index 0000000..63e1e28 --- /dev/null +++ b/inc/camera.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include + +struct Viewport { + float fov_degrees; + float width; + float height; +}; + +Viewport make_viewport(float win_w, float win_h, float fov_degrees); +glm::mat4 camera_to_projection(Viewport& v); + +struct Camera { + glm::vec3 focus; + float theta, phi, distance; +}; + +Camera make_camera(glm::vec3 focus, float distance); +void pan_camera(Camera &c, glm::vec2 dxdy); +void rotate_camera(Camera &c, glm::vec2 dxdy); +void zoom_camera(Camera &c, float dz); +glm::mat4 world_to_camera(Camera& c); +glm::mat4 camera_to_world(Camera& c); diff --git a/inc/camera_poses.hpp b/inc/camera_poses.hpp index 6d8d619..d7c1e74 100644 --- a/inc/camera_poses.hpp +++ b/inc/camera_poses.hpp @@ -1,6 +1,5 @@ #pragma once #include "util.hpp" -#include "body.hpp" -bool parse_poses(Array *bodies_out, const char* filepath); +bool parse_poses(Array* locs_out, const char* filepath); diff --git a/inc/live_plotter.hpp b/inc/live_plotter.hpp new file mode 100644 index 0000000..e2a3c79 --- /dev/null +++ b/inc/live_plotter.hpp @@ -0,0 +1,12 @@ +#pragma once + +typedef unsigned long long pointid; + +DllExport bool __cdecl start(int win_w, int win_h); +DllExport bool __cdecl stop(); +DllExport pointid __cdecl create_point(float x, float y, float z); +DllExport void __cdecl set_color(pointid id, float r, float g, float b); +DllExport void __cdecl set_scale(pointid id, float scale); +DllExport void __cdecl update_point(pointid id, float x, float y, float z); +DllExport void __cdecl set_lifetime(pointid id, float new_lifetime_s); +DllExport void __cdecl clear_point(pointid id); \ No newline at end of file diff --git a/inc/util.hpp b/inc/util.hpp index 6c0329c..fe4d784 100644 --- a/inc/util.hpp +++ b/inc/util.hpp @@ -1,10 +1,12 @@ #pragma once +#include #include #include #include #include -#include + +#define DllExport __declspec( dllexport ) typedef unsigned int uint; @@ -23,4 +25,9 @@ bool read_file(Array* out, const char* filepath); Array split_str(const char* s, char delimiter); Array split_str(const char* s); -glm::mat4 quat_to_mat4(glm::quat q); \ No newline at end of file +glm::mat4 quat_to_mat4(glm::quat q); + +template T lerp(T start, T end, float t) { return t * end + (1 - t) * start; } +template float ilerp(T start, T end, T pos) { return (pos - start) / (end - start); } + +float randf(); // returns a float between 0 and 1 diff --git a/src/body.cpp b/src/body.cpp index e98e7e7..210b220 100644 --- a/src/body.cpp +++ b/src/body.cpp @@ -100,16 +100,13 @@ bool load_body(Body* out_body, const char* obj_filepath) { glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0); glEnableVertexAttribArray(0); - *out_body = { .pose = glm::mat4(1), - .scale = 1.0f, - .ebo = ebo, - .vao = vao, - .vbo = vbo, - .shader = 0, - .verts = verts, - .faces = faces, - .color = glm::vec4(0.5, 0.5, 0.5, 1) - }; + out_body->pose = glm::mat4(1); + out_body->ebo = ebo; + out_body->vao = vao; + out_body->vbo = vbo; + out_body->shader = 0; + out_body->verts = verts; + out_body->faces = faces; return true; } diff --git a/src/camera.cpp b/src/camera.cpp new file mode 100644 index 0000000..ff5b7d5 --- /dev/null +++ b/src/camera.cpp @@ -0,0 +1,48 @@ +#include "camera.hpp" + +#include +#include +#include +#include + +const float zoom_speed_scale = 30.0f; + +Viewport make_viewport(float win_w, float win_h, float fov_degrees = 45.0f) { + return { .fov_degrees = fov_degrees, .width = win_w, .height = win_h }; +} + +glm::mat4 camera_to_projection(Viewport &v) { + return glm::infinitePerspective(glm::radians(v.fov_degrees), v.width / v.height, 0.1f); +} + +Camera make_camera(glm::vec3 focus = glm::vec3(0, 0, 0), float distance = 1.0f) { + return { + .focus = focus, + .theta = 0, + .phi = 0, + .distance = distance + }; +} +void pan_camera(Camera& c, glm::vec2 dxdy) { + dxdy.y *= -1; + c.focus += camera_to_world(c) * glm::vec4(dxdy, 0, 0) * c.distance / 1000.0f; +} + +void rotate_camera(Camera& c, glm::vec2 dxdy) { + c.theta += dxdy.x / 100.0f; + c.phi += dxdy.y / 100.0f; +} + +void zoom_camera(Camera& c, float dz) { + c.distance = std::max(0.0f, c.distance - (dz * zoom_speed_scale)); +} + +glm::mat4 world_to_camera(Camera& c) { + glm::mat4 world_to_focus = glm::translate(glm::mat4(1), c.focus); + glm::mat4 rotation_theta = glm::rotate(glm::mat4(1), c.theta, {0, 1, 0}); + glm::mat4 rotation_phi = glm::rotate(glm::mat4(1), c.phi, {1, 0, 0}); + glm::mat4 rotated_focus_to_camera = glm::translate(glm::mat4(1), { 0, 0, -c.distance }); + return rotated_focus_to_camera * rotation_phi * rotation_theta * world_to_focus; +} + +glm::mat4 camera_to_world(Camera& c) { return glm::inverse(world_to_camera(c)); } diff --git a/src/camera_poses.cpp b/src/camera_poses.cpp index 0eab81d..88317f5 100644 --- a/src/camera_poses.cpp +++ b/src/camera_poses.cpp @@ -14,11 +14,7 @@ #define NUM_SPHERES_PER_AXE 25 #define SPACE_PER_SPHERE 10.0f -glm::vec4 red_color = glm::vec4(1, 0, 0, 1); -glm::vec4 green_color = glm::vec4(0, 1, 0, 1); -glm::vec4 blue_color = glm::vec4(0, 0, 1, 1); - -bool parse_poses(Array* bodies_out, const char* filepath) { +bool parse_poses(Array* locs_out, const char* filepath) { FILE* fp; if (fopen_s(&fp, filepath, "rb")) { printf("Error parsing %s\n", filepath); @@ -28,8 +24,8 @@ bool parse_poses(Array* bodies_out, const char* filepath) { char delim = ','; char line[LINE_BUF_SIZE]; // because clang refuses to cooperate with my append implementation and generate the function code... - *bodies_out - = { (Body*)malloc(sizeof(Body) * 3 * NUM_SPHERES_PER_AXE * 14), 3 * NUM_SPHERES_PER_AXE * 14 }; + *locs_out = { (glm::mat2x3*)malloc(sizeof(glm::mat2x3) * 3 * NUM_SPHERES_PER_AXE * 14), + 3 * NUM_SPHERES_PER_AXE * 14 }; // read in header fgets(line, LINE_BUF_SIZE, fp); @@ -37,7 +33,6 @@ bool parse_poses(Array* bodies_out, const char* filepath) { fgets(line, LINE_BUF_SIZE, fp); for (int camera_i = 0; !feof(fp); camera_i++) { - Array words = split_str(line, delim); float x = atof(words[0]); float y = atof(words[1]); @@ -47,23 +42,18 @@ bool parse_poses(Array* bodies_out, const char* filepath) { float j = atof(words[5]); float k = atof(words[6]); - glm::mat4 pose = glm::translate(quat_to_mat4(glm::quat(w, i, j, k)), glm::vec3(x, y, z)); - + glm::mat4 pose = quat_to_mat4(glm::quat(w, i, j, k)); + pose[3] = glm::vec4(x, y, z, 1); // Generate axis spheres - for (int i = 0; i < 3; i++) { - for (int j = 0; j < NUM_SPHERES_PER_AXE; j++) { - Body b; - create_new_sphere(&b); + for (int m = 0; m < 3; m++) { + for (int n = 0; n < NUM_SPHERES_PER_AXE; n++) { + glm::mat2x3 loc_color = glm::mat2x3(0.0); + loc_color[0][m] = n * SPACE_PER_SPHERE; + loc_color[0] = pose * glm::vec4(loc_color[0], 1); - // How far along the axis is this ball - glm::vec3 trans = glm::vec3(0, 0, 0); - trans[i] = (float)j * SPACE_PER_SPHERE; - - // Now move the translated pose via the camera's pose - b.pose = pose * glm::translate(b.pose, trans); - b.color = glm::vec4(i == 0 ? 1 : 0, i == 1 ? 1 : 0, i == 2 ? 1 : 0, 1); - b.scale = 3; - bodies_out->data[camera_i*3*NUM_SPHERES_PER_AXE + i*NUM_SPHERES_PER_AXE + j] = b; + loc_color[1] = glm::vec3(0); + loc_color[1][m] = 1.0f; + locs_out->data[camera_i*3*NUM_SPHERES_PER_AXE + m*NUM_SPHERES_PER_AXE + n] = loc_color; } } fgets(line, LINE_BUF_SIZE, fp); diff --git a/src/live_plotter.cpp b/src/live_plotter.cpp new file mode 100644 index 0000000..e7785a3 --- /dev/null +++ b/src/live_plotter.cpp @@ -0,0 +1,288 @@ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "util.hpp" +#include "shaders.hpp" +#include "body.hpp" +#include "camera.hpp" +#include "live_plotter.hpp" + +#define LERP_MOVE_PERIOD_S 0.05 +#define STOP_WAIT_TIME_MS 500 + +struct Point { + bool initialized; + glm::vec3 startloc; + glm::vec3 targetloc; + Body b; + double lifetime_s; + double start_s; +}; + +// Globals +static GLFWwindow* win; +static double prev_cursor_x, prev_cursor_y; +static bool mouse_pressed, scroll_pressed, stop_flag, running; +static Camera camera; +static Viewport viewport; +static uint shader; +static CRITICAL_SECTION cs; +static HANDLE win_thread_h; +static DWORD win_thread_id; +static LARGE_INTEGER fr; +static pointid next_id = 0; +static std::map id_to_point; // Use a pool allocator possibly later +static std::map point_to_id; + +// Constants +const char* vertex_filepath = "src/shaders/vertex.glsl"; +const char* fragment_filepath = "src/shaders/fragment.glsl"; + +// Private foward decls +void _resize_cb(GLFWwindow* win, int w, int h); +void _cursor_pos_cb(GLFWwindow* win, double xpos, double ypos); +void _mouse_button_cb(GLFWwindow* win, int button, int action, int mods); +void _scroll_cb(GLFWwindow* win, double xoffset, double yoffset); +DWORD WINAPI _win_thread(LPVOID); +bool _glfw_setup(); +void _refresh_win(); +double _time(); + +DllExport bool __cdecl start(int win_w, int win_h) { + if (!InitializeCriticalSectionAndSpinCount(&cs, 0x00000400)) + return false; + + if (running) { + printf("Already running! Call stop before calling stop again\n"); + return false; + } + + if (!QueryPerformanceFrequency(&fr)) { + printf("Failed to get the performance counter frequency.\n"); + return false; + } + + glm::vec2* winsize = (glm::vec2*)malloc(sizeof(glm::vec2)); + *winsize = glm::vec2(win_w, win_h); + stop_flag = false; + win_thread_h = CreateThread(NULL, 0, _win_thread, winsize, 0, &win_thread_id); + + running = win_thread_h != NULL; + if (!running) + printf("Error while creating the live plotter window thread.\n"); + return running; +} + +DllExport bool __cdecl stop() { + stop_flag = true; + DWORD res = WaitForSingleObject(win_thread_h, STOP_WAIT_TIME_MS); + bool success = res == WAIT_OBJECT_0; + running = !success; // Consider the app still running if we didn't shut down properly...? + + // TODO: Please wrap away win api synch stuff. thank you + if (!running) DeleteCriticalSection(&cs); + return success; +} + +DllExport pointid __cdecl create_point(float x, float y, float z) { + EnterCriticalSection(&cs); + + Point* p = (Point*)malloc(sizeof(Point)); + *p = { + .initialized = false, + .startloc = glm::vec3(x, y, z), + .targetloc = glm::vec3(x, y, z), + .lifetime_s = INFINITY, + .start_s = _time() + }; + p->b.scale = 1.0f; + p->b.color = glm::vec4(randf() + 0.1, randf() + 0.1, randf() + 0.1, 1); + + pointid id = next_id++; + id_to_point[id] = p; + point_to_id[p] = id; + LeaveCriticalSection(&cs); + return id; +} + +DllExport void __cdecl set_color(pointid id, float r, float g, float b) { + EnterCriticalSection(&cs); + Point* p = id_to_point[id]; + p->b.color = { r, g, b, p->b.color[3] }; + LeaveCriticalSection(&cs); +} + +DllExport void __cdecl set_scale(pointid id, float scale) { + EnterCriticalSection(&cs); + Point* p = id_to_point[id]; + p->b.scale = scale; + LeaveCriticalSection(&cs); +} + +DllExport void __cdecl update_point(pointid id, float x, float y, float z) { + EnterCriticalSection(&cs); + Point* p = id_to_point[id]; + p->targetloc = { x, y, z }; + p->startloc = p->b.pose[3]; + LeaveCriticalSection(&cs); +} + +DllExport void __cdecl set_lifetime(pointid id, float new_lifetime_s) { + EnterCriticalSection(&cs); + Point* p = id_to_point[id]; + p->start_s = _time(); + p->lifetime_s = new_lifetime_s; + LeaveCriticalSection(&cs); +} + +DllExport void __cdecl clear_point(pointid id) { + EnterCriticalSection(&cs); + Point* p = id_to_point[id]; + id_to_point.erase(id); + point_to_id.erase(p); + free(p); + LeaveCriticalSection(&cs); +} + +void _resize_cb(GLFWwindow* win, int w, int h) { + viewport.width = w; + viewport.height = h; + glViewport(0, 0, w, h); +} + +void _cursor_pos_cb(GLFWwindow* win, double xpos, double ypos) { + glm::vec2 dxdy = glm::vec2((xpos - prev_cursor_x), (ypos - prev_cursor_y)); + prev_cursor_x = xpos; + prev_cursor_y = ypos; + if (mouse_pressed) + rotate_camera(camera, dxdy); + if (scroll_pressed) + pan_camera(camera, dxdy); +} + +void _mouse_button_cb(GLFWwindow* win, int button, int action, int mods) { + if (button == GLFW_MOUSE_BUTTON_RIGHT) + mouse_pressed = action == GLFW_PRESS; + if (button == GLFW_MOUSE_BUTTON_MIDDLE) + scroll_pressed = action == GLFW_PRESS; + // glfwGetCursorPos(window, &prev_cursor_x, &prev_cursor_y); Don't think this is necessary +} + +void _scroll_cb(GLFWwindow* win, double xoffset, double yoffset) { zoom_camera(camera, yoffset); } + +DWORD _win_thread(LPVOID args) { + glm::vec2* winsize = (glm::vec2*)args; + camera = make_camera({ 0, 0, 0 }, 3000); + camera.theta = glm::radians(90.0f); + camera.phi = glm::radians(30.0f); + viewport = make_viewport(winsize->x, winsize->y, 45.0f); + if (!_glfw_setup()) { + printf("Failed to initialize glfw window\n"); + return -1; + } + + if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { + printf("Failed to initialize GLAD\n"); + return -1; + } + + if (!load_shader(&shader, vertex_filepath, fragment_filepath)) { + printf("Failed to compile shaders\n"); + return -1; + } + + // This swapping bit is probably unnecessary now that I clear in the loop. + // I was getting a flashing issue during the tutorial... + glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT); // Write to back buffer + glfwSwapBuffers(win); // front buffer is now back + glClear(GL_COLOR_BUFFER_BIT); // Write to back buffer again (former front buf) + glDisable(GL_CULL_FACE); + glEnable(GL_DEPTH_TEST); + + while (!(glfwWindowShouldClose(win) || stop_flag)) + _refresh_win(); + glfwTerminate(); + return 0; +} + +bool _glfw_setup() { + glfwInit(); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + win = glfwCreateWindow(viewport.width, viewport.height, "LivePlotter", NULL, NULL); + if (win == NULL) { + printf("Failed to create GLFW window\n"); + glfwTerminate(); + return false; + } + glfwMakeContextCurrent(win); + glfwSetFramebufferSizeCallback(win, _resize_cb); + glfwSetCursorPosCallback(win, _cursor_pos_cb); + glfwSetMouseButtonCallback(win, _mouse_button_cb); + glfwSetScrollCallback(win, _scroll_cb); + + _cursor_pos_cb(win, 0, 0); + return true; +} + +void _refresh_win() { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + set_uniform(shader, "camera_t", world_to_camera(camera)); + set_uniform(shader, "projection_t", camera_to_projection(viewport)); + + if (TryEnterCriticalSection(&cs)) { + for (const auto& [id, p] : id_to_point) { + // Initialize if not done so yet + if (!p->initialized) { + create_new_sphere(&p->b, p->b.scale); + p->b.shader = shader; + p->b.pose = glm::translate(glm::mat4(1), p->startloc); + p->initialized = true; + } + + // Perform fade + double elapsed_time_s = _time() - p->start_s; + float t = elapsed_time_s / p->lifetime_s; + p->b.color[3] = lerp(1.0, 0.0, t); + + // Lerp position + t = elapsed_time_s / LERP_MOVE_PERIOD_S; + p->b.pose[3] = glm::vec4(lerp(p->startloc, p->targetloc, t), 1); + draw_body(p->b); + } + LeaveCriticalSection(&cs); + } + glfwSwapBuffers(win); + glfwPollEvents(); +} + +double _time() { + LARGE_INTEGER timeticks; + if (!QueryPerformanceCounter(&timeticks)) { + printf("Failed to query performance counter;\n"); + return false; + } + return (double)timeticks.QuadPart / (double)fr.QuadPart; +} + diff --git a/src/main.cpp b/src/main.cpp index 36ff647..3229801 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,249 +1,60 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "util.hpp" -#include "shaders.hpp" -#include "body.hpp" #include "camera_poses.hpp" +#include "live_plotter.hpp" -static GLFWwindow* window; -static float width, height; -static glm::mat4 projection_t; +//void* process_cin(void* args) { +// std::string line; +// while (true) { +// std::getline(std::cin, line); +// Array words = split_str(line.c_str()); +// if (!words.len == 4) +// return NULL; +// printf("Received: %s, %s, %s, %s\n", words[0], words[1], words[2], words[3]); // echo for debugging +// float x = atof(words[1]); +// float y = atof(words[2]); +// float z = atof(words[3]); +// glm::vec3 new_loc = glm::vec3(x, y, z); +// bool found_match = false; +// for (int i = 0; i < camera_bodies.size(); i++) { +// if (strcmp(words[0], camera_bodies[i].name) == 0 && camera_bodies[i].b) { +// Body& b = *camera_bodies[i].b; +// glm::vec4& transl = b.pose[3]; +// transl = (0.8f * transl) + (0.2f * glm::vec4(new_loc, 1)); // lp filter +// int color_i = i + 1; +// b.color = glm::vec4(color_i & 0x4, color_i & 0x2, color_i & 0x1, 1); // reset alpha to 1 +// camera_bodies[i].hp = max_hp; +// found_match = true; +// } else if (camera_bodies[i].b) { +// float& cur_hp = camera_bodies[i].hp; +// if (cur_hp > 0) +// cur_hp -= 1; +// camera_bodies[i].b->color = glm::vec4(i & 0x4, i & 0x2, i & 0x1, cur_hp / max_hp); +// } +// } +// if (!found_match) { +// auto read = BarcodeRead { words[0], (Body*)NULL, max_hp }; +// camera_bodies.push_back(read); +// } +// } +//} -void framebuffer_size_callback(GLFWwindow* window, int w, int h) { - width = w; - height = h; - glViewport(0, 0, width, height); - projection_t = glm::infinitePerspective(glm::radians(45.0f), (float)width / (float)height, 0.1f); -} - -void process_input() { - if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) - glfwSetWindowShouldClose(window, true); -} - -static bool stop = false; -static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; -const float max_hp - = 10; // Number of scans (without a particular barcode) for which the sphere will still be visible - -struct BarcodeRead { - char* name; - Body* b; - float hp; -}; -static std::vector camera_bodies; // I would use my array here, but was getting a linking error - -void* process_cin(void* args) { - std::string line; - while (true) { - std::getline(std::cin, line); - Array words = split_str(line.c_str()); - if (!words.len == 4) return NULL; - printf("Received: %s, %s, %s, %s\n", words[0], words[1], words[2], words[3]); // echo for debugging - float x = atof(words[1]); - float y = atof(words[2]); - float z = atof(words[3]); - glm::vec3 new_loc = glm::vec3(x, y, z); - bool found_match = false; - pthread_mutex_lock(&lock); - for (int i = 0; i < camera_bodies.size(); i++) { - if (strcmp(words[0], camera_bodies[i].name) == 0 && camera_bodies[i].b) { - Body& b = *camera_bodies[i].b; - glm::vec4& transl = b.pose[3]; - transl = (0.8f * transl) + (0.2f * glm::vec4(new_loc, 1)); // lp filter - int color_i = i + 1; - b.color = glm::vec4(color_i & 0x4, color_i & 0x2, color_i & 0x1, 1); // reset alpha to 1 - camera_bodies[i].hp = max_hp; - found_match = true; - } else if (camera_bodies[i].b) { - float& cur_hp = camera_bodies[i].hp; - if (cur_hp > 0) - cur_hp -= 1; - camera_bodies[i].b->color = glm::vec4(i & 0x4, i & 0x2, i & 0x1, cur_hp / max_hp); - } - } - if (!found_match) { - auto read = BarcodeRead { words[0], (Body*)NULL, max_hp }; - camera_bodies.push_back(read); - } - pthread_mutex_unlock(&lock); - } -} - -static bool mouse_pressed = false; -static bool scroll_pressed = false; -static double prev_cursor_x, prev_cursor_y; - -static double theta = 0.0; // angle of camera trans vect wrt x-z plane -static double phi = glm::radians(270.0); // angle of camera trans vect wrt x-axis - -static glm::vec3 focal_point = glm::vec3(0, 0, 500); -static glm::vec3 camera_loc = glm::vec3(0, 4000, 0); -static glm::vec3 up = glm::vec3(0, 1, 0); -static glm::mat4 world_to_camera = glm::lookAt(camera_loc, focal_point, up); - -static void cursor_position_callback(GLFWwindow* window, double xpos, double ypos) { - float dx = (xpos - prev_cursor_x); - float dy = (ypos - prev_cursor_y); - - glm::mat4 camera_to_world = glm::inverse(world_to_camera); - // These could be acquired via some cross products. Don't know if that's more efficient. - glm::vec4 strafe_x = camera_to_world[0]; - glm::vec4 strafe_y = camera_to_world[1]; - prev_cursor_x = xpos; - prev_cursor_y = ypos; - - double len = glm::length(camera_loc - focal_point); - - if (mouse_pressed) { - phi += glm::radians(dx * (360 / width)); // * glm::radians(360.0); - theta += glm::radians(dy * (360 / height)); // * glm::radians(360.0); - camera_loc.x = focal_point.x + (len * glm::cos(theta) * glm::cos(-phi)); - camera_loc.y = focal_point.y + (len * glm::sin(theta)); - camera_loc.z = focal_point.z + (-len * glm::cos(theta) * glm::sin(-phi)); - } - - if (scroll_pressed) { - glm::vec4 move_vec = glm::max((float)len, 20.0f) * (- strafe_x * (dx / 500) + strafe_y * (dy / 500)); - focal_point += move_vec; - camera_loc += move_vec; - } - - world_to_camera = glm::lookAt(camera_loc, focal_point, up); -} - -void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) { - if (button == GLFW_MOUSE_BUTTON_RIGHT) { - mouse_pressed = action == GLFW_PRESS; - } - - if (button == GLFW_MOUSE_BUTTON_MIDDLE) { - scroll_pressed = action == GLFW_PRESS; - } - - glfwGetCursorPos(window, &prev_cursor_x, &prev_cursor_y); -} - -void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { - glm::vec3 k = camera_loc - focal_point; - camera_loc -= k * (float)yoffset / 10.0f; - world_to_camera = glm::lookAt(camera_loc, focal_point, up); -} - -bool glfw_setup() { - glfwInit(); - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); - // glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); - window = glfwCreateWindow(800, 800, "LivePlotter", NULL, NULL); - if (window == NULL) { - printf("Failed to create GLFW window\n"); - glfwTerminate(); - return false; - } - glfwMakeContextCurrent(window); - glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); - glfwSetCursorPosCallback(window, cursor_position_callback); - glfwSetMouseButtonCallback(window, mouse_button_callback); - glfwSetScrollCallback(window, scroll_callback); - - cursor_position_callback(window, 0, 0); - return true; -} int main() { - if (!glfw_setup()) - return -1; - - if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { - printf("Failed to initialize GLAD\n"); - return -1; - } - glViewport(0, 0, 800, 800); - width = 800; - height = 800; - - const char* vertex_filepath = "src/shaders/vertex.glsl"; - const char* fragment_filepath = "src/shaders/fragment.glsl"; - uint shader; - if (!load_shader(&shader, vertex_filepath, fragment_filepath)) - return -1; - - //glClearColor(0.2f, 0.3f, 0.3f, 1.0f); - glClearColor(0, 0, 0, 0); - glClear(GL_COLOR_BUFFER_BIT); // Write to back buffer - - glfwSwapBuffers(window); // front buffer is now back - glClear(GL_COLOR_BUFFER_BIT); // Write to back buffer again (former front buf) - - // glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - // set_uniform(shader, "color", glm::vec4 { sin(time), sin(time + glm::radians(45.0f)), sin(time + - // glm::radians(90.0f)), 1.0 } / 2.0f); time = glfwGetTime(); - - glDisable(GL_CULL_FACE); - glEnable(GL_DEPTH_TEST); - - projection_t = glm::infinitePerspective(glm::radians(45.0f), (float)width / (float)height, 0.1f); - pthread_t thread_id; - pthread_create(&thread_id, NULL, process_cin, NULL); - - Array camera_pose_axes = { NULL, 0 }; + Array camera_pose_axes = { NULL, 0 }; if (!parse_poses(&camera_pose_axes, "poses.csv")) { return -1; } + + start(800, 800); + for (int i = 0; i < camera_pose_axes.len; i++) { - camera_pose_axes[i].shader = shader; + glm::vec3 p = camera_pose_axes[i][0]; + glm::vec3 color = camera_pose_axes[i][1]; + pointid id = create_point(p.x, p.y, p.z); + set_color(id, color.x, color.y, color.z); + set_scale(id, 10); } - /*Body b; - create_new_sphere(&b); - b.pose = glm::mat4(1); - b.color = glm::vec4(1, 1, 1, 1); - b.shader = shader;*/ - - while (!glfwWindowShouldClose(window)) { - process_input(); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - set_uniform(shader, "camera_t", world_to_camera); - set_uniform(shader, "projection_t", projection_t); - - //draw_body(b); - - for (int i = 0; i < camera_pose_axes.len; i++) { - draw_body(camera_pose_axes[i]); - } - - if (pthread_mutex_trylock(&lock) == 0) { - for (int i = 0; i < camera_bodies.size(); i++) { - if (!camera_bodies[i].b) { - Body* b = (Body*)malloc(sizeof(Body)); - create_new_sphere(b); - b->color = glm::vec4((i+1) & 0x4, (i+1) & 0x2, (i+1) & 0x1, max_hp); - b->scale = 25; - b->shader = shader; - camera_bodies[i].b = b; - } - draw_body(*camera_bodies[i].b); - } - pthread_mutex_unlock(&lock); - } - - glfwSwapBuffers(window); - glfwPollEvents(); - } - glfwTerminate(); - return 0; + while (true) + ; } diff --git a/src/util.cpp b/src/util.cpp index 7882d8b..8efd60b 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -93,7 +93,6 @@ Array _split_str_inner(const char* s, char delim, bool just_check_ws) { return res; } - // https://songho.ca/opengl/gl_quaternion.html glm::mat4 quat_to_mat4(glm::quat q) { glm::vec4 col0 = glm::vec4( @@ -109,3 +108,7 @@ glm::mat4 quat_to_mat4(glm::quat q) { return glm::mat4(col0, col1, col2, col3); } + +float randf() { + return (float)rand() / (float)RAND_MAX; +} From e5a8f88556f2c551464b4b50bdbb1558ff23eeb4 Mon Sep 17 00:00:00 2001 From: Seth Hamilton Date: Mon, 25 Aug 2025 03:43:30 -0500 Subject: [PATCH 2/4] Enable alpha blending. main reads from stdin --- src/live_plotter.cpp | 8 ++++- src/main.cpp | 62 +++++++++++++++------------------------ src/shaders/fragment.glsl | 2 +- 3 files changed, 32 insertions(+), 40 deletions(-) diff --git a/src/live_plotter.cpp b/src/live_plotter.cpp index e7785a3..9511973 100644 --- a/src/live_plotter.cpp +++ b/src/live_plotter.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "util.hpp" #include "shaders.hpp" @@ -143,6 +144,7 @@ DllExport void __cdecl update_point(pointid id, float x, float y, float z) { Point* p = id_to_point[id]; p->targetloc = { x, y, z }; p->startloc = p->b.pose[3]; + p->start_s = _time(); LeaveCriticalSection(&cs); } @@ -218,6 +220,8 @@ DWORD _win_thread(LPVOID args) { glClear(GL_COLOR_BUFFER_BIT); // Write to back buffer again (former front buf) glDisable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); while (!(glfwWindowShouldClose(win) || stop_flag)) _refresh_win(); @@ -264,10 +268,12 @@ void _refresh_win() { // Perform fade double elapsed_time_s = _time() - p->start_s; float t = elapsed_time_s / p->lifetime_s; - p->b.color[3] = lerp(1.0, 0.0, t); + t = std::clamp(t, 0.0f, 1.0f); + p->b.color.w = lerp(1.0, 0.0, t); // Lerp position t = elapsed_time_s / LERP_MOVE_PERIOD_S; + t = std::clamp(t, 0.0f, 1.0f); p->b.pose[3] = glm::vec4(lerp(p->startloc, p->targetloc, t), 1); draw_body(p->b); } diff --git a/src/main.cpp b/src/main.cpp index 3229801..50493b9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,43 +1,11 @@ +#include +#include +#include #include "camera_poses.hpp" #include "live_plotter.hpp" -//void* process_cin(void* args) { -// std::string line; -// while (true) { -// std::getline(std::cin, line); -// Array words = split_str(line.c_str()); -// if (!words.len == 4) -// return NULL; -// printf("Received: %s, %s, %s, %s\n", words[0], words[1], words[2], words[3]); // echo for debugging -// float x = atof(words[1]); -// float y = atof(words[2]); -// float z = atof(words[3]); -// glm::vec3 new_loc = glm::vec3(x, y, z); -// bool found_match = false; -// for (int i = 0; i < camera_bodies.size(); i++) { -// if (strcmp(words[0], camera_bodies[i].name) == 0 && camera_bodies[i].b) { -// Body& b = *camera_bodies[i].b; -// glm::vec4& transl = b.pose[3]; -// transl = (0.8f * transl) + (0.2f * glm::vec4(new_loc, 1)); // lp filter -// int color_i = i + 1; -// b.color = glm::vec4(color_i & 0x4, color_i & 0x2, color_i & 0x1, 1); // reset alpha to 1 -// camera_bodies[i].hp = max_hp; -// found_match = true; -// } else if (camera_bodies[i].b) { -// float& cur_hp = camera_bodies[i].hp; -// if (cur_hp > 0) -// cur_hp -= 1; -// camera_bodies[i].b->color = glm::vec4(i & 0x4, i & 0x2, i & 0x1, cur_hp / max_hp); -// } -// } -// if (!found_match) { -// auto read = BarcodeRead { words[0], (Body*)NULL, max_hp }; -// camera_bodies.push_back(read); -// } -// } -//} - +static std::map name_to_id; int main() { Array camera_pose_axes = { NULL, 0 }; @@ -55,6 +23,24 @@ int main() { set_scale(id, 10); } - while (true) - ; + while (true) { + std::string line; + std::getline(std::cin, line); + Array words = split_str(line.c_str()); + if (!words.len == 4) + return NULL; + printf("Received: %s, %s, %s, %s\n", words[0], words[1], words[2], words[3]); // echo for debugging + std::string name = std::string(words[0]); + float x = atof(words[1]); + float y = atof(words[2]); + float z = atof(words[3]); + + if (auto it = name_to_id.find(name); it != name_to_id.end()) { + update_point(it->second, x, y, z); + } else { + name_to_id[name] = create_point(x, y, z); + set_lifetime(name_to_id[name], 0.2); + set_scale(name_to_id[name], 15); + } + } } diff --git a/src/shaders/fragment.glsl b/src/shaders/fragment.glsl index 323267a..d64db91 100644 --- a/src/shaders/fragment.glsl +++ b/src/shaders/fragment.glsl @@ -10,7 +10,7 @@ void main() { vec3 dx = dFdx(frag_pos) * 500; vec3 dy = dFdy(frag_pos) * 500; vec3 N = normalize(cross(dFdx(frag_pos), dFdy(frag_pos))); - frag_color = color + vec4(N/2, 1)/2; + frag_color = color; //frag_color = vec4(length(dx), length(dy), length(dy), 1.0); //frag_color += color; } From c403b06bd9b61b65034688e9f06a47b065cc9155 Mon Sep 17 00:00:00 2001 From: Seth Hamilton Date: Mon, 25 Aug 2025 04:05:41 -0500 Subject: [PATCH 3/4] remove pthread win wrapper --- .gitmodules | 3 --- LivePlotter.vcxproj | 24 +++++++++--------------- ext/pthreads4w-code | 1 - src/live_plotter.cpp | 1 - 4 files changed, 9 insertions(+), 20 deletions(-) delete mode 160000 ext/pthreads4w-code diff --git a/.gitmodules b/.gitmodules index 1749696..3167aa9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,3 @@ [submodule "ext/glm"] path = ext/glm url = https://github.com/g-truc/glm.git -[submodule "ext/pthreads4w-code"] - path = ext/pthreads4w-code - url = https://git.code.sf.net/p/pthreads4w/code diff --git a/LivePlotter.vcxproj b/LivePlotter.vcxproj index a2131d0..e784240 100644 --- a/LivePlotter.vcxproj +++ b/LivePlotter.vcxproj @@ -97,15 +97,15 @@ - $(SolutionDir)lib;$(SolutionDir)ext\pthreads4w-code\build\Debug;$(SolutionDir)ext\glfw\build\src\Debug;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64) - $(SolutionDir)ext\pthreads4w-code;$(SolutionDir)ext\glm;$(SolutionDir)ext\glfw\include;$(SolutionDir)inc;$(IncludePath) + $(SolutionDir)lib;$(SolutionDir)ext\glfw\build\src\Debug;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64) + $(SolutionDir)ext\glm;$(SolutionDir)ext\glfw\include;$(SolutionDir)inc;$(IncludePath) $(SolutionDir)bin\$(Platform)\$(Configuration)\ $(SolutionDir)obj\$(Platform)\$(Configuration)\ $(SolutionDir)src;$(SourcePath) - $(SolutionDir)lib;$(SolutionDir)ext\pthreads4w-code\build\Debug;$(SolutionDir)ext\glfw\build\src\Debug;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64) - $(SolutionDir)ext\pthreads4w-code;$(SolutionDir)ext\glm;$(SolutionDir)ext\glfw\include;$(SolutionDir)inc;$(IncludePath) + $(SolutionDir)lib;$(SolutionDir)ext\glfw\build\src\Debug;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64) + $(SolutionDir)ext\glm;$(SolutionDir)ext\glfw\include;$(SolutionDir)inc;$(IncludePath) $(SolutionDir)bin\$(Platform)\$(Configuration)\ $(SolutionDir)obj\$(Platform)\$(Configuration)\ $(SolutionDir)src;$(SourcePath) @@ -161,10 +161,10 @@ Console true - ext\pthreads4w-code\build\Debug\pthreadVC3d.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies) + glfw3.lib;opengl32.lib;%(AdditionalDependencies) - xcopy /y "$(SolutionDir)poses.csv" "$(OutDir)" && xcopy /y "$(SolutionDir)ext\pthreads4w-code\build\Debug\pthreadVC3d.dll" "$(OutDir)" + xcopy /y "$(SolutionDir)poses.csv" "$(OutDir)" @@ -178,10 +178,10 @@ Console true - ext\pthreads4w-code\build\Debug\pthreadVC3d.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies) + glfw3.lib;opengl32.lib;%(AdditionalDependencies) - xcopy /y "$(SolutionDir)poses.csv" "$(OutDir)" && xcopy /y "$(SolutionDir)ext\pthreads4w-code\build\Debug\pthreadVC3d.dll" "$(OutDir)" + xcopy /y "$(SolutionDir)poses.csv" "$(OutDir)" @@ -213,10 +213,4 @@ - - - - - - - \ No newline at end of file + diff --git a/ext/pthreads4w-code b/ext/pthreads4w-code deleted file mode 160000 index 8e467a6..0000000 --- a/ext/pthreads4w-code +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8e467a62a14fd9de15af33beec0a913d23f4d2f9 diff --git a/src/live_plotter.cpp b/src/live_plotter.cpp index 9511973..5b9a0dc 100644 --- a/src/live_plotter.cpp +++ b/src/live_plotter.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include From 13fcaede51bff20ce521dd8ab7f3f8fc1fce90fd Mon Sep 17 00:00:00 2001 From: Seth Hamilton Date: Mon, 25 Aug 2025 04:11:43 -0500 Subject: [PATCH 4/4] temporarily disable main.cpp --- src/main.cpp | 92 ++++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 50493b9..617bc34 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,46 +1,46 @@ -#include -#include -#include - -#include "camera_poses.hpp" -#include "live_plotter.hpp" - -static std::map name_to_id; - -int main() { - Array camera_pose_axes = { NULL, 0 }; - if (!parse_poses(&camera_pose_axes, "poses.csv")) { - return -1; - } - - start(800, 800); - - for (int i = 0; i < camera_pose_axes.len; i++) { - glm::vec3 p = camera_pose_axes[i][0]; - glm::vec3 color = camera_pose_axes[i][1]; - pointid id = create_point(p.x, p.y, p.z); - set_color(id, color.x, color.y, color.z); - set_scale(id, 10); - } - - while (true) { - std::string line; - std::getline(std::cin, line); - Array words = split_str(line.c_str()); - if (!words.len == 4) - return NULL; - printf("Received: %s, %s, %s, %s\n", words[0], words[1], words[2], words[3]); // echo for debugging - std::string name = std::string(words[0]); - float x = atof(words[1]); - float y = atof(words[2]); - float z = atof(words[3]); - - if (auto it = name_to_id.find(name); it != name_to_id.end()) { - update_point(it->second, x, y, z); - } else { - name_to_id[name] = create_point(x, y, z); - set_lifetime(name_to_id[name], 0.2); - set_scale(name_to_id[name], 15); - } - } -} +//#include +//#include +//#include +// +//#include "camera_poses.hpp" +//#include "live_plotter.hpp" +// +//static std::map name_to_id; +// +//int main() { +// Array camera_pose_axes = { NULL, 0 }; +// if (!parse_poses(&camera_pose_axes, "poses.csv")) { +// return -1; +// } +// +// start(800, 800); +// +// for (int i = 0; i < camera_pose_axes.len; i++) { +// glm::vec3 p = camera_pose_axes[i][0]; +// glm::vec3 color = camera_pose_axes[i][1]; +// pointid id = create_point(p.x, p.y, p.z); +// set_color(id, color.x, color.y, color.z); +// set_scale(id, 10); +// } +// +// while (true) { +// std::string line; +// std::getline(std::cin, line); +// Array words = split_str(line.c_str()); +// if (!words.len == 4) +// return NULL; +// printf("Received: %s, %s, %s, %s\n", words[0], words[1], words[2], words[3]); // echo for debugging +// std::string name = std::string(words[0]); +// float x = atof(words[1]); +// float y = atof(words[2]); +// float z = atof(words[3]); +// +// if (auto it = name_to_id.find(name); it != name_to_id.end()) { +// update_point(it->second, x, y, z); +// } else { +// name_to_id[name] = create_point(x, y, z); +// set_lifetime(name_to_id[name], 0.2); +// set_scale(name_to_id[name], 15); +// } +// } +//}