diff --git a/LivePlotter.vcxproj b/LivePlotter.vcxproj
index 4030fce..1e30ef5 100644
--- a/LivePlotter.vcxproj
+++ b/LivePlotter.vcxproj
@@ -140,7 +140,6 @@
-
diff --git a/LivePlotter.vcxproj.filters b/LivePlotter.vcxproj.filters
index 8e596b3..23a472a 100644
--- a/LivePlotter.vcxproj.filters
+++ b/LivePlotter.vcxproj.filters
@@ -30,8 +30,5 @@
Source Files
-
- Source Files
-
\ No newline at end of file
diff --git a/src/main.cpp b/src/main.cpp
index fe2112c..0d8694e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,3 +1,4 @@
+#include
#include
#include
#include
@@ -9,6 +10,7 @@
#include
#include
#include
+#include
#include "util.hpp"
#include "shaders.hpp"
@@ -28,31 +30,58 @@ void process_input() {
glfwSetWindowShouldClose(window, true);
}
+static uint shader;
+body create_new_sphere() {
+ body b;
+ assert(load_body(&b, "Icosphere.obj"));
+ b.shader = shader;
+ b.pose = glm::translate(b.pose, glm::vec3(0, 0, 0));
+ return b;
+}
+
static bool stop = false;
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
-static std::map> camera_name_to_bodies;
+const float max_hp = 10; // Number of scans (without a particular barcode) for which the sphere will still be visible
+array> camera_bodies;
-enum class LineParserState {
- NAME,
- X,
- Y,
- Z
-};
-// name x y z\n
-void process_cin(void* args) {
- size_t len = 256;
- std::string line;
- while (true) {
- std::getline(std::cin, line);
- array words = split_str(line.c_str());
- assert(words.len == 4);
- pthread_mutex_lock(&lock);
- for (int i = 0; i < words.len; i++) {
- if (camera_name_to_bodies.find(words
- }
- pthread_mutex_unlock(&lock);
- }
-}
+//void process_cin(void* args) {
+// size_t len = 256;
+// std::string line;
+// while (true) {
+// std::getline(std::cin, line);
+// array words = split_str(line.c_str());
+// assert(words.len == 4);
+// printf("Received: %s, %s, %s, %s\n", words[0], words[1], words[2], words[3]); // echo for debugging
+// pthread_mutex_lock(&lock);
+// 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.len; i++) {
+// if (strcmp(words[0], std::get<0>(camera_bodies[i])) == 0) {
+// glm::vec4 &transl = std::get<1>(camera_bodies[i]).pose[4];
+// transl = 0.9f*transl + 0.1f*glm::vec4(new_loc, 1); // filter
+//
+// std::get<1>(camera_bodies[i]).color = glm::vec4(i&0x4, i&0x2, i&0x1, 1);
+// std::get<2>(camera_bodies[i]) = max_hp;
+// found_match = true;
+// } else {
+// float &cur_hp = std::get<2>(camera_bodies[i]);
+// if (cur_hp > 0) cur_hp -= 1;
+// std::get<1>(camera_bodies[i]).color = glm::vec4(i&0x4, i&0x2, i&0x1, cur_hp/max_hp);
+// }
+// }
+// if (!found_match) {
+// body b = create_new_sphere();
+// int i = camera_bodies.len;
+// b.color = glm::vec4(i&0x4, i&0x2, i&0x1, max_hp);
+// auto t = std::make_tuple(words[0], b, max_hp);
+// append(camera_bodies, t);
+// }
+// pthread_mutex_unlock(&lock);
+// }
+//}
static bool mouse_pressed = false;
static bool scroll_pressed = false;
@@ -109,7 +138,7 @@ void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) {
glm::vec4 k = camera_t[2];
float d = yoffset;
- camera_loc += k * (d / 10 * max(glm::length(camera_loc), 1.0f));
+ camera_loc += k * (d / 10 * glm::max(glm::length(camera_loc), 1.0f));
camera_t = glm::lookAt(camera_loc, focal_point, up);
}
@@ -148,7 +177,6 @@ int main() {
width = 800;
height = 800;
- uint shader;
const char* vertex_filepath = "src/shaders/vertex.glsl";
const char* fragment_filepath = "src/shaders/fragment.glsl";
if (!load_shader(&shader, vertex_filepath, fragment_filepath))
@@ -161,18 +189,7 @@ int main() {
glfwSwapBuffers(window); // front buffer is now back
glClear(GL_COLOR_BUFFER_BIT); // Write to back buffer again (former front buf)
- body b;
- if (!load_body(&b, "Icosphere.obj"))
- return -1;
- b.shader = shader;
- b.pose = glm::translate(b.pose, glm::vec3(0, 0, 0));
- b.color = glm::vec4(0.5, 0, 0, 1);
-
- body b2;
- if (!load_body(&b2, "Icosphere.obj"))
- return -1;
- b2.shader = shader;
- b2.pose = glm::translate(b.pose, glm::vec3(2, 0, 0));
+ body b2 = create_new_sphere();
b2.color = glm::vec4(0, 0.5, 0, 1);
// glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
@@ -188,12 +205,10 @@ int main() {
while (!glfwWindowShouldClose(window)) {
process_input();
- process_cin();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
set_uniform(shader, "camera_t", camera_t);
set_uniform(shader, "projection_t", projection_t);
- draw_body(b);
draw_body(b2);
glfwSwapBuffers(window);