diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | asset.h | 10 | ||||
-rw-r--r-- | intermediate/floorboards.bmp | bin | 0 -> 16522 bytes | |||
-rw-r--r-- | intermediate/floorboardsbot.bmp | bin | 0 -> 16522 bytes | |||
-rw-r--r-- | render.c | 43 |
5 files changed, 46 insertions, 9 deletions
@@ -33,6 +33,8 @@ mesh_sources = \ texture_sources = \ $(int_dir)/gun.bmp \ + $(int_dir)/floorboards.bmp \ + $(int_dir)/floorboardsbot.bmp \ $(int_dir)/brick.bmp meshes = $(mesh_sources:$(int_dir)/%.obj=$(data_dir)/%.msh) @@ -31,6 +31,16 @@ struct Mesh; asset_type_texture, \ "brick.bc1" \ ) \ + x( \ + asset_id_floorboards_texture, \ + asset_type_texture, \ + "floorboards.bc1" \ + ) \ + x( \ + asset_id_floorboardsbot_texture, \ + asset_type_texture, \ + "floorboardsbot.bc1" \ + ) \ typedef enum { #define x(id, type, path) id, diff --git a/intermediate/floorboards.bmp b/intermediate/floorboards.bmp Binary files differnew file mode 100644 index 0000000..2c586ab --- /dev/null +++ b/intermediate/floorboards.bmp diff --git a/intermediate/floorboardsbot.bmp b/intermediate/floorboardsbot.bmp Binary files differnew file mode 100644 index 0000000..53fedb4 --- /dev/null +++ b/intermediate/floorboardsbot.bmp @@ -724,13 +724,40 @@ void ren_map( const int* dir, const int* left ) { - int x, w, h, hh; + int x, y, w, h, hh, hhi, hci, ey; const int* data = (const int*)&map[1]; /* temp */ const Texture* texture = get_texture(asset_id_brick_texture); + const Texture* ceiling = get_texture(asset_id_floorboardsbot_texture); + const Texture* floort = get_texture(asset_id_floorboards_texture); w = r->vp[0] << fbits; h = r->vp[1] << fbits; hh = (h / 4) * r->asp; + hhi = r->vp[1] / 2; + ey = mini(hhi, r->clip[3]); + for (y = r->clip[1]; y < ey; y++) { + int rl[2], rr[2], floor[4]; + int dist = (hh) / ((y - hhi) << fbits); + rl[0] = dir[0] + left[0]; + rl[1] = dir[1] + left[1]; + rr[0] = dir[0] - left[0]; + rr[1] = dir[1] - left[1]; + floor[0] = pos[0] - ((dist * rl[0]) >> fbits); + floor[1] = pos[1] - ((dist * rl[1]) >> fbits); + floor[2] = pos[0] - ((dist * rr[0]) >> fbits); + floor[3] = pos[1] - ((dist * rr[1]) >> fbits); + for (x = r->clip[0]; x < r->clip[2]; x++) { + int t = ((2 * x) << (fbits * 2)) / w - f1; + int coordc = x + y * r->vp[0]; + int coordf = x + ((hhi - y) + hhi) * r->vp[0]; + int ifloor[2]; + t = (t + f1) / 2; + ifloor[0] = floor[0] + ((t * (floor[2] - floor[0])) >> fbits); + ifloor[1] = floor[1] + ((t * (floor[3] - floor[1])) >> fbits); + r->t[coordc] = sample_tex(ceiling, ifloor[0], ifloor[1]); + r->t[coordf] = sample_tex(floort, ifloor[0], ifloor[1]); + } + } for (x = r->clip[0]; x < r->clip[2]; x++) { int ray = ((2 * x) << (fbits * 2)) / w - f1; int d[2]; @@ -740,8 +767,8 @@ void ren_map( d[1] = dir[1] - ((left[1] * ray) >> fbits); mp[0] = pos[0] >> fbits; mp[1] = pos[1] >> fbits; - delta[0] = !d[0]? f1*30: abs((f1 << fbits) / d[0]); - delta[1] = !d[1]? f1*30: abs((f1 << fbits) / d[1]); + delta[0] = abs((f1 << fbits) / (d[0] + !d[0])); + delta[1] = abs((f1 << fbits) / (d[1] + !d[1])); if (d[0] < 0) { step[0] = -1; dside[0] = ((pos[0] - (mp[0] << fbits)) * delta[0]) >> fbits; @@ -781,12 +808,10 @@ void ren_map( ey = mini(ey, r->clip[3]); for (y = sy; y < ey; y++) { int coord = x + y * r->vp[0]; - if (dist < r->d[coord]) { - int v = ((y - sy) << fbits) / (ey - sy); - Colour c = sample_tex(texture, u, v); - r->d[coord] = dist; - r->t[coord] = c; - } + int v = ((y - sy) << fbits) / (ey - sy); + Colour c = sample_tex(texture, u, v); + r->d[coord] = dist; + r->t[coord] = c; } break; } |