cleaned up vt parse
This commit is contained in:
58
src/amo.cpp
58
src/amo.cpp
@@ -231,6 +231,51 @@ std::vector<Vnormal> parse_vn(std::istringstream& s, std::ifstream& f) {
|
||||
return vn;
|
||||
}
|
||||
|
||||
struct Vtexture {
|
||||
std::vector<float> n;
|
||||
};
|
||||
|
||||
void operator>>(std::istream& in, Vtexture& q) {
|
||||
int i;
|
||||
for (i=0; i<2; i++) {
|
||||
float v;
|
||||
in >> v;
|
||||
q.n.push_back(v);
|
||||
}
|
||||
}
|
||||
|
||||
// Parse vertex textures
|
||||
std::vector<Vtexture> parse_vt(std::istringstream& s, std::ifstream& f) {
|
||||
// get count
|
||||
int vtcnt;
|
||||
s >> vtcnt;
|
||||
std::cout << "vt " << vtcnt << std::endl;
|
||||
|
||||
// return later
|
||||
std::vector<Vtexture> vt;
|
||||
|
||||
// parse until count
|
||||
int i;
|
||||
for (i=0; i<vtcnt; i++) {
|
||||
std::string l;
|
||||
|
||||
if (getline(f, l)) {
|
||||
std::istringstream stream(l);
|
||||
|
||||
Vtexture vtexture;
|
||||
|
||||
stream >> vtexture;
|
||||
|
||||
vt.push_back(vtexture);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return vt;
|
||||
}
|
||||
|
||||
/*
|
||||
// Parse Vertex Textures
|
||||
std::vector<std::tuple<float, float>> parse_vt(std::istringstream& s, std::ifstream& f) {
|
||||
// Get vertex textures count
|
||||
@@ -261,6 +306,7 @@ std::vector<std::tuple<float, float>> parse_vt(std::istringstream& s, std::ifstr
|
||||
|
||||
return vt;
|
||||
}
|
||||
*/
|
||||
|
||||
// Parse Vertices
|
||||
std::vector<std::tuple<float, float, float>> parse_v(std::istringstream& s, std::ifstream& f) {
|
||||
@@ -348,11 +394,21 @@ void Model::loadAMO(const std::string& filename) {
|
||||
std::cout << get<0>(i) << " " << get<1>(i) << " " << get<2>(i) << std::endl;
|
||||
}
|
||||
} else if (prefix == "vt") {
|
||||
std::vector<std::tuple<float, float>> vt;
|
||||
/*std::vector<std::tuple<float, float>> vt;
|
||||
vt = parse_vt(stream, file);
|
||||
for (const std::tuple<float, float>& i: vt) {
|
||||
std::cout << get<0>(i) << " " << get<1>(i) << std::endl;
|
||||
}
|
||||
*/
|
||||
|
||||
std::vector<Vtexture> vt;
|
||||
vt = parse_vt(stream, file);
|
||||
for (const Vtexture& i: vt) {
|
||||
for (const float& ii: i.n) {
|
||||
std::cout << ii << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
} else if (prefix == "vn") {
|
||||
/*std::vector<std::tuple<float, float, float>> vn;
|
||||
vn = parse_vn(stream, file);
|
||||
|
Reference in New Issue
Block a user