mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-24 17:10:36 +00:00
item/monster icons in 3d
This commit is contained in:
parent
79f36c6f49
commit
9a21401b9c
@ -215,7 +215,7 @@ void display_data::set_projection(int ed) {
|
||||
DEBB(DF_GRAPH, (debugfile,"current_display->set_projection\n"));
|
||||
|
||||
bool pers3 = false;
|
||||
bool apply_models = !among(pmodel, mdUnchanged, mdRug);
|
||||
bool apply_models = !among(pmodel, mdUnchanged, mdFlatten, mdRug);
|
||||
|
||||
shaderside_projection = false;
|
||||
glhr::new_shader_projection = glhr::shader_projection::standard;
|
||||
@ -242,13 +242,14 @@ void display_data::set_projection(int ed) {
|
||||
if(spherephase == 3) glhr::new_shader_projection = glhr::shader_projection::standardS33;
|
||||
}
|
||||
}
|
||||
if(pmodel == mdFlatten) shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::flatten;
|
||||
|
||||
start_projection(ed, shaderside_projection);
|
||||
if(pmodel == mdRug) return;
|
||||
|
||||
auto cd = current_display;
|
||||
|
||||
if(!shaderside_projection) {
|
||||
if(!shaderside_projection || glhr::new_shader_projection == glhr::shader_projection::flatten) {
|
||||
if(DIM == 3 && apply_models) {
|
||||
glhr::projection_multiply(glhr::ortho(cd->xsize/2, -cd->ysize/2, 1));
|
||||
glhr::id_modelview();
|
||||
@ -319,7 +320,7 @@ void display_data::set_projection(int ed) {
|
||||
}
|
||||
}
|
||||
|
||||
if(vid.camera_angle && !among(pmodel, mdUnchanged, mdRug)) {
|
||||
if(vid.camera_angle && !among(pmodel, mdUnchanged, mdFlatten, mdRug)) {
|
||||
ld cam = vid.camera_angle * degree;
|
||||
|
||||
GLfloat cc = cos(cam);
|
||||
|
@ -261,7 +261,7 @@ enum eModel {
|
||||
mdFisheye, mdJoukowsky, mdJoukowskyInverted,
|
||||
mdRotatedHyperboles, mdSpiral, mdPerspective,
|
||||
mdEquivolume,
|
||||
mdGUARD, mdUnchanged, mdHyperboloidFlat, mdPolynomial, mdRug
|
||||
mdGUARD, mdUnchanged, mdHyperboloidFlat, mdPolynomial, mdRug, mdFlatten
|
||||
};
|
||||
|
||||
typedef unsigned long long flagtype;
|
||||
|
@ -771,7 +771,7 @@ bool drawItemType(eItem it, cell *c, const transmatrix& V, color_t icol, int pti
|
||||
#endif
|
||||
|
||||
transmatrix Vit = V;
|
||||
if(GDIM == 3 && WDIM == 2) Vit = mscale(V, geom3::STUFF);
|
||||
if(GDIM == 3 && WDIM == 2 && c) Vit = mscale(V, geom3::STUFF);
|
||||
if(DIM == 3 && c) Vit = face_the_player(Vit);
|
||||
// V * cspin(0, 2, ptick(618, 0));
|
||||
|
||||
|
7
hud.cpp
7
hud.cpp
@ -162,7 +162,7 @@ int glyphflags(int gid) {
|
||||
}
|
||||
|
||||
bool graphglyph() {
|
||||
if(DIM == 3) return false;
|
||||
// if(DIM == 3) return false;
|
||||
return vid.graphglyph == 2 || (vid.graphglyph == 1 && vid.monmode);
|
||||
}
|
||||
|
||||
@ -187,6 +187,9 @@ bool displayglyph(int cx, int cy, int buttonsize, char glyph, color_t color, int
|
||||
if(m == moKrakenT || m == moDragonTail) bsize /= 2;
|
||||
if(m == moSlime) bsize = (2*bsize+1)/3;
|
||||
transmatrix V = atscreenpos(cx+buttonsize/2, cy, bsize*zoom);
|
||||
if(isWorm(m) && wormscale != 1)
|
||||
for(int i=0; i<DIM; i++)
|
||||
V[i][i] /= wormscale;
|
||||
int mcol = color;
|
||||
mcol -= (color & 0xFCFCFC) >> 2;
|
||||
drawMonsterType(m, NULL, V, mcol, glyphphase[id]/500.0);
|
||||
@ -394,7 +397,7 @@ void drawStats() {
|
||||
bool h = hide_player();
|
||||
|
||||
{
|
||||
dynamicval<eModel> pm(pmodel, mdDisk);
|
||||
dynamicval<eModel> pm(pmodel, DIM == 3 ? mdFlatten : mdDisk);
|
||||
// dynamicval<videopar> v(vid, vid);
|
||||
// vid.alpha = vid.scale = 1;
|
||||
dynamicval<ld> va(vid.alpha, 1);
|
||||
|
2
hyper.h
2
hyper.h
@ -3950,7 +3950,7 @@ namespace glhr {
|
||||
|
||||
enum class shader_projection { standard, band, halfplane, standardH3, standardR3,
|
||||
standardS30, standardS31, standardS32, standardS33,
|
||||
ball, halfplane3, band3,
|
||||
ball, halfplane3, band3, flatten,
|
||||
MAX
|
||||
};
|
||||
|
||||
|
@ -671,7 +671,10 @@ hyperpoint mscale(const hyperpoint& t, double fac) {
|
||||
}
|
||||
|
||||
transmatrix mscale(const transmatrix& t, double fac) {
|
||||
if(GDIM == 3) return t * cpush(2, fac);
|
||||
if(GDIM == 3) {
|
||||
if(pmodel == mdFlatten) { transmatrix u = t; u[2][DIM] += fac; return u; }
|
||||
return t * cpush(2, fac);
|
||||
}
|
||||
transmatrix res;
|
||||
for(int i=0; i<MDIM; i++) for(int j=0; j<MDIM; j++)
|
||||
res[i][j] = t[i][j] * fac;
|
||||
|
21
hypgraph.cpp
21
hypgraph.cpp
@ -273,6 +273,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) {
|
||||
}
|
||||
|
||||
case mdUnchanged:
|
||||
case mdFlatten:
|
||||
ret = H / current_display->radius;
|
||||
return;
|
||||
|
||||
@ -1288,12 +1289,20 @@ transmatrix screenpos(ld x, ld y) {
|
||||
|
||||
transmatrix atscreenpos(ld x, ld y, ld size) {
|
||||
transmatrix V = Id;
|
||||
|
||||
V[0][2] += (x - current_display->xcenter);
|
||||
V[1][2] += (y - current_display->ycenter);
|
||||
V[0][0] = size * 2 * hcrossf / crossf;
|
||||
V[1][1] = size * 2 * hcrossf / crossf;
|
||||
V[2][2] = current_display->scrdist;
|
||||
|
||||
if(pmodel == mdFlatten) {
|
||||
V[0][3] += (x - current_display->xcenter);
|
||||
V[1][3] += (y - current_display->ycenter);
|
||||
V[0][0] = size * 2 * hcrossf / crossf;
|
||||
V[1][1] = size * 2 * hcrossf / crossf;
|
||||
}
|
||||
else {
|
||||
V[0][2] += (x - current_display->xcenter);
|
||||
V[1][2] += (y - current_display->ycenter);
|
||||
V[0][0] = size * 2 * hcrossf / crossf;
|
||||
V[1][1] = size * 2 * hcrossf / crossf;
|
||||
V[2][2] = current_display->scrdist;
|
||||
}
|
||||
|
||||
return V;
|
||||
}
|
||||
|
13
polygons.cpp
13
polygons.cpp
@ -441,6 +441,15 @@ void coords_to_poly() {
|
||||
}
|
||||
|
||||
void addpoly(const transmatrix& V, const vector<glvertex> &tab, int ofs, int cnt) {
|
||||
if(pmodel == mdFlatten) {
|
||||
for(int i=ofs; i<ofs+cnt; i++) {
|
||||
hyperpoint h = glhr::gltopoint(tab[i]);
|
||||
h[3] = 1;
|
||||
h = V * h;
|
||||
add1(h);
|
||||
}
|
||||
return;
|
||||
}
|
||||
tofix.clear(); knowgood = false;
|
||||
hyperpoint last = V * glhr::gltopoint(tab[ofs]);
|
||||
bool last_behind = is_behind(last);
|
||||
@ -2709,6 +2718,8 @@ void configure_floorshapes() {
|
||||
generate_floorshapes();
|
||||
}
|
||||
|
||||
ld wormscale;
|
||||
|
||||
#if MAXMDIM >= 4
|
||||
extern void make_3d_models();
|
||||
#endif
|
||||
@ -2854,7 +2865,7 @@ void buildpolys() {
|
||||
bshape(shPirateX, PPR::ITEM, scalefactor, 124);
|
||||
bshape(shTreat, PPR::ITEM, scalefactor, 253);
|
||||
|
||||
ld wormscale = WDIM == 3 ? 3 : 1;
|
||||
wormscale = WDIM == 3 ? 3 : 1;
|
||||
|
||||
// first layer monsters
|
||||
bshape(shTentacleX, PPR::TENTACLE0);
|
||||
|
15
shaders.cpp
15
shaders.cpp
@ -305,9 +305,11 @@ bool operator != (const glmatrix& m1, const glmatrix& m2) {
|
||||
return !(m1 == m2);
|
||||
}
|
||||
|
||||
bool uses_mvp(shader_projection sp) { return among(sp, shader_projection::standard, shader_projection::flatten); }
|
||||
|
||||
void set_modelview(const glmatrix& modelview) {
|
||||
if(!current) return;
|
||||
if(current_shader_projection != shader_projection::standard) {
|
||||
if(!uses_mvp(current_shader_projection)) {
|
||||
if(modelview != current_modelview) {
|
||||
current_modelview = modelview;
|
||||
glUniformMatrix4fv(current->uMV, 1, 0, modelview.as_array());
|
||||
@ -331,7 +333,7 @@ void set_modelview(const glmatrix& modelview) {
|
||||
|
||||
void id_modelview() {
|
||||
if(!current) return;
|
||||
if(current_shader_projection != shader_projection::standard) { set_modelview(id); return; }
|
||||
if(!uses_mvp(current_shader_projection)) { set_modelview(id); return; }
|
||||
#if MINIMIZE_GL_CALLS
|
||||
if(projection == current_matrix) return;
|
||||
current_matrix = projection;
|
||||
@ -495,7 +497,7 @@ void init() {
|
||||
|
||||
shader_projection sp = shader_projection(j);
|
||||
|
||||
bool mps = j != 0;
|
||||
bool mps = !uses_mvp(sp);
|
||||
bool band = among(sp, shader_projection::band, shader_projection::band3);
|
||||
bool hp = among(sp, shader_projection::halfplane, shader_projection::halfplane3);
|
||||
bool sh3 = (sp == shader_projection::standardH3);
|
||||
@ -510,6 +512,7 @@ void init() {
|
||||
bool dim3 = s3 || among(sp, shader_projection::ball, shader_projection::halfplane3, shader_projection::band3);
|
||||
bool dim2 = !dim3;
|
||||
bool ball = (sp == shader_projection::ball);
|
||||
bool flatten = (sp == shader_projection::flatten);
|
||||
|
||||
programs[i][j] = new GLprogram(stringbuilder(
|
||||
|
||||
@ -557,9 +560,11 @@ void init() {
|
||||
varcol, "vColor = aColor;",
|
||||
!varcol, "vColor = uColor;",
|
||||
lfog, "vColor = vColor * clamp(1.0 + aPosition.z * uFog, 0.0, 1.0);",
|
||||
!mps, "gl_Position = uMVP * aPosition;",
|
||||
!mps && !flatten, "gl_Position = uMVP * aPosition;",
|
||||
!mps && flatten, "vec4 pos = aPosition; pos[3] = 1.0; gl_Position = uMVP * pos;",
|
||||
ball, "vec4 t = uMV * aPosition; t /= (t[3] + uAlpha); ",
|
||||
mps&&!(band||hp||s3||ball),"gl_Position = uP * (uMV * aPosition);",
|
||||
mps&&!(band||hp||s3||ball||flatten),"gl_Position = uP * (uMV * aPosition);",
|
||||
mps&&flatten, "vec4 pos = aPosition; pos[3] = 1.0; gl_Position = uP * (uMV * pos);",
|
||||
|
||||
band||hp, "vec4 t = uMV * aPosition;",
|
||||
(band||hp) && dim2, "float zlev = zlevel(t);",
|
||||
|
Loading…
Reference in New Issue
Block a user