1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-27 14:37:16 +00:00

3D:: animation for all birds; fixed a crash on Butterfly drawing

This commit is contained in:
Zeno Rogue 2019-05-16 17:08:12 +02:00
parent dc92ff2eda
commit fc7100bbf1
3 changed files with 47 additions and 22 deletions

View File

@ -682,8 +682,8 @@ void animate_bird(hpcshape& orig, hpcshape animated[30], ld body) {
} }
} }
} }
for(int i=0; i<30; i++) shift_shape(animated[i], geom3::BIRD); // for(int i=0; i<30; i++) shift_shape(animated[i], geom3::BIRD);
shift_shape(orig, geom3::BIRD); // shift_shape(orig, geom3::BIRD);
} }
void slimetriangle(hyperpoint a, hyperpoint b, hyperpoint c, ld rad, int lev) { void slimetriangle(hyperpoint a, hyperpoint b, hyperpoint c, ld rad, int lev) {
@ -978,8 +978,8 @@ void make_3d_models() {
make_revolution_cut(shGhost, 60, geom3::GHOST + g); make_revolution_cut(shGhost, 60, geom3::GHOST + g);
make_revolution_cut(shEagle, 180, -geom3::BIRD, 0.05*S); make_revolution_cut(shEagle, 180, 0, 0.05*S);
make_revolution_cut(shHawk, 180, -geom3::BIRD, 0.05*S); make_revolution_cut(shHawk, 180, 0, 0.05*S);
make_revolution_cut(shTinyBird, 180, 0, 0.025 * S); make_revolution_cut(shTinyBird, 180, 0, 0.025 * S);
make_revolution_cut(shTinyShark, 90); make_revolution_cut(shTinyShark, 90);
@ -987,14 +987,14 @@ void make_3d_models() {
make_revolution_cut(shGargoyleWings, 180, 0, 0.05*S); make_revolution_cut(shGargoyleWings, 180, 0, 0.05*S);
make_revolution_cut(shGargoyleBody, 180, 0, 0.05*S); make_revolution_cut(shGargoyleBody, 180, 0, 0.05*S);
make_revolution_cut(shGadflyWing, 180, -geom3::BIRD, 0.05*S); make_revolution_cut(shGadflyWing, 180, 0, 0.05*S);
make_revolution_cut(shBatWings, 180, -geom3::BIRD, 0.05*S); make_revolution_cut(shBatWings, 180, 0, 0.05*S);
make_revolution_cut(shBatBody, 180, -geom3::BIRD, 0.05*S); make_revolution_cut(shBatBody, 180, 0, 0.05*S);
make_revolution_cut(shJelly, 60); make_revolution_cut(shJelly, 60);
make_revolution(shFoxTail1); make_revolution(shFoxTail1);
make_revolution(shFoxTail2); make_revolution(shFoxTail2);
make_revolution(shGadflyBody, 180, -geom3::BIRD); make_revolution(shGadflyBody, 180, 0);
for(int i=0; i<8; i++) for(int i=0; i<8; i++)
make_revolution(shAsteroid[i], 360); make_revolution(shAsteroid[i], 360);
@ -1003,11 +1003,21 @@ void make_3d_models() {
make_revolution(shBugArmor, 180, geom3::ABODY); make_revolution(shBugArmor, 180, geom3::ABODY);
make_revolution_cut(shBugAntenna, 90, geom3::ABODY); make_revolution_cut(shBugAntenna, 90, geom3::ABODY);
make_revolution_cut(shButterflyBody, 180, -geom3::BIRD); make_revolution_cut(shButterflyBody, 180, 0);
make_revolution_cut(shButterflyWing, 180, 0, 0.05*S);
finishshape();
animate_bird(shEagle, shAnimatedEagle, 0.05*S); animate_bird(shEagle, shAnimatedEagle, 0.05*S);
animate_bird(shTinyBird, shAnimatedTinyEagle, 0.05*S/2); animate_bird(shTinyBird, shAnimatedTinyEagle, 0.05*S/2);
animate_bird(shButterflyWing, shAnimatedButterfly, 0);
animate_bird(shGadflyWing, shAnimatedGadfly, 0);
animate_bird(shHawk, shAnimatedHawk, 0.05*S);
animate_bird(shGargoyleWings, shAnimatedGargoyle, 0.05*S);
animate_bird(shGargoyleBody, shAnimatedGargoyle2, 0.05*S);
animate_bird(shBatWings, shAnimatedBat, 0.05*S);
animate_bird(shBatBody, shAnimatedBat2, 0.05*S);
disable(shWolfRearLeg); disable(shWolfRearLeg);
disable(shWolfFrontLeg); disable(shWolfFrontLeg);
disable(shDogRearLeg); disable(shDogRearLeg);

View File

@ -1149,6 +1149,18 @@ void drawPlayer(eMonster m, cell *where, const transmatrix& V, color_t col, doub
} }
} }
int wingphase(int period, int phase = 0) {
ld t = fractick(period, phase);
return int(t * 30) % 30;
}
transmatrix wingmatrix(int period, int phase = 0) {
ld t = fractick(period, phase) * 2 * M_PI;
transmatrix Vwing = Id;
Vwing[1][1] = .85 + .15 * sin(t);
return Vwing;
}
void drawMimic(eMonster m, cell *where, const transmatrix& V, color_t col, double footphase) { void drawMimic(eMonster m, cell *where, const transmatrix& V, color_t col, double footphase) {
charstyle& cs = getcs(); charstyle& cs = getcs();
@ -1475,7 +1487,7 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V1, color_t col
case moTameBomberbird: case moWindCrow: case moTameBomberbirdMoved: case moTameBomberbird: case moWindCrow: case moTameBomberbirdMoved:
case moSandBird: case moAcidBird: { case moSandBird: case moAcidBird: {
ShadowV(V, shEagle); ShadowV(V, shEagle);
auto& sh = DIM == 3 ? shAnimatedEagle[((long long)(ticks) * 30 / 1000) % 30] : shEagle; auto& sh = DIM == 3 ? shAnimatedEagle[wingphase(200)] : shEagle;
if(m == moParrot && DIM == 3) if(m == moParrot && DIM == 3)
queuepolyat(VBIRD, sh, darkena(col, 0, 0xFF), PPR::SUPERLINE); queuepolyat(VBIRD, sh, darkena(col, 0, 0xFF), PPR::SUPERLINE);
else else
@ -1485,24 +1497,26 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V1, color_t col
case moSparrowhawk: case moWestHawk: { case moSparrowhawk: case moWestHawk: {
ShadowV(V, shHawk); ShadowV(V, shHawk);
queuepoly(VBIRD, shHawk, darkena(col, 0, 0xFF)); auto& sh = DIM == 3 ? shAnimatedHawk[wingphase(200)] : shHawk;
queuepoly(VBIRD, sh, darkena(col, 0, 0xFF));
return false; return false;
} }
case moButterfly: { case moButterfly: {
transmatrix Vwing = Id; transmatrix Vwing = wingmatrix(100);
Vwing[1][1] = .85 + .15 * sintick(100);
ShadowV(V * Vwing, shButterflyWing); ShadowV(V * Vwing, shButterflyWing);
if(DIM == 2)
queuepoly(VBIRD * Vwing, shButterflyWing, darkena(col, 0, 0xFF)); queuepoly(VBIRD * Vwing, shButterflyWing, darkena(col, 0, 0xFF));
else
queuepoly(VBIRD, shAnimatedButterfly[wingphase(100)], darkena(col, 0, 0xFF));
queuepoly(VBIRD, shButterflyBody, darkena(col, 2, 0xFF)); queuepoly(VBIRD, shButterflyBody, darkena(col, 2, 0xFF));
return false; return false;
} }
case moGadfly: { case moGadfly: {
transmatrix Vwing = Id; transmatrix Vwing = wingmatrix(100);
Vwing[1][1] = .85 + .15 * sintick(100);
ShadowV(V * Vwing, shGadflyWing); ShadowV(V * Vwing, shGadflyWing);
queuepoly(VBIRD * Vwing, shGadflyWing, darkena(col, 0, 0xFF)); queuepoly(VBIRD * Vwing, DIM == 2 ? shGadflyWing : shAnimatedGadfly[wingphase(100)], darkena(col, 0, 0xFF));
queuepoly(VBIRD, shGadflyBody, darkena(col, 1, 0xFF)); queuepoly(VBIRD, shGadflyBody, darkena(col, 1, 0xFF));
queuepoly(VBIRD, shGadflyEye, darkena(col, 2, 0xFF)); queuepoly(VBIRD, shGadflyEye, darkena(col, 2, 0xFF));
queuepoly(VBIRD * Mirror, shGadflyEye, darkena(col, 2, 0xFF)); queuepoly(VBIRD * Mirror, shGadflyEye, darkena(col, 2, 0xFF));
@ -1513,8 +1527,8 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V1, color_t col
// vampires have no shadow and no mirror images // vampires have no shadow and no mirror images
if(m == moBat) ShadowV(V, shBatWings); if(m == moBat) ShadowV(V, shBatWings);
if(m == moBat || !inmirrorcount) { if(m == moBat || !inmirrorcount) {
queuepoly(VBIRD, shBatWings, darkena(0x303030, 0, 0xFF)); queuepoly(VBIRD, DIM == 2 ? shBatWings : shAnimatedBat[wingphase(100)], darkena(0x303030, 0, 0xFF));
queuepoly(VBIRD, shBatBody, darkena(0x606060, 0, 0xFF)); queuepoly(VBIRD, DIM == 2 ? shBatBody : shAnimatedBat2[wingphase(100)], darkena(0x606060, 0, 0xFF));
} }
/* queuepoly(V, shBatMouth, darkena(0xC00000, 0, 0xFF)); /* queuepoly(V, shBatMouth, darkena(0xC00000, 0, 0xFF));
queuepoly(V, shBatFang, darkena(0xFFC0C0, 0, 0xFF)); queuepoly(V, shBatFang, darkena(0xFFC0C0, 0, 0xFF));
@ -1526,8 +1540,8 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V1, color_t col
case moGargoyle: { case moGargoyle: {
ShadowV(V, shGargoyleWings); ShadowV(V, shGargoyleWings);
queuepoly(VBIRD, shGargoyleWings, darkena(col, 0, 0xD0)); queuepoly(VBIRD, DIM == 2 ? shGargoyleWings : shAnimatedGargoyle[wingphase(300)], darkena(col, 0, 0xD0));
queuepoly(VBIRD, shGargoyleBody, darkena(col, 0, 0xFF)); queuepoly(VBIRD, DIM == 2 ? shGargoyleBody : shAnimatedGargoyle2[wingphase(300)], darkena(col, 0, 0xFF));
return false; return false;
} }

View File

@ -1748,7 +1748,8 @@ hpcshape
shPBodyOnly, shPBodyArm, shPBodyHand, shPHeadOnly, shPBodyOnly, shPBodyArm, shPBodyHand, shPHeadOnly,
shAnimatedEagle[30], shAnimatedTinyEagle[30], shAnimatedEagle[30], shAnimatedTinyEagle[30], shAnimatedGadfly[30], shAnimatedHawk[30], shAnimatedButterfly[30],
shAnimatedGargoyle[30], shAnimatedGargoyle2[30], shAnimatedBat[30], shAnimatedBat2[30],
shDodeca; shDodeca;