3d:: nicer effects for orbs

This commit is contained in:
Zeno Rogue 2019-05-11 15:04:54 +02:00
parent 2c98f9dcf6
commit 798f4b54f7
2 changed files with 85 additions and 14 deletions

View File

@ -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;

View File

@ -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<S84; b+=S14) {
if(DIM == 3) queueball(V * zpush(geom3::GROIN1), geom3::human_height * 0.55, col, itOrbSpeed);
else for(int b=0; b<S84; b+=S14) {
PRING(a)
curvepoint(V*xspinpush0((ds+b+a) * M_PI/S42, hexf*a/S84));
queuecurve(col, 0x8080808, PPR::LINE);
@ -207,7 +214,9 @@ void drawSafety(const transmatrix& V, int ct) {
#if CAP_QUEUE
ld ds = ptick(50);
color_t col = darkena(iinf[itOrbSafety].color, 0, 0xFF);
for(int a=0; a<ct; a++)
if(DIM == 3)
queueball(V * zpush(geom3::GROIN1), 2*hexf, col, itOrbSafety);
else for(int a=0; a<ct; a++)
queueline(V*xspinpush0((ds+a*S84/ct) * M_PI/S42, 2*hexf), V*xspinpush0((ds+(a+(ct-1)/2)*S84/ct) * M_PI / S42, 2*hexf), col, vid.linequality);
#endif
}
@ -219,12 +228,22 @@ void drawFlash(const transmatrix& V) {
col &= ~1;
for(int u=0; u<5; u++) {
ld rad = hexf * (2.5 + .5 * sin(ds+u*.3));
PRING(a) curvepoint(V*xspinpush0(a * M_PI / S42, rad));
queuecurve(col, 0x8080808, PPR::LINE);
if(DIM == 3) {
queueball(V * zpush(geom3::GROIN1), rad, col, itOrbFlash);
}
else {
PRING(a) curvepoint(V*xspinpush0(a * M_PI / S42, rad));
queuecurve(col, 0x8080808, PPR::LINE);
}
}
#endif
}
transmatrix chei(const transmatrix V, int a, int b) {
if(DIM == 2) return V;
return V * zpush(geom3::FLOOR + (geom3::HEAD - geom3::FLOOR) * (a+.5) / b);
}
void drawLove(const transmatrix& V, int hdir) {
#if CAP_CURVE
float ds = ptick(300);
@ -237,7 +256,8 @@ void drawLove(const transmatrix& V, int hdir) {
if(z <= 10) d += (10-z) * (10-z) * (10-z) / 3000.;
ld rad = hexf * (2.5 + .5 * sin(ds+u*.3)) * d;
curvepoint(V*xspinpush0((S42+hdir+a-1) * M_PI/S42, rad));
transmatrix V1 = chei(V, u, 5);
curvepoint(V1*xspinpush0((S42+hdir+a-1) * M_PI/S42, rad));
}
queuecurve(col, 0x8080808, PPR::LINE);
}
@ -250,7 +270,8 @@ void drawWinter(const transmatrix& V, ld hdir) {
color_t col = darkena(iinf[itOrbWinter].color, 0, 0xFF);
for(int u=0; u<20; u++) {
ld rad = sin(ds+u * 2 * M_PI / 20) * M_PI / S7;
queueline(V*xspinpush0(M_PI+hdir+rad, hexf*.5), V*xspinpush0(M_PI+hdir+rad, hexf*3), col, 2 + vid.linequality);
transmatrix V1 = chei(V, u, 20);
queueline(V1*xspinpush0(M_PI+hdir+rad, hexf*.5), V1*xspinpush0(M_PI+hdir+rad, hexf*3), col, 2 + vid.linequality);
}
#endif
}
@ -261,7 +282,8 @@ void drawLightning(const transmatrix& V) {
for(int u=0; u<20; u++) {
ld leng = 0.5 / (0.1 + (rand() % 100) / 100.0);
ld rad = rand() % 1000;
queueline(V*xspinpush0(rad, hexf*0.3), V*xspinpush0(rad, hexf*leng), col, 2 + vid.linequality);
transmatrix V1 = chei(V, u, 20);
queueline(V1*xspinpush0(rad, hexf*0.3), V1*xspinpush0(rad, hexf*leng), col, 2 + vid.linequality);
}
#endif
}
@ -6108,8 +6130,12 @@ void drawFlashes() {
int flashcol = f.color;
if(u > 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);
}
}
}