wrote vw parser
This commit is contained in:
41
src/amo.cpp
41
src/amo.cpp
@@ -6,6 +6,40 @@
|
||||
#include <J3ML/LinearAlgebra.h>
|
||||
#include <Collage/types/model.h>
|
||||
|
||||
// Parse vertex weights
|
||||
std::vector<std::tuple<float, float, float, float>> parse_vw(std::istringstream& s, std::ifstream& f) {
|
||||
// Get vertex weights count
|
||||
int vwcnt;
|
||||
s >> vwcnt;
|
||||
std::cout << "vw " << vwcnt << std::endl;
|
||||
|
||||
// Store our vertex weights for returning later
|
||||
std::vector<std::tuple<float, float, float, float>> vw;
|
||||
|
||||
// Parse until vwcnt
|
||||
int i;
|
||||
for (i=0; i<vwcnt; i++) {
|
||||
std::string l;
|
||||
|
||||
if (getline(f, l)) {
|
||||
std::istringstream stream(l);
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
float z = 0;
|
||||
float a = 0;
|
||||
stream >> x >> y >> z >> a;
|
||||
// For debugging -> std::cout << l << std::endl;
|
||||
|
||||
vw.push_back({x,y,z,a});
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return vw;
|
||||
}
|
||||
|
||||
|
||||
// Parse vertex joints
|
||||
std::vector<std::tuple<int, int, int, int>> parse_vj(std::istringstream& s, std::ifstream& f) {
|
||||
// Get vertex joints count
|
||||
@@ -205,7 +239,14 @@ void Model::loadAMO(const std::string& filename) {
|
||||
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;
|
||||
}
|
||||
} else if (prefix == "vw") {
|
||||
std::vector<std::tuple<float, float, float, float>> vw;
|
||||
vw = parse_vw(stream, file);
|
||||
for (const std::tuple<float, float, float, float>& i : vw) {
|
||||
std::cout << get<0>(i) << " " << get<1>(i) << " " << get<2>(i) << " " << get<3>(i) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
Reference in New Issue
Block a user