mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-11 18:00:34 +00:00
3D geometries should now render without OpenGL
This commit is contained in:
parent
43fd94bed6
commit
c1ed54763b
@ -585,6 +585,7 @@ void geometry_information::make_revolution_cut(hpcshape &sh, int each, ld push,
|
|||||||
shDogStripes = shDogTorso;
|
shDogStripes = shDogTorso;
|
||||||
add_texture(shDogStripes);
|
add_texture(shDogStripes);
|
||||||
auto& utt = models_texture;
|
auto& utt = models_texture;
|
||||||
|
if(utt.tvertices.empty()) return;
|
||||||
int a = (6 * 360 / step);
|
int a = (6 * 360 / step);
|
||||||
for(int i=0; i<shDogStripes.e - shDogStripes.s; i++)
|
for(int i=0; i<shDogStripes.e - shDogStripes.s; i++)
|
||||||
if(i % (2 * a) < a)
|
if(i % (2 * a) < a)
|
||||||
@ -770,6 +771,7 @@ void geometry_information::adjust_eye(hpcshape& eye, hpcshape head, ld shift_eye
|
|||||||
for(int i=eye.s; i<s; i++) {
|
for(int i=eye.s; i<s; i++) {
|
||||||
hpcpush(MirrorY * hpc[i]);
|
hpcpush(MirrorY * hpc[i]);
|
||||||
auto& utt = models_texture;
|
auto& utt = models_texture;
|
||||||
|
if(!utt.tvertices.empty())
|
||||||
utt.tvertices.push_back(utt.tvertices[i - eye.s + eye.texture_offset]);
|
utt.tvertices.push_back(utt.tvertices[i - eye.s + eye.texture_offset]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1618,7 +1618,7 @@ void celldrawer::draw_features_and_walls_3d() {
|
|||||||
poly.tinf = &texture::config.tinf3;
|
poly.tinf = &texture::config.tinf3;
|
||||||
poly.offset_texture = 0;
|
poly.offset_texture = 0;
|
||||||
}
|
}
|
||||||
else
|
else if(!floor_texture_vertices.empty())
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
poly.tinf = &floor_texture_vertices[qfi.fshape->id];
|
poly.tinf = &floor_texture_vertices[qfi.fshape->id];
|
||||||
|
33
drawing.cpp
33
drawing.cpp
@ -407,6 +407,12 @@ void coords_to_poly() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool behind3(hyperpoint h) {
|
||||||
|
if(pmodel == mdGeodesic)
|
||||||
|
h = lp_apply(inverse_exp(h, iTable));
|
||||||
|
return h[2] < 0;
|
||||||
|
}
|
||||||
|
|
||||||
void addpoly(const transmatrix& V, const vector<glvertex> &tab, int ofs, int cnt) {
|
void addpoly(const transmatrix& V, const vector<glvertex> &tab, int ofs, int cnt) {
|
||||||
if(pmodel == mdPixel) {
|
if(pmodel == mdPixel) {
|
||||||
for(int i=ofs; i<ofs+cnt; i++) {
|
for(int i=ofs; i<ofs+cnt; i++) {
|
||||||
@ -418,6 +424,24 @@ void addpoly(const transmatrix& V, const vector<glvertex> &tab, int ofs, int cnt
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tofix.clear(); knowgood = false;
|
tofix.clear(); knowgood = false;
|
||||||
|
if(among(pmodel, mdPerspective, mdGeodesic)) {
|
||||||
|
if(poly_flags & POLY_TRIANGLES) {
|
||||||
|
for(int i=ofs; i<ofs+cnt; i+=3) {
|
||||||
|
hyperpoint h0 = V * glhr::gltopoint(tab[i]);
|
||||||
|
hyperpoint h1 = V * glhr::gltopoint(tab[i+1]);
|
||||||
|
hyperpoint h2 = V * glhr::gltopoint(tab[i+2]);
|
||||||
|
if(!behind3(h0) && !behind3(h1) && !behind3(h2))
|
||||||
|
addpoint(h0), addpoint(h1), addpoint(h2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for(int i=ofs; i<ofs+cnt; i++) {
|
||||||
|
hyperpoint h = V * glhr::gltopoint(tab[i]);
|
||||||
|
if(!behind3(h)) addpoint(h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
hyperpoint last = V * glhr::gltopoint(tab[ofs]);
|
hyperpoint last = V * glhr::gltopoint(tab[ofs]);
|
||||||
bool last_behind = is_behind(last);
|
bool last_behind = is_behind(last);
|
||||||
if(!last_behind) addpoint(last);
|
if(!last_behind) addpoint(last);
|
||||||
@ -1614,6 +1638,11 @@ void dqi_poly::draw() {
|
|||||||
coords_to_poly();
|
coords_to_poly();
|
||||||
color_t col = color;
|
color_t col = color;
|
||||||
if(poly_flags & POLY_INVERSE) col = 0;
|
if(poly_flags & POLY_INVERSE) col = 0;
|
||||||
|
if(poly_flags & POLY_TRIANGLES) {
|
||||||
|
for(int i=0; i<polyi; i+=3)
|
||||||
|
svg::polygon(polyx+i, polyy+i, 3, col, outline, get_width(this));
|
||||||
|
}
|
||||||
|
else
|
||||||
svg::polygon(polyx, polyy, polyi, col, outline, get_width(this));
|
svg::polygon(polyx, polyy, polyi, col, outline, get_width(this));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1644,6 +1673,10 @@ void dqi_poly::draw() {
|
|||||||
}
|
}
|
||||||
filledPolygonColorI(s, polyx, polyy, polyi+5, color);
|
filledPolygonColorI(s, polyx, polyy, polyi+5, color);
|
||||||
}
|
}
|
||||||
|
else if(poly_flags & POLY_TRIANGLES) {
|
||||||
|
for(int i=0; i<polyi; i+=3)
|
||||||
|
filledPolygonColorI(s, polyx+i, polyy+i, 3, color);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
filledPolygonColorI(s, polyx, polyy, polyi, color);
|
filledPolygonColorI(s, polyx, polyy, polyi, color);
|
||||||
|
|
||||||
|
@ -1086,6 +1086,7 @@ void draw_shape_for_texture(floorshape* sh) {
|
|||||||
/** copy the texture vertices so that there are at least qty of them */
|
/** copy the texture vertices so that there are at least qty of them */
|
||||||
EX void ensure_vertex_number(basic_textureinfo& bti, int qty) {
|
EX void ensure_vertex_number(basic_textureinfo& bti, int qty) {
|
||||||
int s = isize(bti.tvertices);
|
int s = isize(bti.tvertices);
|
||||||
|
if(!s) return;
|
||||||
while(isize(bti.tvertices) <= qty) {
|
while(isize(bti.tvertices) <= qty) {
|
||||||
for(int i=0; i<s; i++) bti.tvertices.push_back(bti.tvertices[i]);
|
for(int i=0; i<s; i++) bti.tvertices.push_back(bti.tvertices[i]);
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ ld find_zlev(hyperpoint& H) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ld get_tz(hyperpoint H) {
|
ld get_tz(hyperpoint H) {
|
||||||
ld tz = euclid ? (1+vid.alpha) : vid.alpha+H[LDIM];
|
ld tz = vid.alpha+H[LDIM];
|
||||||
if(tz < BEHIND_LIMIT && tz > -BEHIND_LIMIT) tz = BEHIND_LIMIT;
|
if(tz < BEHIND_LIMIT && tz > -BEHIND_LIMIT) tz = BEHIND_LIMIT;
|
||||||
return tz;
|
return tz;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user