106 lines
3.0 KiB
C++
106 lines
3.0 KiB
C++
#include <iostream>
|
|
#include <string>
|
|
#include <map>
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <glm/glm.hpp>
|
|
#include <glm/ext/matrix_clip_space.hpp>
|
|
#include <glm/ext/matrix_transform.hpp>
|
|
#include <glm/ext/vector_float3.hpp>
|
|
#include <glm/matrix.hpp>
|
|
|
|
#include "util.hpp"
|
|
#include "live_plotter.hpp"
|
|
|
|
#pragma comment(lib, "LivePlotter.lib")
|
|
|
|
using namespace std;
|
|
|
|
static map<string, pointid> name_to_id;
|
|
|
|
#define LINE_BUF_SIZE 256
|
|
#define NUM_SPHERES_PER_AXE 25
|
|
#define SPACE_PER_SPHERE 10.0f
|
|
|
|
bool parse_poses(std::vector<glm::mat2x3>& locs_out, const char* filepath) {
|
|
ifstream file(filepath);
|
|
if (!file.is_open()) {
|
|
return false;
|
|
}
|
|
|
|
string line;
|
|
getline(file, line);
|
|
while (getline(file, line)) {
|
|
std::vector<std::string> words = split_str(line, ',');
|
|
float x = stof(words[0]);
|
|
float y = stof(words[1]);
|
|
float z = stof(words[2]);
|
|
float w = stof(words[3]);
|
|
float i = stof(words[4]);
|
|
float j = stof(words[5]);
|
|
float k = stof(words[6]);
|
|
|
|
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 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);
|
|
|
|
loc_color[1] = glm::vec3(0);
|
|
loc_color[1][m] = 1.0f;
|
|
locs_out.push_back(loc_color);
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
int main() {
|
|
vector<glm::mat2x3> camera_pose_axes;
|
|
if (!parse_poses(camera_pose_axes, "poses.csv")) {
|
|
return -1;
|
|
}
|
|
|
|
start(800, 800);
|
|
pointid id = create_point(0, 0, 0);
|
|
set_color(id, 1, 1, 1);
|
|
set_scale(id, 10);
|
|
|
|
while (true)
|
|
;
|
|
|
|
//for (int i = 0; i < camera_pose_axes.size(); 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) {
|
|
// string line;
|
|
// getline(cin, line);
|
|
// vector<string> words = split_str(line, ' ');
|
|
// if (!words.size() == 4)
|
|
// return NULL;
|
|
// printf("Received: %s, %s, %s, %s\n", words[0].c_str(), words[1].c_str(), words[2].c_str(),
|
|
// words[3].c_str()); // echo for debugging
|
|
// string name = words[0];
|
|
// float x = stof(words[1]);
|
|
// float y = stof(words[2]);
|
|
// float z = stof(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);
|
|
// }
|
|
//}
|
|
}
|