1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-20 15:40:26 +00:00

2D3D:: better stars

This commit is contained in:
Zeno Rogue 2019-05-29 01:59:01 +02:00
parent 42dd86f650
commit 88d6c0d144
3 changed files with 42 additions and 20 deletions

View File

@ -642,6 +642,38 @@ void geometry_information::make_ball(hpcshape& sh, ld rad, int lev) {
add_texture(sh);
}
void geometry_information::hpcsquare(hyperpoint h1, hyperpoint h2, hyperpoint h3, hyperpoint h4) {
last->flags |= POLY_TRIANGLES;
hpcpush(h1);
hpcpush(h2);
hpcpush(h3);
hpcpush(h2);
hpcpush(h3);
hpcpush(h4);
}
void geometry_information::make_star(hpcshape& sh, ld rad) {
bshape(sh, sh.prio);
rad = sinh(rad);
sh.flags |= POLY_TRIANGLES | POLY_INTENSE;
for(int a=0; a<64; a++) {
ld z0 = (a-32)/32.;
ld z1 = (a-31)/32.;
ld r0 = sqrt(1 - z0*z0) * rad;
ld r1 = sqrt(1 - z1*z1) * rad;
z0 *= rad;
z1 *= rad;
for(int b=0; b<360; b+=15) {
ld b0 = b * degree;
ld b1 = (b+15) * degree;
hpcsquare(
hpxy3(r0 * cos(b0), r0 * sin(b0), z0), hpxy3(r0 * cos(b1), r0 * sin(b1), z0),
hpxy3(r1 * cos(b0), r1 * sin(b0), z1), hpxy3(r1 * cos(b1), r1 * sin(b1), z1)
);
}
}
}
hyperpoint psmin(hyperpoint H) {
hyperpoint res;
res[2] = asin_auto(H[2]);
@ -978,8 +1010,8 @@ void geometry_information::make_3d_models() {
if(euclid)
make_ball(shSun, 0.5, 2);
else
make_ball(shSun, 3, 5);
make_ball(shNightStar, 0.75, 2);
make_star(shSun, 3);
make_star(shNightStar, 0.75);
if(WDIM == 2) {
for(int i=0; i<3; i++) {

View File

@ -4633,9 +4633,7 @@ void draw_euclidean_sky() {
}
queuecurve(0, 0x0044e4FF, PPR::EUCLIDEAN_SKY).flags |= POLY_TRIANGLES;
auto &sun = queuepolyat(T * zpush(cgi.SKY+0.5) * xpush(cgi.SKY+0.5), cgi.shSun, 0xFFFF00FF, PPR::SKY);
sun.tinf = NULL;
sun.flags |= POLY_INTENSE;
queuepolyat(T * zpush(cgi.SKY+0.5) * xpush(cgi.SKY+0.5), cgi.shSun, 0xFFFF00FF, PPR::SKY);
}
void draw_ceiling(cell *c, const transmatrix& V, int fd, color_t& fcol, color_t& wcol) {
@ -4647,9 +4645,7 @@ void draw_ceiling(cell *c, const transmatrix& V, int fd, color_t& fcol, color_t&
case 1: {
if(euclid) return;
if(fieldpattern::fieldval_uniq(c) % 3 == 0) {
auto &star = queuepolyat(V * zpush(cgi.SKY+0.5), cgi.shNightStar, 0xFFFFFFFF, PPR::SKY);
star.tinf = NULL;
star.flags |= POLY_INTENSE;
queuepolyat(V * zpush(cgi.SKY+0.5), cgi.shNightStar, 0xFFFFFFFF, PPR::SKY);
}
int sk = get_skybrightness();
if(sk > 0) {
@ -4658,9 +4654,7 @@ void draw_ceiling(cell *c, const transmatrix& V, int fd, color_t& fcol, color_t&
}
if(c->land == laAsteroids) {
if(fieldpattern::fieldval_uniq(c) % 9 < 3) {
auto &downstar = queuepolyat(V * zpush(-0.5-cgi.SKY), cgi.shNightStar, 0xFFFFFFFF, PPR::SKY);
downstar.tinf = NULL;
downstar.flags |= POLY_INTENSE;
queuepolyat(V * zpush(-0.5-cgi.SKY), cgi.shNightStar, 0xFFFFFFFF, PPR::SKY);
}
sk = get_skybrightness(-1);
auto sky = draw_shapevec(c, V * MirrorZ, cgi.shFullFloor.levels[SIDE_SKY], 0x000000FF + 0x100 * (sk/17), PPR::SKY);
@ -4675,9 +4669,7 @@ void draw_ceiling(cell *c, const transmatrix& V, int fd, color_t& fcol, color_t&
if(c->land == laWineyard) {
col = 0x4040FF;
if(emeraldval(c) / 4 == 11) {
auto &sun = queuepolyat(V * zpush(cgi.SKY+0.5), cgi.shSun, 0xFFFF00FF, PPR::SKY);
sun.tinf = NULL;
sun.flags |= POLY_INTENSE;
queuepolyat(V * zpush(cgi.SKY+0.5), cgi.shSun, 0xFFFF00FF, PPR::SKY);
}
}
else {
@ -4728,9 +4720,7 @@ void draw_ceiling(cell *c, const transmatrix& V, int fd, color_t& fcol, color_t&
if(euclid) return;
if(true) {
auto &star = queuepolyat(V * zpush(cgi.SKY+0.5), cgi.shNightStar, 0xFFFFFFFF, PPR::SKY);
star.tinf = NULL;
star.flags |= POLY_INTENSE;
queuepolyat(V * zpush(cgi.SKY+0.5), cgi.shNightStar, 0xFFFFFFFF, PPR::SKY);
}
int sk = get_skybrightness();
if(sk > 0) {
@ -4752,9 +4742,7 @@ void draw_ceiling(cell *c, const transmatrix& V, int fd, color_t& fcol, color_t&
if(euclid) return;
if(true) {
auto &star = queuepolyat(V * zpush(cgi.SKY+0.5), cgi.shNightStar, 0xFFFFFFFF, PPR::SKY);
star.tinf = NULL;
star.flags |= POLY_INTENSE;
queuepolyat(V * zpush(cgi.SKY+0.5), cgi.shNightStar, 0xFFFFFFFF, PPR::SKY);
}
int sk = get_skybrightness();
if(sk > 0) {

View File

@ -4467,6 +4467,7 @@ hpcshape
void prepare_usershapes();
void hpcpush(hyperpoint h);
void hpcsquare(hyperpoint h1, hyperpoint h2, hyperpoint h3, hyperpoint h4);
void chasmifyPoly(double fac, double fac2, int k);
void shift(hpcshape& sh, double dx, double dy, double dz);
void initPolyForGL();
@ -4522,6 +4523,7 @@ hpcshape
void slimetriangle(hyperpoint a, hyperpoint b, hyperpoint c, ld rad, int lev);
void balltriangle(hyperpoint a, hyperpoint b, hyperpoint c, ld rad, int lev);
void make_ball(hpcshape& sh, ld rad, int lev);
void make_star(hpcshape& sh, ld rad);
void adjust_eye(hpcshape& eye, hpcshape head, ld shift_eye, ld shift_head, int q, ld zoom=1);
void shift_last_straight(ld z);
void queueball(const transmatrix& V, ld rad, color_t col, eItem what);