From a009fd37491b468fdbc91760f927e5e267434ea7 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Thu, 19 Sep 2024 05:33:21 -0400 Subject: [PATCH] Face down --- terrain.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/terrain.c b/terrain.c index 51dcc81..dfed8e9 100644 --- a/terrain.c +++ b/terrain.c @@ -8,6 +8,7 @@ #include "unigi/main.h" // #include "keys.h" +// #define ECS_MAXENTITIES 30000 #include "terrain_ecstypes.h" #include @@ -29,21 +30,22 @@ #define CHUNKSCALE 1.0 / CHUNKSIZE #define VIEWDISTANCE 10 #define PLBOXEDGE (VIEWDISTANCE * 2 + 1) -#define MAXCHUNKPERFRAME 100 +#define MAXCHUNKPERFRAME 1 // These are initial values but there may be ways to change it -#define CAM_INITPITCH MPI_2 +#define INIT_CAMPITCH MPI_2 * 1.6 // 1.575 #define INIT_NEARCLIP 0.01 #define INIT_FARCLIP 100.0 #define INIT_FOV 90.0 -#define INIT_DITHERSTART 10000 -#define INIT_DITHEREND 10000 +#define INIT_DITHERSTART 100 +#define INIT_DITHEREND 100 #define INIT_LIGHTPITCH -MPI / 4.0 #define INIT_LIGHTYAW 0 #define INIT_MINLIGHT 0.2 +#define INIT_PLAYERHEIGHT 1.5 #define INIT_PLAYERSPEED \ - { .x = 0, .y = 0, .z = -0.5 } + { .x = 0, .y = 0, .z = -1.5 } // Some globals you can mess around with potentially int fps = 60; @@ -73,9 +75,9 @@ void gen_terrain(struct vec3i pos, haloo3d_obj *model) { // clang-format off // REMEMBER: NEGATIVE Z IS FORWARD int tl = haloo3d_obj_addvertex(model, (struct vec4){.x = 0, .y = 0, .z = 0, .w = 1}); - int tr = haloo3d_obj_addvertex(model, (struct vec4){.x = CHUNKSIZE / 2.0, .y = 0, .z = 0, .w = 1}); - int bl = haloo3d_obj_addvertex(model, (struct vec4){.x = 0, .y = 0, .z = CHUNKSIZE / 2.0, .w = 1}); - int br = haloo3d_obj_addvertex(model, (struct vec4){.x = CHUNKSIZE / 2.0, .y = 0, .z = CHUNKSIZE / 2.0, .w = 1}); + int tr = haloo3d_obj_addvertex(model, (struct vec4){.x = CHUNKSIZE / 1.1, .y = 0, .z = 0, .w = 1}); + int bl = haloo3d_obj_addvertex(model, (struct vec4){.x = 0, .y = 0, .z = CHUNKSIZE / 1.1, .w = 1}); + int br = haloo3d_obj_addvertex(model, (struct vec4){.x = CHUNKSIZE / 1.1, .y = 0, .z = CHUNKSIZE / 1.1, .w = 1}); // clang-format on haloo3d_facei face; fastface(face, seauv, bl, br, tl); @@ -212,6 +214,7 @@ void sys_movement(ecs_placement *p, ecs_movement *m, tecs **ecs) { vec3_add(p->up.v, p->up.v, temp); vec3_multiply_f(temp, m->pos.v, (*ecs)->delta_s); vec3_add(p->pos.v, p->pos.v, temp); + // vec3_multiply(p->pos.v, p->pos.v, p->pos.v); } // Perform the entire rendering of an object @@ -374,10 +377,10 @@ void sys_placement_lock(ecs_placement_lock *lock, ecs_placement *pl) { ecs_eid setup_player(tecs *ecs, render_context *context) { ecs_eid playerid = tecs_newentity(ecs, 0); ECS_SETCOMPONENT(ecs, playerid, ecs_placement){ - .pos = {.x = 0, .y = 1, .z = 0}, .up = DEFAULTUP}; + .pos = {.x = 0, .y = INIT_PLAYERHEIGHT, .z = 0}, .up = DEFAULTUP}; ECS_SETCOMPONENT(ecs, playerid, ecs_movement){.pos = INIT_PLAYERSPEED}; ECS_SETCOMPONENT(ecs, playerid, ecs_rotation){.yaw = 0, - .pitch = CAM_INITPITCH}; + .pitch = INIT_CAMPITCH}; ECS_SETCOMPONENT(ecs, playerid, ecs_rendercontext) context; ECS_SETCOMPONENT(ecs, playerid, ecs_input){}; return playerid; @@ -410,7 +413,9 @@ ecs_eid setup_sea(tecs *ecs, render_context *ctx, ecs_placement *playerpos, haloo3d_obj_addface(model, face); ECS_SETCOMPONENT(ecs, seaid, ecs_object){ .texture = haloo3d_easystore_gettex(&ecs->storage, PALETTEKEY), - .scale = {.x = VIEWDISTANCE, .y = VIEWDISTANCE, .z = VIEWDISTANCE}, + .scale = {.x = VIEWDISTANCE * 1.5, + .y = VIEWDISTANCE * 1.5, + .z = VIEWDISTANCE * 1.5}, .lighting = NULL, .model = model, .cullbackface = 1, @@ -455,6 +460,9 @@ int main() { // int argc, char **argv) { context.nearclip = INIT_NEARCLIP; context.farclip = INIT_FARCLIP; context.fov = INIT_FOV; + haloo3d_trirender_init(&context.rendersettings); + context.rendersettings.ditherclose = INIT_DITHERSTART; + context.rendersettings.ditherfar = INIT_DITHEREND; haloo3d_fb_init(&context.window, WIDTH, HEIGHT); eprintf("Initialized screen buffers, context, and timers\n"); @@ -491,9 +499,9 @@ int main() { // int argc, char **argv) { if (ecs.delta_s) { ECS_RUNSYSTEM1(&ecs, sys_playerinput, ecs_input); ECS_RUNSYSTEM2(&ecs, sys_rotation, ecs_placement, ecs_rotation); + ECS_RUNSYSTEM3(&ecs, sys_movement, ecs_placement, ecs_movement, tecs); ECS_RUNSYSTEM2(&ecs, sys_placement_lock, ecs_placement_lock, ecs_placement); - ECS_RUNSYSTEM3(&ecs, sys_movement, ecs_placement, ecs_movement, tecs); ECS_RUNSYSTEM3(&ecs, sys_rendercontext, ecs_rendercontext, ecs_placement, tecs); ECS_RUNSYSTEM3(&ecs, sys_playergarbage, ecs_playergarbage, ecs_object,