#include <assert.h>
#include <imago2.h>
#include "voxscape.h"
+#include "lut.h"
enum {
SLICELEN = 1
{
int i;
- /*
- for(i=0; i<vox->fbwidth; 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; i<vox->nslices; 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;
}
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; i<vox->fbwidth; 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];
}
x += xstep;
+ y += ystep;
}
}