From 402b6aa0ad93cf787b93d224f69b8774c2d8a46c Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 12 May 2019 21:09:27 +0200 Subject: [PATCH] improved armor models; head lower; configurable human eye color --- 3d-models.cpp | 61 +++++++++++++++++++++++++++++++++++++-------------- config.cpp | 8 ++++--- graph.cpp | 28 ++++++++++++----------- hyper.h | 2 +- 4 files changed, 65 insertions(+), 34 deletions(-) diff --git a/3d-models.cpp b/3d-models.cpp index 5c43770b..5a96d2d2 100644 --- a/3d-models.cpp +++ b/3d-models.cpp @@ -7,6 +7,8 @@ namespace hr { +ld eyepos; + #if MAXMDIM >= 4 #define S (scalefactor / 0.805578) @@ -343,7 +345,7 @@ void addtri(array hs, int kind) { } if(kind) { - hyperpoint ht[3]; + array ht; ld hsh[3]; ld shi[3]; bool ok = true; @@ -356,26 +358,50 @@ void addtri(array hs, int kind) { zz -= h[0] * h[0] / 0.10 / 0.10 * 0.01 / S / S * SH; if(abs(h[1]) > 0.14*S) ok = false, zz -= revZ * (abs(h[1])/S - 0.14) * SH; if(abs(h[0]) > 0.08*S) ok = false, zz -= revZ * (abs(h[0])/S - 0.08) * (abs(h[0])/S - 0.08) * 25 * SH; - hpcpush(ht[s] = zpush(zz) * h); - if(hsh[s] < 0.1*S) shi[s] = -0.5; - else if(hsh[s] < 0.12*S) shi[s] = -0.1 - 0.4 * (hsh[s]/S - 0.1) / (0.12 - 0.1); - else shi[s] = -0.1; - shi[s] *= geom3::human_height * revZ; + h = normalize(h); + ht[s] = zpush(zz) * h; + if(hsh[s] < 0.1*S) shi[s] = 0.5; + else if(hsh[s] < 0.12*S) shi[s] = 0.1 + 0.4 * (hsh[s]/S - 0.1) / (0.12 - 0.1); + else shi[s] = 0.1; } - if(ok && kind == 1) for(int i=0; i<3; i++) { - int j = (i+1) % 3; - hpcpush(ht[i]); - hpcpush(ht[j]); - hpcpush(zpush(shi[i]) * ht[i]); - hpcpush(ht[j]); - hpcpush(zpush(shi[i]) * ht[i]); - hpcpush(zpush(shi[i]) * ht[j]); + if(ok && kind == 1) { + array, 6> htx; + for(int i=0; i<6; i++) htx[i] = ht; + + for(int i=0; i<3; i++) { + htx[0][i][0] *= 0.7; htx[0][i][1] *= 0.7; + htx[1][i][0] *= 1.2; htx[1][i][1] *= 1.7; + htx[2][i][1] *= 1.7; + htx[4][i][0] = htx[4][i][0] * 0.4 + scalefactor * 0.1; + htx[5][i][0] = htx[5][i][0] * 0.3 + scalefactor * 0.1; + for(int a=0; a<6; a++) htx[a][i] = hpxy3(htx[a][i][0], htx[a][i][1], htx[a][i][2]); + } + ld levels[6] = {0, 0.125, 0.125, 0.250, 0.375, 0.5}; + for(int a=0; a<6; a++) for(int i=0; i<3; i++) + htx[a][i] = zpush(-min(shi[i], levels[a]) * geom3::human_height * revZ) * htx[a][i]; + + hpcpush(htx[0][0]); + hpcpush(htx[0][1]); + hpcpush(htx[0][2]); + + for(int a=0; a<5; a++) for(int i=0; i<3; i++) { + int j = (i+1) % 3; + int b = a+1; + hpcpush(htx[a][i]); + hpcpush(htx[a][j]); + hpcpush(htx[b][i]); + hpcpush(htx[a][j]); + hpcpush(htx[b][i]); + hpcpush(htx[b][j]); + } } + else + hpcpush(ht[0]), hpcpush(ht[1]), hpcpush(ht[2]); } else { for(int s=0; s<3; s++) { hyperpoint h = hs[s]; - ld zz = zc(0.925); + ld zz = zc(eyepos); if(h[0] < -0.05*S) zz += revZ * (h[0]/S + 0.05) * SH; if(hdist0(h) <= 0.0501*S) { zz += revZ * sqrt(0.0026 - pow(hdist0(h)/S, 2)) * SH; @@ -434,7 +460,7 @@ void make_foot_3d(hpcshape& sh) { void make_head_only() { auto addpt = [] (int d, int u) { - hpcpush(zpush(zc(0.925) + 0.06 * SH * sin(u * degree)) * xspinpush0(d * degree, 0.05 * S * cos(u * degree))); + hpcpush(zpush(zc(eyepos) + 0.06 * SH * sin(u * degree)) * xspinpush0(d * degree, 0.05 * S * cos(u * degree))); }; bshape(shPHeadOnly, shPHeadOnly.prio); @@ -712,6 +738,7 @@ hyperpoint psmin(hyperpoint H) { } void adjust_eye(hpcshape& eye, hpcshape head, ld shift_eye, ld shift_head, int q, ld zoom=1) { + eyepos = WDIM == 2 ? 0.875 : 0.925; using namespace hyperpoint_vec; hyperpoint center = Hypc; for(int i=eye.s; i 0) center += hpc[i]; @@ -743,7 +770,7 @@ void adjust_eye(hpcshape& eye, hpcshape head, ld shift_eye, ld shift_head, int q if(&eye == &shSkullEyes) println(hlog, "skull pos = ", pos); if(&eye == &shSkullEyes) - pos = zc(0.925) - 0.06 * SH * 0.05; + pos = zc(eyepos) - 0.06 * SH * 0.05; make_ball(eye, rad, 0); transmatrix T = zpush(-shift_eye) * rgpushxto0(center) * zpush(pos); diff --git a/config.cpp b/config.cpp index 43987cdd..02f18b04 100644 --- a/config.cpp +++ b/config.cpp @@ -100,8 +100,7 @@ unsigned int haircolors[] = { 8, 0x686868FF, 0x8C684AFF, 0xF2E1AEFF, 0xB55239FF unsigned int dresscolors[] = { 6, 0xC00000FF, 0x00C000FF, 0x0000C0FF, 0xC0C000FF, 0xC0C0C0FF, 0x202020FF }; unsigned int dresscolors2[] = { 7, 0x8080FFC0, 0x80FF80C0, 0xFF8080C0, 0xFFFF80C0, 0xFF80FFC0, 0x80FFFFC0, 0xFFFFFF80 }; unsigned int swordcolors[] = { 6, 0xC0C0C0FF, 0xFFFFFFFF, 0xFFC0C0FF, 0xC0C0FFFF, 0x808080FF, 0x202020FF }; -unsigned int eyecolors[] = { 4, 0x00C000FF, 0x0000C0FF, 0xC00000FF, 0xC0C000FF }; - +unsigned int eyecolors[] = { 4, 0x00C000FF, 0x0000C0FF, 0xC00000FF, 0xC0C000FF, 0x804010FF, 0x00C000FF }; void initcs(charstyle &cs) { cs.charid = 0; @@ -111,6 +110,7 @@ void initcs(charstyle &cs) { cs.swordcolor = 0xD0D0D0FF; cs.dresscolor2= 0x8080FFC0; cs.uicolor = 0xFF0000FF; + cs.eyecolor = 0x603000FF; cs.lefthanded = false; } @@ -1505,6 +1505,7 @@ void showCustomizeChar() { dialog::addSelItem(XLAT("character"), csname(cs), 'g'); dialog::addColorItem(XLAT("skin color"), cs.skincolor, 's'); + dialog::addColorItem(XLAT("eye color"), cs.eyecolor, 'e'); dialog::addColorItem(XLAT("weapon color"), cs.swordcolor, 'w'); dialog::addColorItem(XLAT("hair color"), cs.haircolor, 'h'); @@ -1550,10 +1551,11 @@ void showCustomizeChar() { else if(uni == 'p') vid.samegender = !vid.samegender; else if(uni == 's') switchcolor(cs.skincolor, cat ? haircolors : skincolors); else if(uni == 'h') switchcolor(cs.haircolor, haircolors); - else if(uni == 'w') switchcolor(cs.swordcolor, cat ? eyecolors : swordcolors); + else if(uni == 'w') switchcolor(cs.swordcolor, swordcolors); else if(uni == 'd') switchcolor(cs.dresscolor, cat ? haircolors : dresscolors); else if(uni == 'f') switchcolor(cs.dresscolor2, dresscolors2); else if(uni == 'u') switchcolor(cs.uicolor, eyecolors); + else if(uni == 'e') switchcolor(cs.eyecolor, eyecolors); else if(uni == 'l') cs.lefthanded = !cs.lefthanded; else if(doexiton(sym, uni)) popScreen(); }; diff --git a/graph.cpp b/graph.cpp index 2a3ee21b..b14dbf68 100644 --- a/graph.cpp +++ b/graph.cpp @@ -949,6 +949,15 @@ void drawTerraWarrior(const transmatrix& V, int t, int hp, double footphase) { } #endif +color_t skincolor = 0xD0C080FF; + +void humanoid_eyes(const transmatrix& V, color_t ecol, color_t hcol = skincolor) { + if(DIM == 3) { + queuepoly(VHEAD, shPHeadOnly, hcol); + queuepoly(VHEAD, shSkullEyes, ecol); + } + } + void drawPlayer(eMonster m, cell *where, const transmatrix& V, color_t col, double footphase) { charstyle& cs = getcs(); @@ -965,7 +974,7 @@ void drawPlayer(eMonster m, cell *where, const transmatrix& V, color_t col, doub queuepoly(VABODY, shWolfBody, fc(0, cs.skincolor, 0)); queuepoly(VAHEAD, shFamiliarHead, fc(500, cs.haircolor, 2)); if(!shmup::on || shmup::curtime >= shmup::getPlayer()->nextshot) { - color_t col = items[itOrbDiscord] ? watercolor(0) : fc(314, cs.swordcolor, 3); + color_t col = items[itOrbDiscord] ? watercolor(0) : fc(314, cs.eyecolor, 3); queuepoly(VAHEAD, shFamiliarEye, col); queuepoly(VAHEAD * Mirror, shFamiliarEye, col); } @@ -988,7 +997,7 @@ void drawPlayer(eMonster m, cell *where, const transmatrix& V, color_t col, doub queuepoly(VAHEAD, shDogHead, fc(150, cs.haircolor, 2)); if(!shmup::on || shmup::curtime >= shmup::getPlayer()->nextshot) { - color_t col = items[itOrbDiscord] ? watercolor(0) : fc(314, cs.swordcolor, 3); + color_t col = items[itOrbDiscord] ? watercolor(0) : fc(314, cs.eyecolor, 3); queuepoly(VAHEAD, shWolf1, col); queuepoly(VAHEAD, shWolf2, col); } @@ -1013,7 +1022,7 @@ void drawPlayer(eMonster m, cell *where, const transmatrix& V, color_t col, doub queuepoly(VABODY, shCatBody, fc(0, cs.skincolor, 0)); queuepoly(VAHEAD, shCatHead, fc(150, cs.haircolor, 2)); if(!shmup::on || shmup::curtime >= shmup::getPlayer()->nextshot) { - color_t col = items[itOrbDiscord] ? watercolor(0) : fc(314, cs.swordcolor, 3); + color_t col = items[itOrbDiscord] ? watercolor(0) : fc(314, cs.eyecolor, 3); queuepoly(VAHEAD * xpush(.04), shWolf1, col); queuepoly(VAHEAD * xpush(.04), shWolf2, col); } @@ -1096,6 +1105,8 @@ void drawPlayer(eMonster m, cell *where, const transmatrix& V, color_t col, doub queuepoly(VHEAD, shPFace, fc(500, cs.skincolor, 1)); queuepoly(VHEAD1, (cs.charid&1) ? shFemaleHair : shPHead, fc(150, cs.haircolor, 2)); } + + humanoid_eyes(V, cs.eyecolor, cs.skincolor); if(knighted) queuepoly(VBODY * VBS, shKnightCloak, darkena(cloakcolor(knighted), 1, 0xFF)); @@ -1180,15 +1191,6 @@ void drawMimic(eMonster m, cell *where, const transmatrix& V, color_t col, doubl } } -color_t skincolor = 0xD0C080FF; - -void humanoid_eyes(const transmatrix& V, color_t ecol, color_t hcol = skincolor) { - if(DIM == 3) { - queuepoly(VHEAD, shPHeadOnly, hcol); - queuepoly(VHEAD, shSkullEyes, ecol); - } - } - bool drawMonsterType(eMonster m, cell *where, const transmatrix& V1, color_t col, double footphase) { #if MAXMDIM >= 4 @@ -1307,7 +1309,7 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V1, color_t col if(m == moRoseLady) { // queuepoly(V, girl ? shGoatHead : shDemon, 0x800000FF); // make her hair a bit darker to stand out in 3D - queuepoly(VHEAD1, girl ? shFemaleHair : shPHead, evil ? 0x500050FF : DIM == 3 ? 0x433A32FF : 0x332A22FF); + queuepoly(VHEAD1, girl ? shFemaleHair : shPHead, evil ? 0x500050FF : DIM == 3 ? 0x666A64FF : 0x332A22FF); } else if(m == moRoseBeauty) { if(girl) { diff --git a/hyper.h b/hyper.h index e68ded5e..1519054d 100644 --- a/hyper.h +++ b/hyper.h @@ -835,7 +835,7 @@ void activateActiv(cell *c, bool msg); struct charstyle { int charid; - color_t skincolor, haircolor, dresscolor, swordcolor, dresscolor2, uicolor; + color_t skincolor, haircolor, dresscolor, swordcolor, dresscolor2, uicolor, eyecolor; bool lefthanded; };