X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fvoxscape.c;fp=src%2Fvoxscape.c;h=0ea8f0691c1a57c2a13c32396f0fc79e069d60d3;hb=365156a5f69ea9a4dd54a2a86e5dbc20d05621d7;hp=28a02bf44674cb6a6a25da8b89154d5e0342ef09;hpb=2c28fb640747244df7009a86df557d22a07ad5b1;p=voxscape diff --git a/src/voxscape.c b/src/voxscape.c index 28a02bf..0ea8f06 100644 --- a/src/voxscape.c +++ b/src/voxscape.c @@ -6,6 +6,7 @@ #include #include #include "voxscape.h" +#include "lut.h" enum { SLICELEN = 1 @@ -179,17 +180,12 @@ void vox_begin(struct voxscape *vox) { int i; - /* - for(i=0; ifbwidth; i++) { - vox->coltop[i] = vox->fbheight; - } - */ memset(vox->coltop, 0, vox->fbwidth * sizeof *vox->coltop); if(!(vox->valid & SLICELEN)) { float theta = (float)vox->fov * M_PI / 360.0f; /* half angle */ for(i=0; inslices; i++) { - vox->slicelen[i] = (int32_t)((vox->znear + i) * tan(theta) * 10.0f * 65536.0f); + vox->slicelen[i] = (int32_t)((vox->znear + i) * tan(theta) * 4.0f * 65536.0f); } vox->valid |= SLICELEN; } @@ -197,22 +193,25 @@ void vox_begin(struct voxscape *vox) void vox_render_slice(struct voxscape *vox, int n) { - int i, j, tx, ty, hval, colstart, colheight; - int32_t x, y, len, xstep; + int i, j, tx, ty, hval, colstart, colheight, z; + int32_t x, y, len, xstep, ystep; uint32_t color; uint32_t *fbptr; - len = vox->slicelen[n]; - xstep = len / vox->fbwidth; + z = vox->znear + n; + + len = vox->slicelen[n] >> 8; + xstep = ((COS(vox->angle) >> 8) * len) / vox->fbwidth; + ystep = ((SIN(vox->angle) >> 8) * len) / vox->fbwidth; - x = vox->x - xstep * (vox->fbwidth >> 1); - y = vox->y + ((vox->znear + n) << 16); + x = vox->x - SIN(vox->angle) * z - xstep * (vox->fbwidth >> 1); + y = vox->y + COS(vox->angle) * z - ystep * (vox->fbwidth >> 1); for(i=0; ifbwidth; i++) { tx = (x >> 16) & vox->xmask; ty = (y >> 16) & vox->ymask; hval = vox->height[(ty << vox->xshift) + tx] - 80; - hval = hval * 80 / (vox->znear + n) + 250; + hval = hval * 160 / (vox->znear + n) + 250; if(hval > vox->fbheight) hval = vox->fbheight; if(hval > vox->coltop[i]) { color = vox->color[(ty << vox->xshift) + tx]; @@ -228,6 +227,7 @@ void vox_render_slice(struct voxscape *vox, int n) } x += xstep; + y += ystep; } }