return -1;
}
vox_framebuf(vox, FB_W, FB_H, fb);
- vox_proj(vox, 45, 1, 200);
- vox_view(vox, pos[0], pos[1], angle);
+ vox_proj(vox, 45, 1, 300);
glfb_setup(FB_W, FB_H, GLFB_RGBA32, FB_W * 4);
return 0;
pos[1] -= right[1];
}
- vox_view(vox, pos[0], pos[1], angle);
+ vox_view(vox, pos[0], pos[1], -30, angle);
}
void display(void)
vox->xshift++;
}
- vox->vheight = 50;
+ vox->vheight = 80;
vox->proj_dist = 4; /* TODO */
return vox;
free(vox);
}
+int vox_height(struct voxscape *vox, int32_t x, int32_t y)
+{
+ int tx = (x >> 16) & vox->xmask;
+ int ty = (y >> 16) & vox->ymask;
+
+ return vox->height[(ty << vox->xshift) + tx];
+}
+
void vox_framebuf(struct voxscape *vox, int xres, int yres, uint32_t *fb)
{
if(xres != vox->fbwidth) {
vox->fbheight = yres;
}
-void vox_view(struct voxscape *vox, int32_t x, int32_t y, int32_t angle)
+void vox_view(struct voxscape *vox, int32_t x, int32_t y, int h, int32_t angle)
{
+ if(h < 0) {
+ h = vox_height(vox, x, y) - h;
+ }
+
vox->x = x;
vox->y = y;
+ vox->vheight = h;
vox->angle = angle;
- /* TODO precalc stuff */
vox->valid &= ~SLICELEN;
}
tx = (x >> 16) & vox->xmask;
ty = (y >> 16) & vox->ymask;
- hval = vox->height[(ty << vox->xshift) + tx] - 80;
+ hval = vox->height[(ty << vox->xshift) + tx] - vox->vheight;
hval = hval * 160 / (vox->znear + n) + 250;
if(hval > vox->fbheight) hval = vox->fbheight;
if(hval > vox->coltop[i]) {
struct voxscape *vox_open(const char *hfile, const char *cfile);
void vox_free(struct voxscape *vox);
+int vox_height(struct voxscape *vox, int32_t x, int32_t y);
+
void vox_framebuf(struct voxscape *vox, int xres, int yres, uint32_t *fb);
-void vox_view(struct voxscape *vox, int32_t x, int32_t y, int32_t angle);
+/* negative height for auto at -h above terrain */
+void vox_view(struct voxscape *vox, int32_t x, int32_t y, int h, int32_t angle);
void vox_proj(struct voxscape *vox, int fov, int znear, int zfar);
void vox_render(struct voxscape *vox);