From 798f4b54f77b993eb19e1400684634ac2f21edb8 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 11 May 2019 15:04:54 +0200 Subject: [PATCH] 3d:: nicer effects for orbs --- 3d-models.cpp | 41 ++++++++++++++++++++++++++++++++++++ graph.cpp | 58 ++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 85 insertions(+), 14 deletions(-) diff --git a/3d-models.cpp b/3d-models.cpp index 07ead088..982c656c 100644 --- a/3d-models.cpp +++ b/3d-models.cpp @@ -688,6 +688,47 @@ void make_ball(hpcshape& sh, ld rad, int lev) { add_texture(sh); } +void queueball(const transmatrix& V, ld rad, color_t col, eItem what) { + if(what == itOrbSpeed) { + transmatrix V1 = V * cspin(1, 2, M_PI/2); + ld tt = ptick(100); + for(int t=0; t<5; t++) { + for(int a=-50; a<50; a++) + curvepoint(V1 * cspin(0, 2, a * M_PI/100.) * cspin(0, 1, t * 72 * degree + tt + a*2*M_PI/50.) * xpush0(rad)); + queuecurve(col, 0, PPR::LINE); + } + return; + } + ld z = 63.43 * degree; + transmatrix V1 = V * cspin(0, 2, M_PI/2); + if(what == itOrbShield) V1 = V * cspin(0, 1, ptick(500)); + if(what == itOrbFlash) V1 = V * cspin(0, 1, ptick(1500)); + if(what == itOrbShield) V1 = V * cspin(1, 2, ptick(1000)); + if(what == itOrbFlash) V1 = V * cspin(1, 2, ptick(750)); + if(what == itDiamond) V1 = V * cspin(1, 2, ptick(200)); + if(what == itRuby) V1 = V * cspin(1, 2, ptick(300)); + auto line = [&] (transmatrix A, transmatrix B) { + hyperpoint h0 = A * xpush0(1); + hyperpoint h1 = B * xpush0(1); + using namespace hyperpoint_vec; + for(int i=0; i<=8; i++) + curvepoint(V1 * rspintox(normalize(h0*(8-i) + h1*i)) * xpush0(rad)); + queuecurve(col, 0, PPR::LINE); + }; + for(int i=0; i<5; i++) { + auto a = cspin(1, 2, (72 * i ) * degree) * spin(z); + auto b = cspin(1, 2, (72 * i-72) * degree) * spin(z); + auto c = cspin(1, 2, (72 * i+36) * degree) * spin(M_PI-z); + auto d = cspin(1, 2, (72 * i-36) * degree) * spin(M_PI-z); + line(Id, a); + line(a, b); + line(a, c); + line(a, d); + line(d, c); + line(c, spin(M_PI)); + } + } + void make_3d_models() { if(DIM == 2) return; shcenter = C0; diff --git a/graph.cpp b/graph.cpp index 98d018bd..e56599ca 100644 --- a/graph.cpp +++ b/graph.cpp @@ -159,6 +159,8 @@ int lightat, safetyat; void drawLightning() { lightat = ticks; } void drawSafety() { safetyat = ticks; } +void queueball(const transmatrix& V, ld rad, color_t col, eItem what); + void drawShield(const transmatrix& V, eItem it) { #if CAP_CURVE float ds = ptick(300); @@ -169,9 +171,13 @@ void drawShield(const transmatrix& V, eItem it) { col = 0; double d = it == itOrbShield ? hexf : hexf - .1; int mt = sphere ? 7 : 5; - for(ld a=0; a<=S84*mt+1e-6; a+=pow(.5, vid.linequality)) - curvepoint(V*xspinpush0(a * M_PI/S42, d + sin(ds + M_PI*2*a/4/mt)*.1)); - queuecurve(darkena(col, 0, 0xFF), 0x8080808, PPR::LINE); + if(DIM == 3) + queueball(V * zpush(geom3::GROIN1), geom3::human_height / 2, darkena(col, 0, 0xFF), itOrbShield); + else { + for(ld a=0; a<=S84*mt+1e-6; a+=pow(.5, vid.linequality)) + curvepoint(V*xspinpush0(a * M_PI/S42, d + sin(ds + M_PI*2*a/4/mt)*.1)); + queuecurve(darkena(col, 0, 0xFF), 0x8080808, PPR::LINE); + } #endif } @@ -179,7 +185,8 @@ void drawSpeed(const transmatrix& V) { #if CAP_CURVE ld ds = ptick(10); color_t col = darkena(iinf[itOrbSpeed].color, 0, 0xFF); - for(int b=0; b 500) flashcol = gradient(flashcol, 0, 500, u, 1100); flashcol = darkena(flashcol, 0, 0xFF); - PRING(a) curvepoint(V*xspinpush0(a * M_PI / S42, rad)); - queuecurve(flashcol, 0x8080808, PPR::LINE); + if(DIM == 3) + queueball(V * zpush(geom3::GROIN1), rad, flashcol, itDiamond); + else { + PRING(a) curvepoint(V*xspinpush0(a * M_PI / S42, rad)); + queuecurve(flashcol, 0x8080808, PPR::LINE); + } } } else if(f.size == 2000) { @@ -6122,8 +6148,12 @@ void drawFlashes() { int flashcol = f.color; if(u > 1000) flashcol = gradient(flashcol, 0, 1000, u, 2200); flashcol = darkena(flashcol, 0, 0xFF); - PRING(a) curvepoint(V*xspinpush0(a * M_PI / S42, rad)); - queuecurve(flashcol, 0x8080808, PPR::LINE); + if(DIM == 3) + queueball(V * zpush(geom3::GROIN1), rad, flashcol, itRuby); + else { + PRING(a) curvepoint(V*xspinpush0(a * M_PI / S42, rad)); + queuecurve(flashcol, 0x8080808, PPR::LINE); + } } }