From 1f3b6a973dd42bb031ed3a5239193bc1b05a5484 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Fri, 20 Sep 2024 03:05:45 -0400 Subject: [PATCH] Lots of trees (ugly) --- haloo3d | 2 +- terrain.c | 34 ++++++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/haloo3d b/haloo3d index d5cd80d..a30aea9 160000 --- a/haloo3d +++ b/haloo3d @@ -1 +1 @@ -Subproject commit d5cd80d67cacec466968aa846883e2dd10db3a38 +Subproject commit a30aea9dac005602b64d9591f906407bccbd88e2 diff --git a/terrain.c b/terrain.c index 195c3bf..c2e348a 100644 --- a/terrain.c +++ b/terrain.c @@ -125,8 +125,9 @@ void gen_terrain(struct vec3i pos, haloo3d_obj *model, eprintf("Generating terrain at %d,%d\n", pos.x, pos.z); haloo3d_obj *tree = haloo3d_easystore_getobj(storage, TREEKEY); // Don't allow the model to have more than some amount of faces/vertices. - haloo3d_obj_resetfixed(model, CHUNKVSIZE * CHUNKVSIZE * 4, - CHUNKVSIZE * CHUNKVSIZE * 4); + haloo3d_obj_resetfixed(model, CHUNKVSIZE * CHUNKVSIZE * 16, + CHUNKVSIZE * CHUNKVSIZE * 16); + // if (rand() & 3) return; struct vec3 landcol = haloo3d_gen_paletteuv(LANDCOL); // 0xF2C0); int landuv = haloo3d_obj_addvtexture(model, landcol); fnl_state ns = fnlCreateState(); @@ -158,13 +159,30 @@ void gen_terrain(struct vec3i pos, haloo3d_obj *model, haloo3d_obj_addface(model, face); fastface(face, landuv, br, tr, tl); haloo3d_obj_addface(model, face); + struct vec4 corn = model->vertices[bl]; + if (corn.y > 0.1) { + float scale = 0.1 + RANDF() * 0.05; + float height = 0.5 + RANDF() * 0.5; + // for (int b = 1; b <= 4; b++) { + haloo3d_obj_addobj( + model, tree, + (struct vec3){.x = corn.x, .y = corn.y + scale * height, .z = corn.z}, + (struct vec3)DEFAULTLOOK, (struct vec3)DEFAULTUP, + (struct vec3){.x = scale, .y = scale * height, .z = scale}); + //} + // haloo3d_obj_addobj( + // model, tree, + // (struct vec3){ + // .x = corn.x, .y = corn.y + scale * height * 2, .z = corn.z}, + // (struct vec3)DEFAULTLOOK, (struct vec3)DEFAULTUP, + // (struct vec3){.x = scale, .y = scale * height, .z = scale}); + } } - haloo3d_obj_addobj(model, tree, - (struct vec3){.x = CHUNKSIZE / 2.0, - .y = LANDHEIGHT, - .z = CHUNKSIZE / 2.0}, - (struct vec3)DEFAULTLOOK, (struct vec3)DEFAULTUP, - (struct vec3){.x = 1.0, .y = 1.0, .z = 1.0}); + // haloo3d_obj_addobj( + // model, tree, + // (struct vec3){.x = CHUNKSIZE / 2.0, .y = 1.0, .z = -CHUNKSIZE / 2.0}, + // (struct vec3)DEFAULTLOOK, (struct vec3)DEFAULTUP, + // (struct vec3){.x = 1.0, .y = 1.0, .z = 1.0}); haloo3d_obj_shrinktofit(model); }