mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-23 21:07:17 +00:00
sl2:: 3d-models
This commit is contained in:
parent
1e6970ca28
commit
fd42b45fce
@ -32,6 +32,7 @@ vector<hyperpoint> geometry_information::get_shape(hpcshape sh) {
|
||||
|
||||
EX hyperpoint normalize_flat(hyperpoint h) {
|
||||
if(prod) return product_decompose(h).second;
|
||||
if(sl2) h = slr::translate(h) * zpush0(-atan2(h[2], h[3]));
|
||||
return normalize(h);
|
||||
}
|
||||
|
||||
@ -133,6 +134,12 @@ vector<hyperpoint> scaleshape(const vector<hyperpoint>& vh, ld s) {
|
||||
return res;
|
||||
}
|
||||
|
||||
ld get_zlevel(hyperpoint h) {
|
||||
if(prod) return zlevel(h);
|
||||
if(sl2) return atan2(h[2], h[3]);
|
||||
return asin_auto(h[2]);
|
||||
}
|
||||
|
||||
void geometry_information::make_ha_3d(hpcshape& sh, bool isarmor, ld scale) {
|
||||
shcenter = C0;
|
||||
|
||||
@ -202,7 +209,7 @@ void geometry_information::make_ha_3d(hpcshape& sh, bool isarmor, ld scale) {
|
||||
int arm1 = isize(hpc);
|
||||
for(int i=arm0; i<arm1; i++) {
|
||||
hyperpoint h = hpc[i];
|
||||
ld zl = prod ? zlevel(h) : asin_auto(h[2]);
|
||||
ld zl = get_zlevel(h);
|
||||
h = zpush(-zl) * h;
|
||||
ld rad = hdist0(h);
|
||||
rad = (rad - 0.1124*S) / (0.2804*S - 0.1124*S);
|
||||
@ -615,10 +622,10 @@ void geometry_information::animate_bird(hpcshape& orig, hpcshape_animated& anima
|
||||
// shift_shape(orig, BIRD);
|
||||
}
|
||||
|
||||
EX hyperpoint forward_dir(ld x) { return (prod || sl2) ? point3(x, 0, 0) : xpush0(x); }
|
||||
EX hyperpoint zforward_dir(ld z) { return (prod || sl2) ? point3(0, 0, z) : zpush0(z); }
|
||||
EX hyperpoint forward_dir(ld x) { return hybri ? point3(x, 0, 0) : xpush0(x); }
|
||||
EX hyperpoint zforward_dir(ld z) { return hybri ? point3(0, 0, z) : zpush0(z); }
|
||||
|
||||
EX hyperpoint dir_to_point(hyperpoint h) { return prod ? product::direct_exp(h) : h; }
|
||||
EX hyperpoint dir_to_point(hyperpoint h) { return hybri ? nisot::direct_exp(h, 100) : h; }
|
||||
|
||||
EX hyperpoint dir_setlength(hyperpoint dir, ld length) {
|
||||
if(dir[0] == 0 && dir[1] == 0 && dir[2] == 0) return dir;
|
||||
@ -630,7 +637,7 @@ void geometry_information::slimetriangle(hyperpoint a, hyperpoint b, hyperpoint
|
||||
dynamicval<int> d(vid.texture_step, 8);
|
||||
texture_order([&] (ld x, ld y) {
|
||||
ld z = 1-x-y;
|
||||
ld r = scalefactor * hcrossf7 * (0 + pow(max(x,max(y,z)), .3) * 0.8) * (prod ? .5 : 1);
|
||||
ld r = scalefactor * hcrossf7 * (0 + pow(max(x,max(y,z)), .3) * 0.8) * (hybri ? .5 : 1);
|
||||
hyperpoint h = dir_to_point(dir_setlength(a*x+b*y+c*z, r));
|
||||
hpcpush(h);
|
||||
});
|
||||
|
@ -569,6 +569,7 @@ void geometry_information::prepare_basics() {
|
||||
}
|
||||
|
||||
plevel = vid.plevel_factor * scalefactor;
|
||||
if(sl2) plevel = M_PI / 14;
|
||||
|
||||
set_sibling_limit();
|
||||
|
||||
@ -650,7 +651,7 @@ namespace geom3 {
|
||||
string invalid;
|
||||
|
||||
ld actual_wall_height() {
|
||||
if(prod) return cgi.plevel;
|
||||
if(hybri) return cgi.plevel;
|
||||
#if CAP_GP
|
||||
if(GOLDBERG && vid.gp_autoscale_heights)
|
||||
return vid.wall_height * min<ld>(4 / hypot_d(2, gp::next), 1);
|
||||
@ -722,7 +723,7 @@ namespace geom3 {
|
||||
|
||||
human_height = vid.human_wall_ratio * wh;
|
||||
if(WDIM == 3) human_height = scalefactor * vid.height_width / 2;
|
||||
if(prod) human_height = min(human_height, cgi.plevel * .9);
|
||||
if(hybri) human_height = min(human_height, cgi.plevel * .9);
|
||||
|
||||
ld reduce = (WDIM == 3 ? human_height / 2 : 0);
|
||||
|
||||
|
15
graph.cpp
15
graph.cpp
@ -349,14 +349,14 @@ double hexshiftat(cell *c) {
|
||||
}
|
||||
|
||||
EX transmatrix ddspin(cell *c, int d, ld bonus IS(0)) {
|
||||
if(prod) return PIU( ddspin(c, d, bonus) );
|
||||
if(hybri) return PIU( ddspin(c, d, bonus) );
|
||||
if(WDIM == 3 && d < c->type) return rspintox(tC0(calc_relative_matrix(c->cmove(d), c, C0))) * cspin(2, 0, bonus);
|
||||
if(WDIM == 2 && (binarytiling || penrose) && d < c->type) return spin(bonus) * rspintox(nearcorner(c, d));
|
||||
return spin(displayspin(c, d) + bonus - hexshiftat(c));
|
||||
}
|
||||
|
||||
EX transmatrix iddspin(cell *c, int d, ld bonus IS(0)) {
|
||||
if(prod) return PIU( iddspin(c, d, bonus) );
|
||||
if(hybri) return PIU( iddspin(c, d, bonus) );
|
||||
if(WDIM == 3 && d < c->type) return cspin(0, 2, bonus) * spintox(tC0(calc_relative_matrix(c->cmove(d), c, C0)));
|
||||
if(WDIM == 2 && (binarytiling || penrose) && d < c->type) return spin(bonus) * spintox(nearcorner(c, d));
|
||||
return spin(hexshiftat(c) - displayspin(c, d) + bonus);
|
||||
@ -808,6 +808,7 @@ color_t kind_outline(eItem it) {
|
||||
|
||||
EX transmatrix face_the_player(const transmatrix V) {
|
||||
if(GDIM == 2) return V;
|
||||
if(sl2) return V * zpush(cos(ptick(750)) * cgi.plevel / 16);
|
||||
if(prod) return mscale(V, cos(ptick(750)) * cgi.plevel / 16);
|
||||
if(nonisotropic) return spin_towards(V, C0, 2, 0);
|
||||
return rgpushxto0(tC0(V));
|
||||
@ -870,6 +871,8 @@ EX bool drawItemType(eItem it, cell *c, const transmatrix& V, color_t icol, int
|
||||
if(GDIM == 3 && WDIM == 2 && c && it != itBabyTortoise) Vit = mscale(V, cgi.STUFF);
|
||||
if(c && prod)
|
||||
Vit = mscale(Vit, sin(ptick(750)) * cgi.plevel / 4);
|
||||
else if(c && sl2)
|
||||
Vit = Vit * zpush(sin(ptick(750)) * cgi.plevel / 4);
|
||||
else
|
||||
if(GDIM == 3 && c && it != itBabyTortoise) Vit = face_the_player(Vit);
|
||||
// V * cspin(0, 2, ptick(618, 0));
|
||||
@ -1351,7 +1354,7 @@ EX bool drawMonsterType(eMonster m, cell *where, const transmatrix& V1, color_t
|
||||
char xch = minf[m].glyph;
|
||||
|
||||
transmatrix V = V1;
|
||||
if(WDIM == 3 && (classflag(m) & CF_FACE_UP) && where && !prod) V = V1 * cspin(0, 2, M_PI/2);
|
||||
if(WDIM == 3 && (classflag(m) & CF_FACE_UP) && where && !hybri) V = V1 * cspin(0, 2, M_PI/2);
|
||||
|
||||
// if(GDIM == 3) V = V * cspin(0, 2, M_PI/2);
|
||||
|
||||
@ -2548,7 +2551,7 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, color_t col, bool m
|
||||
|
||||
if(mmmon) {
|
||||
if(isAnyIvy(c)) {
|
||||
if(prod) {
|
||||
if(hybri) {
|
||||
queuepoly(Vb, cgi.shILeaf[ctof(c)], darkena(col, 0, 0xFF));
|
||||
for(int a=0; a<c->type-2; a++)
|
||||
queuepoly(Vb * spin(a * 2 * M_PI / (c->type-2)), cgi.shILeaf[2], darkena(col, 0, 0xFF));
|
||||
@ -2788,13 +2791,13 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, color_t col, bool m
|
||||
if(prod) Vs = mscale(Vs, z);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else if(!sl2) {
|
||||
hyperpoint V0 = inverse(cwtV) * tC0(Vs);
|
||||
Vs = cwtV * rspintox(V0) * xpush(hdist0(V0)) * cspin(0, 2, -M_PI);
|
||||
// cwtV * rgpushxto0(inverse(cwtV) * tC0(Vs));
|
||||
}
|
||||
if(c->monst == moHunterChanging)
|
||||
Vs = Vs * (prod ? spin(M_PI) : cspin(WDIM-2, WDIM-1, M_PI));
|
||||
Vs = Vs * (hybri ? spin(M_PI) : cspin(WDIM-2, WDIM-1, M_PI));
|
||||
}
|
||||
if(c->monmirror) Vs = Vs * Mirror;
|
||||
|
||||
|
@ -493,6 +493,7 @@ EX bool eqmatrix(transmatrix A, transmatrix B, ld eps IS(.01)) {
|
||||
// in the 3D space, move the point h orthogonally to the (x,y) plane by z units
|
||||
EX hyperpoint orthogonal_move(const hyperpoint& h, ld z) {
|
||||
if(prod) return zshift(h, z);
|
||||
if(sl2) return slr::translate(h) * cpush0(2, z);
|
||||
if(!hyperbolic) return rgpushxto0(h) * cpush(2, z) * C0;
|
||||
if(nil) return nisot::translate(h) * cpush0(2, z);
|
||||
if(translatable) return hpxy3(h[0], h[1], h[2] + z);
|
||||
@ -960,6 +961,7 @@ EX hyperpoint orthogonal_of_C0(hyperpoint h0, hyperpoint h1, hyperpoint h2) {
|
||||
|
||||
EX hyperpoint zshift(hyperpoint x, ld z) {
|
||||
if(GDIM == 3 && WDIM == 2) return rgpushxto0(x) * cpush0(2, z);
|
||||
else if(sl2) return mscale(x, z);
|
||||
else if(prod) return mscale(x, z);
|
||||
else return mscale(x, z);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user