mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-07-03 10:12:51 +00:00
rogueviz::objmodel:: load faces with more than 3 vertices
This commit is contained in:
parent
c8b26954c2
commit
44e127689d
@ -159,24 +159,34 @@ void model::load_obj(model_data& md) {
|
|||||||
else if(s == "f") {
|
else if(s == "f") {
|
||||||
struct vertexinfo { int f, t, n; };
|
struct vertexinfo { int f, t, n; };
|
||||||
array<vertexinfo, 3> vis;
|
array<vertexinfo, 3> vis;
|
||||||
vector<hyperpoint> hys;
|
|
||||||
vector<hyperpoint> tot;
|
|
||||||
char bar;
|
char bar;
|
||||||
for(int i=0; i<3; i++) {
|
|
||||||
vis[i].f = vis[i].t = vis[i].n = 1;
|
auto get_vi = [&] (vertexinfo& vi) {
|
||||||
scan(fs, vis[i].f);
|
vi.f = vi.t = vi.n = 1;
|
||||||
|
scan(fs, vi.f);
|
||||||
if(peek(fs) == '/') {
|
if(peek(fs) == '/') {
|
||||||
scan(fs, bar);
|
scan(fs, bar);
|
||||||
if(peek(fs) != '/') scan(fs, vis[i].t);
|
if(peek(fs) != '/') scan(fs, vi.t);
|
||||||
}
|
}
|
||||||
if(peek(fs) == '/') {
|
if(peek(fs) == '/') {
|
||||||
scan(fs, bar);
|
scan(fs, bar);
|
||||||
scan(fs, vis[i].n);
|
scan(fs, vi.n);
|
||||||
}
|
}
|
||||||
|
|
||||||
vis[i].f--; vis[i].t--; vis[i].n--;
|
vi.f--; vi.t--; vi.n--;
|
||||||
if(vis[i].f < 0 || vis[i].f >= isize(vertices))
|
if(vi.f < 0 || vi.f >= isize(vertices))
|
||||||
throw hr_exception("illegal ID");
|
throw hr_exception("illegal ID");
|
||||||
|
};
|
||||||
|
|
||||||
|
get_vi(vis[0]);
|
||||||
|
get_vi(vis[1]);
|
||||||
|
next_triangle:
|
||||||
|
get_vi(vis[2]);
|
||||||
|
|
||||||
|
vector<hyperpoint> hys;
|
||||||
|
vector<hyperpoint> tot;
|
||||||
|
|
||||||
|
for(int i=0; i<3; i++) {
|
||||||
hys.push_back(vertices[vis[i].f]);
|
hys.push_back(vertices[vis[i].f]);
|
||||||
tot.push_back(textured ? tvertices[vis[i].t] : point3(0,0,0));
|
tot.push_back(textured ? tvertices[vis[i].t] : point3(0,0,0));
|
||||||
}
|
}
|
||||||
@ -219,6 +229,10 @@ void model::load_obj(model_data& md) {
|
|||||||
tri(a+1, b+1);
|
tri(a+1, b+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while(among(peek(fs), ' ', '\r', '\n')) scan(fs, bar);
|
||||||
|
if(isdigit(peek(fs))) { vis[1] = vis[2]; println(hlog, "next triangle"); goto next_triangle; }
|
||||||
|
println(hlog, "last triangle");
|
||||||
}
|
}
|
||||||
else if(s == "l") {
|
else if(s == "l") {
|
||||||
int a, b;
|
int a, b;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user