#include "hyper.h" namespace hr { EX bool context_fog = true; EX ld camera_level; #if MAXMDIM >= 4 && CAP_GL EX int get_skybrightness(int mul IS(1)) { ld s = 1 - mul * (camera_level - cgi.WALL) / -2; if(s > 1) return 255; if(s < 0) return 0; return int(s * 255); } struct sky_item { cell *c; shiftmatrix T; color_t color; color_t skycolor; sky_item(cell *_c, const struct shiftmatrix _T, color_t _color, color_t _skycolor) : c(_c), T(_T), color(_color), skycolor(_skycolor) {} }; struct dqi_sky : drawqueueitem { vector sky; void draw() override; color_t outline_group() override { return 3; } // singleton explicit dqi_sky() { hr::sky = this; } ~dqi_sky() override { hr::sky = NULL; } }; EX struct dqi_sky *sky; EX void prepare_sky() { sky = NULL; if(euclid) { if(WDIM == 3 || GDIM == 2) return; if(no_wall_rendering) return; shiftmatrix T = ggmatrix(currentmap->gamestart()); T.T = gpushxto0(tC0(T.T)) * T.T; queuepoly(T, cgi.shEuclideanSky, 0x0044e4FF); queuepolyat(T * zpush(cgi.SKY+0.5) * xpush(cgi.SKY+0.5), cgi.shSun, 0xFFFF00FF, PPR::SKY); } else { sky = &queuea (PPR::MISSILE); } } vector skyvertices; cell *sky_centerover; shiftmatrix sky_cview; void compute_skyvertices(const vector& sky) { skyvertices.clear(); int sk = get_skybrightness(); std::map> colors; for(const sky_item& si: sky) colors[si.c] = make_pair(darkena(gradient(0, si.color, 0, sk, 255), 0, 0xFF), darkena(si.skycolor, 0, 0xFF) ); hyperpoint skypoint = cpush0(2, cgi.SKY); hyperpoint hellpoint = cpush0(2, -cgi.SKY); vector this_poly; for(const sky_item& si: sky) { auto c = si.c; if(c->land == laMirrorWall) continue; bool inmir = false; forCellEx(c1, c) if(c1->land == laMirrorWall) inmir = true; if(inmir) continue; if(cgflags & qIDEAL) { for(int i=0; itype; i++) { int j = (i+1) % c->type; transmatrix T1 = unshift(si.T); hyperpoint ci = kleinize(get_corner_position(c, i, 3)); hyperpoint cj = kleinize(get_corner_position(c, j, 3)); static const int prec = 8; ci = (ci - C0)/prec; cj = (cj - C0)/prec; glhr::colored_vertex vs[prec+1][prec+1], vh[prec+1][prec+1]; auto& co = colors[c]; for(int x=0; x<=prec; x++) for(int y=0; y<=prec-x; y++) { transmatrix h = T1 * rgpushxto0(normalize(C0+ci*min(x, prec - .01)+cj*min(y, prec-.01))); vs[y][x] = glhr::colored_vertex(h * skypoint, co.first); vh[y][x] = glhr::colored_vertex(h * hellpoint, co.second); } for(int x=0; xmove(i))) { for(int i=0; itype; i++) { static const int prec = 2; if(1) { cellwalker cw0(c, i); cellwalker cw2 = cw0; cw2--; cw2 += wstep; if(!colors.count(cw2.at)) { this_poly.clear(); transmatrix T1 = Id; transmatrix T2 = unshift(si.T); auto cw = cw0; auto co = at_or_null(colors, cw.at); while(co) { this_poly.emplace_back(T2 * T1 * skypoint, co->first); this_poly.emplace_back(T2 * T1 * hellpoint, co->second); auto cw1 = cw; cw += wstep; cw++; auto co1 = at_or_null(colors, cw.at); if(!co1) break; transmatrix A = currentmap->adj(cw1.at, cw1.spin); hyperpoint a = tC0(A); for(int i=1; ifirst, co1->first, 0, i, prec)); this_poly.emplace_back(T2 * orthogonal_move(h, -cgi.SKY), gradient(co->second, co1->second, 0, i, prec)); } T1 = T1 * A; co = co1; } int k = isize(this_poly); for(int j=2; j vertices; vector vcolors; transmatrix T1 = Id; do { vertices.push_back(tC0(T1)); vcolors.push_back(colors[cw.at].first); T1 = T1 * currentmap->adj(cw.at, cw.spin); cw += wstep; cw++; } while(cw != cw0); int k = isize(vertices); println(hlog, "bb ", k); color_t ccolor; for(int i=0; i i(vrhr::state, 0); #endif if(1) { //shot::take("airtest.png", drawqueue); dynamicval v(vid, vid); dynamicval vi(inHighQual, true); vid.xres = AIR_TEXTURE; vid.yres = AIR_TEXTURE; calcparam(); models::configure(); resetbuffer rb; airbuf->enable(); current_display->set_viewport(0); airbuf->clear(0xFFFF00FF); pconf.alpha = 1; pconf.scale = 1; pconf.camera_angle = 0; pconf.stretch = 1; pmodel = mdDisk; vid.always3 = false; geom3::apply_always3(); check_cgi(); cgi.require_shapes(); eGeometry orig = geometry; #if !ISIOS glDisable(GL_LINE_SMOOTH); #endif for(auto& g: sky->sky) { transmatrix S; if(1) { geometry = gSpace534; S = g.T.T; S = radar_transform * S; geometry = orig; swapmatrix(S); } auto& h = cgi.shFullFloor.b[shvid(g.c)]; dqi_poly p; p.V = shiftless(S); p.offset = h.s; p.cnt = h.e - h.s; p.tab = &cgi.ourshape; p.color = (g.skycolor << 8) | 0xFF; p.outline = 0; p.linewidth = 1; p.flags = POLY_FORCEWIDE; p.tinf = nullptr; p.draw(); } #if !ISIOS if(vid.antialias & AA_LINES) glEnable(GL_LINE_SMOOTH); #endif #if CAP_SDL // if(anyshiftclick) IMAGESAVE(airbuf->render(), "air.png"); #endif rb.reset(); } GLERR("after draw"); geom3::apply_always3(); check_cgi(); calcparam(); GLERR("after make_air"); current_display->set_viewport(0); current_display->set_all(0,0); } #endif }