1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-19 03:34:49 +00:00

conformal:: more precise line animation

This commit is contained in:
Zeno Rogue 2018-04-21 12:12:52 +02:00
parent 295e2b9f82
commit 2eaff9ac46
4 changed files with 131 additions and 108 deletions

View File

@ -493,6 +493,9 @@ else if(args()[0] == '-' && args()[1] == x && args()[2] == '0') { showstartmenu
PHASEFROM(2); PHASEFROM(2);
shift(); sightrange_bonus = genrange_bonus = gamerange_bonus = argi(); autocheat = true; shift(); sightrange_bonus = genrange_bonus = gamerange_bonus = argi(); autocheat = true;
} }
else if(argis("-els")) {
shift(); conformal::extra_line_steps = argf();
}
else if(argis("-we")) { else if(argis("-we")) {
PHASEFROM(2); PHASEFROM(2);
shift(); whatever = argf(); resetGeometry(); shift(); whatever = argf(); resetGeometry();

View File

@ -192,6 +192,7 @@ void initConfig() {
addsaver(polygonal::deg, "polygonal degree"); addsaver(polygonal::deg, "polygonal degree");
addsaver(conformal::autobandhistory, "include history"); // check! addsaver(conformal::autobandhistory, "include history"); // check!
addsaver(conformal::lvspeed, "lineview speed"); addsaver(conformal::lvspeed, "lineview speed");
addsaver(conformal::extra_line_steps, "lineview extension");
addsaver(polygonal::maxcoef, "polynomial degree"); addsaver(polygonal::maxcoef, "polynomial degree");
for(int i=0; i<polygonal::MSI; i++) { for(int i=0; i<polygonal::MSI; i++) {

View File

@ -279,6 +279,8 @@ namespace conformal {
bool autobandhistory = false; bool autobandhistory = false;
bool dospiral = true; bool dospiral = true;
ld extra_line_steps = 0;
void clear() { void clear() {
on = false; on = false;
int N = size(v); int N = size(v);
@ -287,7 +289,7 @@ namespace conformal {
} }
void create() { void create() {
if(celldist(cwt.c) <= 7) { if(celldist(cwt.c) == 0) {
addMessage("Must go a distance from the starting point"); addMessage("Must go a distance from the starting point");
return; return;
} }
@ -295,14 +297,6 @@ namespace conformal {
on = true; on = true;
cell *c = cwt.c; cell *c = cwt.c;
for(int q=0; q<5; q++) {
for(int i=0; i<c->type; i++)
if(celldist(c->mov[i]) > celldist(c)) {
c = c->mov[i];
break;
}
}
while(true) { while(true) {
shmup::monster *m = new shmup::monster; shmup::monster *m = new shmup::monster;
m->at = Id; m->at = Id;
@ -346,15 +340,27 @@ namespace conformal {
fixmatrix(v[j]->at); fixmatrix(v[j]->at);
} }
} }
hyperpoint next0 = shmup::calc_relative_matrix(v[1]->base, v[0]->base->master) *
v[1]->at * C0;
v[0]->at = v[0]->at * rspintox(inverse(v[0]->at) * next0);
llv = ticks; llv = ticks;
phase = 0; phase = 0;
for(int j=0; j<=Q; j++) {
hyperpoint cur = v[j]->at * C0;
printf("%4d/%3d. %p [%3d] %s\n", j, Q, v[j]->base, celldist(v[j]->base), display(cur));
}
} }
void movetophase() { void movetophase() {
int ph = int(phase); int ph = int(phase);
int siz = size(v); int siz = size(v);
if(ph<0 || ph >= siz-1) return; if(ph<0) ph = 0;
if(ph >= siz-1) ph = siz-2;
viewctr.h = v[ph]->base->master; viewctr.h = v[ph]->base->master;
viewctr.spin = 0; viewctr.spin = 0;
@ -370,6 +376,8 @@ namespace conformal {
View = spin(M_PI/180 * rotation) * xpush(-(phase-ph) * hdist(now, next)) * View; View = spin(M_PI/180 * rotation) * xpush(-(phase-ph) * hdist(now, next)) * View;
playermoved = false; playermoved = false;
centerover.c = v[ph]->base;
compute_graphical_distance();
} }
void apply() { void apply() {
@ -379,20 +387,19 @@ namespace conformal {
int siz = size(v); int siz = size(v);
while(phase < 1) phase += siz - 2; while(phase > siz-1 + extra_line_steps) phase -= (siz + 2 * extra_line_steps-1);
while(phase >= siz-1) phase -= siz - 2; while(phase < - extra_line_steps) phase += (siz + 2 * extra_line_steps-1);
movetophase(); movetophase();
} }
int measureLength() { ld measureLength() {
int rad = vid.radius; ld r = bandhalf * vid.scale;
vid.radius = bandhalf;
int tpixels = 0; ld tpixels = 0;
int siz = size(v); int siz = size(v);
for(int j=1; j<siz-1; j++) { for(int j=0; j<siz-1; j++) {
hyperpoint next = hyperpoint next =
inverse(v[j]->at) * inverse(v[j]->at) *
shmup::calc_relative_matrix(v[j+1]->base, v[j]->base->master) * shmup::calc_relative_matrix(v[j+1]->base, v[j]->base->master) *
@ -400,10 +407,12 @@ namespace conformal {
hyperpoint nextscr; hyperpoint nextscr;
applymodel(next, nextscr); applymodel(next, nextscr);
tpixels += nextscr[0] * vid.radius; tpixels += nextscr[0] * r;
if(j == 0 || j == siz-2)
tpixels += nextscr[0] * r * extra_line_steps;
} }
vid.radius = rad;
return tpixels; return tpixels;
} }
@ -413,33 +422,38 @@ namespace conformal {
#if CAP_SDL #if CAP_SDL
void createImage(bool dospiral) { void createImage(bool dospiral) {
int segid = 1; int segid = 1;
inHighQual = true;
if(includeHistory) restore(); if(includeHistory) restore();
int bandfull = 2*bandhalf; int bandfull = 2*bandhalf;
int len = measureLength(); ld len = measureLength();
time_t timer; time_t timer;
timer = time(NULL); timer = time(NULL);
char timebuf[128]; char timebuf[128];
strftime(timebuf, 128, "%y%m%d-%H%M%S", localtime(&timer)); strftime(timebuf, 128, "%y%m%d-%H%M%S", localtime(&timer));
rotation = 0;
SDL_Surface *sav = s;
SDL_Surface *bbuf = SDL_CreateRGBSurface(SDL_SWSURFACE,bandfull,bandfull,32,0,0,0,0);
s = bbuf;
int ssr = sightrange_bonus; sightrange_bonus = 3; int sch = cheater; cheater = 0;
videopar vid2 = vid; vid.xres = vid.yres = bandfull; vid.scale = 1;
calcparam();
vid.radius = bandhalf;
int xpos = 0;
vector<SDL_Surface*> bands; vector<SDL_Surface*> bands;
SDL_Surface *band = SDL_CreateRGBSurface(SDL_SWSURFACE, min(len, bandsegment), bandfull,32,0,0,0,0); resetbuffer rbuf;
if(1) {
// block for RAII
dynamicval<videopar> dv(vid, vid);
dynamicval<ld> dr(rotation, 0);
dynamicval<bool> di(inHighQual, true);
renderbuffer glbuf(bandfull, bandfull, vid.usingGL);
vid.xres = vid.yres = bandfull;
glbuf.enable(); vid.radius = bandhalf;
stereo::set_viewport(0);
calcparam();
ld xpos = 0;
int seglen = min(int(len), bandsegment);
SDL_Surface *band = SDL_CreateRGBSurface(SDL_SWSURFACE, seglen, bandfull,32,0,0,0,0);
if(!band) { if(!band) {
addMessage("Could not create an image of that size."); addMessage("Could not create an image of that size.");
@ -447,7 +461,14 @@ namespace conformal {
else { else {
int siz = size(v); int siz = size(v);
for(int j=1; j<siz-1; j++) {
int bonus = ceil(extra_line_steps);
cell *last_base = NULL;
hyperpoint last_relative;
for(int j=-bonus; j<siz+bonus; j++) {
/*
SDL_Surface *buffer = s; SDL_Surface *buffer = s;
s = sav; s = sav;
@ -456,37 +477,29 @@ namespace conformal {
char buf[128]; char buf[128];
sprintf(buf, "#%03d", segid); sprintf(buf, "#%03d", segid);
progress(s0 + buf + " ("+its(j)+"/"+its(siz-2)+")"); progress(s0 + buf + " ("+its(j+bonus)+"/"+its(siz+bonus+bonus-1)+")"); */
calcparam();
vid.radius = bandhalf;
s = buffer; // calcparam(); vid.radius = bandhalf;
viewctr.h = v[j]->base->master; phase = j; movetophase();
viewctr.spin = 0;
View = inverse(v[j]->at);
SDL_FillRect(s, NULL, 0); glbuf.clear(backcolor);
bool ugl = vid.usingGL;
vid.usingGL = false;
drawfullmap(); drawfullmap();
vid.usingGL = ugl;
hyperpoint next = if(last_base) {
inverse(v[j]->at) * hyperpoint last = shmup::ggmatrix(last_base) * last_relative;
shmup::calc_relative_matrix(v[j+1]->base, v[j]->base->master) * hyperpoint hscr;
v[j+1]->at * C0; applymodel(last, hscr);
ld bwidth = -vid.radius * hscr[0];
int x, y, shift; printf("bwidth = %lf/%lf\n", bwidth, len);
getcoord0(next, x, y, shift);
int bwidth = x-bandhalf;
popScreen();
drawsegment: drawsegment:
SDL_Surface *gr = glbuf.render();
for(int cy=0; cy<bandfull; cy++) for(int cx=0; cx<bwidth; cx++) for(int cy=0; cy<bandfull; cy++) for(int cx=0; cx<=bwidth+3; cx++)
qpixel(band, xpos+cx, cy) = qpixel(s, bandhalf+cx, cy); qpixel(band, int(xpos+cx), cy) = qpixel(gr, int(bandhalf+cx-bwidth), cy);
if(j == 1-bonus)
xpos = bwidth * (extra_line_steps - bonus);
if(xpos+bwidth > bandsegment) { if(xpos+bwidth > bandsegment) {
char buf[128]; char buf[128];
@ -500,11 +513,16 @@ namespace conformal {
SDL_FreeSurface(band); SDL_FreeSurface(band);
len -= bandsegment; xpos -= bandsegment; len -= bandsegment; xpos -= bandsegment;
band = SDL_CreateRGBSurface(SDL_SWSURFACE, min(len, bandsegment), bandfull,32,0,0,0,0); seglen = min(int(len), bandsegment);
band = SDL_CreateRGBSurface(SDL_SWSURFACE, seglen, bandfull,32,0,0,0,0);
goto drawsegment; goto drawsegment;
} }
xpos += bwidth; xpos += bwidth;
} }
last_base = viewctr.h->c7;
last_relative = inverse(shmup::ggmatrix(last_base)) * C0;
}
} }
char buf[128]; char buf[128];
@ -516,17 +534,17 @@ namespace conformal {
bands.push_back(band); bands.push_back(band);
else else
SDL_FreeSurface(band); SDL_FreeSurface(band);
}
rbuf.reset();
stereo::set_viewport(0);
SDL_FreeSurface(sav);
s = sav; vid = vid2; sightrange_bonus = ssr; cheater = sch;
if(includeHistory) restoreBack(); if(includeHistory) restoreBack();
if(dospiral) { if(dospiral) {
spiral::loop(bands); spiral::loop(bands);
for(int i=0; i<size(bands); i++) SDL_FreeSurface(bands[i]); for(int i=0; i<size(bands); i++) SDL_FreeSurface(bands[i]);
} }
inHighQual = false;
} }
#endif #endif

View File

@ -945,6 +945,7 @@ namespace conformal {
extern ld lvspeed; extern ld lvspeed;
extern int bandsegment; extern int bandsegment;
extern int bandhalf; extern int bandhalf;
extern ld extra_line_steps;
void create(); void create();
void clear(); void clear();