axis spheres still aren't showing, but some obvious bugs were removed. still debugging

This commit is contained in:
2025-08-22 11:13:16 -05:00
parent 19f786ee7c
commit a79b074201
6 changed files with 39 additions and 34 deletions

View File

@@ -10,8 +10,7 @@
#include "camera_poses.hpp"
#define LINE_BUF_SIZE 128
#define LINE_BUF_SIZE 256
#define NUM_SPHERES_PER_AXE 25
#define SPACE_PER_SPHERE 10.0f
@@ -21,8 +20,8 @@ glm::vec4 blue_color = glm::vec4(0, 0, 1, 1);
bool parse_poses(Array<Body>* bodies_out, const char* filepath) {
FILE* fp;
if (!fopen_s(&fp, filepath, "rb")) {
printf("Error parsing poses csv: %s\n", filepath);
if (fopen_s(&fp, filepath, "rb")) {
printf("Error parsing %s\n", filepath);
return false;
}
@@ -32,13 +31,14 @@ bool parse_poses(Array<Body>* bodies_out, const char* filepath) {
// read in header
fgets(line, LINE_BUF_SIZE, fp);
while (!feof(fp)) {
fgets(line, LINE_BUF_SIZE, fp);
fgets(line, LINE_BUF_SIZE, fp);
for (int camera_i = 0; !feof(fp); camera_i++) {
Array<char*> words = split_str(line, delim);
float x = atof(words[0]);
float y = atof(words[1]);
float z = atof(words[2]);
float x = atof(words[0])/100.0f;
float y = atof(words[1])/100.0f;
float z = atof(words[2])/100.0f;
float w = atof(words[3]);
float i = atof(words[4]);
float j = atof(words[5]);
@@ -54,9 +54,7 @@ bool parse_poses(Array<Body>* bodies_out, const char* filepath) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < NUM_SPHERES_PER_AXE; j++) {
Body b;
if (!load_body(&b, "Icosphere.obj")) {
return false;
}
create_new_sphere(&b);
// How far along the axis is this ball
glm::vec3 trans = glm::vec3(0, 0, 0);
@@ -64,8 +62,12 @@ bool parse_poses(Array<Body>* bodies_out, const char* filepath) {
// Now move the translated pose via the camera's pose
b.pose = pose * glm::translate(b.pose, trans);
bodies_out->data[i*j + j] = b;
b.color = glm::vec4(i == 0 ? 1 : 0, i == 1 ? 1 : 0, i == 2 ? 1 : 0, 1);
b.scale = 0.2;
printf("%d, ", camera_i * 3 * NUM_SPHERES_PER_AXE + i * NUM_SPHERES_PER_AXE + j);
bodies_out->data[camera_i*3*NUM_SPHERES_PER_AXE + i*NUM_SPHERES_PER_AXE + j] = b;
}
}
fgets(line, LINE_BUF_SIZE, fp);
}
}