vj parser

This commit is contained in:
maxbyte9p
2024-05-20 11:31:53 -04:00
parent 2a8b371b89
commit 8fee6a54f3

View File

@@ -6,6 +6,39 @@
#include <J3ML/LinearAlgebra.h>
#include <Collage/types/model.h>
// Parse vertex joints
std::vector<std::tuple<int, int, int, int>> parse_vj(std::istringstream& s, std::ifstream& f) {
// Get vertex joints count
int vjcnt;
s >> vjcnt;
std::cout << "vj " << vjcnt << std::endl;
// Store our vertex joints for returning later
std::vector<std::tuple<int, int, int, int>> vj;
// Parse until vjcnt
int i;
for (i=0; i<vjcnt; i++) {
std::string l;
if (getline(f, l)) {
std::istringstream stream(l);
int x = 0;
int y = 0;
int z = 0;
int a = 0;
stream >> x >> y >> z >> a;
// For debugging -> std::cout << l << std::endl;
vj.push_back({x,y,z,a});
} else {
break;
}
}
return vj;
}
// Parse Vertex Normals
std::vector<std::tuple<float, float, float>> parse_vn(std::istringstream& s, std::ifstream& f) {
// Get vertex normals count
@@ -166,6 +199,12 @@ void Model::loadAMO(const std::string& filename) {
for (const std::tuple<float, float, float>& i : vn) {
std::cout << get<0>(i) << " " << get<1>(i) << " " << get<2>(i) << std::endl;
}
} else if (prefix == "vj") {
std::vector<std::tuple<int, int, int, int>> vj;
vj = parse_vj(stream, file);
for (const std::tuple<int, int, int, int>& i : vj) {
std::cout << get<0>(i) << " " << get<1>(i) << " " << get<2>(i) << " " << get<3>(i) << std::endl;
}
}
}