reorganize to use .bat files instead of .sh. Move demo to an example project
This commit is contained in:
@@ -1,93 +0,0 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include "glm/ext/vector_float3.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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
#version 330 core
|
||||
|
||||
uniform vec4 color;
|
||||
|
||||
in vec3 frag_pos;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
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;
|
||||
//frag_color = vec4(length(dx), length(dy), length(dy), 1.0);
|
||||
//frag_color += color;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
#version 330 core
|
||||
|
||||
layout (location = 0) in vec3 pos;
|
||||
out vec3 frag_pos;
|
||||
|
||||
uniform mat4 global_t;
|
||||
uniform mat4 camera_t;
|
||||
uniform mat4 projection_t;
|
||||
|
||||
void main() {
|
||||
gl_Position = projection_t * camera_t * global_t * vec4(pos.x, pos.y, pos.z, 1.0);
|
||||
frag_pos = pos;
|
||||
}
|
||||
@@ -1,7 +1,3 @@
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "util.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Reference in New Issue
Block a user