From: Randy McShandy Date: Fri, 6 Jun 2025 03:21:48 +0000 (-0500) Subject: Finally figured out room placement X-Git-Url: http://git.mcshandy.xyz/gitweb.cgi?a=commitdiff_plain;h=e0d16e63696bbe1bb0a7fff68c9489ffb07ae61f;p=barrow_crawler Finally figured out room placement --- diff --git a/src/render_raylib.c b/src/render_raylib.c index ff2df95..774b7e5 100644 --- a/src/render_raylib.c +++ b/src/render_raylib.c @@ -117,7 +117,8 @@ float orb_intensity = 1.0f; /* TODO: normalized distance from center, but lighti Vector3 orb_directionality = {1.0f, 1.0f, 1.0f}; int map_visible = 0; -int draw_collision_mesh = 1; +int barrow_visible = 1; +int draw_collision_mesh = 0; typedef void(*renderfunc)(); typedef void(*controlfunc)(); @@ -153,30 +154,32 @@ void drawing_game_mode() BeginMode3D(cam); BeginShaderMode(shader); - DrawModelEx(floor_model, floor_position, floor_rotation_axis, floor_rotation, floor_extent, DARKGRAY); - DrawModelEx(barrow_model, barrow_position, barrow_rotation_axis, barrow_rotation, barrow_extent, DARKGRAY); + if (barrow_visible) + { + DrawModelEx(floor_model, floor_position, floor_rotation_axis, floor_rotation, floor_extent, DARKGRAY); + DrawModelEx(barrow_model, barrow_position, barrow_rotation_axis, barrow_rotation, barrow_extent, DARKGRAY); + } + if (draw_collision_mesh) { - //DrawMesh(barrow_model.meshes[0], barrow_model.materials[0], barrow_mat); + DrawMesh(barrow_model.meshes[0], barrow_model.materials[0], barrow_mat); } + EndShaderMode(); + for (int n = 0; n < room_count; n++) { Vector3 each = room_positions[n]; - DrawSphere(each, 1.0, RED); + DrawSphere(each, 0.1, RED); } + + map_center.y = 1.2f; DrawSphere(map_center, 1.0, SKYBLUE); DrawSphere(barrow_position, 1.0, GREEN); DrawSphere(floor_position, 1.0, PURPLE); - //for (int n = 0; n < spawn_spoke_count; n++) - //{ - // Ray* each = &spawn_spoke_rays[n]; - // DrawRay(*each, RED); - //} //DrawRay(player_collide_ray, RED); - EndShaderMode(); EndMode3D(); orb_normal_color = ColorNormalize(orb_color); @@ -290,6 +293,11 @@ void control_game_mode() cam.target.y -= DEG2RAD * 20.0; } + if (IsKeyReleased(KEY_B)) + { + barrow_visible = !barrow_visible; + } + if (IsKeyReleased(KEY_M)) { map_visible = !map_visible; @@ -322,7 +330,7 @@ void control_game_mode() player_collision = GetRayCollisionMesh(player_collide_ray, barrow_model.meshes[0U], barrow_mat); player_rotation = new_player_rotation; - if (player_collision.hit && player_collision.distance < 1.30f) + if (false && player_collision.hit && player_collision.distance < 1.30f) { player_velocity.x *= -1.05; } @@ -438,34 +446,19 @@ void wait_initialize_resources() hand_rotation = 0.0f; } - printf("center room %f %f %f\n", V3_UNROLL(room_positions[0])); + Vector3 axis = map_center; + float angle = DEG2RAD*0.0f; for (int n = 0; n < room_count; n++) { // Scale room positions down from gentime positions - printf("room at %f %f %f\n", V3_UNROLL(room_positions[n])); - //room_positions[n].x -= barrow_image.width/2.0f; - room_positions[n].x -= 1.0f; - //room_positions[n].z -= barrow_image.height; - //room_positions[n] = Vector3Multiply(room_positions[n], barrow_scale_factor); - //room_positions[n] = Vector3Add(room_positions[n], barrow_size); - //room_positions[n] = Vector3Add(room_positions[n], map_center); + printf("room %d at %f %f %f\n", n, V3_UNROLL(room_positions[n])); + room_positions[n].x /= 4; + room_positions[n].z /= 4; + room_positions[n].y += 0.6f; + room_positions[n] = Vector3RotateByAxisAngle(room_positions[n], axis, angle); printf("room moved to %f %f %f\n", V3_UNROLL(room_positions[n])); } - /* Setup Rays for visualizing spawn contact points */ - spawn_spoke_count = room_count; - spawn_spoke_rays = malloc(sizeof(Ray) * spawn_spoke_count); - for (int n = 0; n < spawn_spoke_count; n++) - { - Ray* each = &spawn_spoke_rays[n]; - each->position = room_positions[n+1]; - each->position = Vector3Add(each->position, floor_position); - each->direction = Vector3Subtract(each->position, cam.position); - printf("Initialized a ray at {%f %f %f} to {%f %f %f}\n", - V3_UNROLL(each->position), V3_UNROLL(each->direction)); - printf("\tfrom room position {%f %f %f}\n", V3_UNROLL(room_positions[n+1])); - } - /* Grab the full transformation matrix of the upper barrow for use in collision */ /* Apparently matrix work needs to be normalized. */ { @@ -498,9 +491,6 @@ void initialize_renderer() cam.fovy = 90.0f; cam.projection = CAMERA_PERSPECTIVE; - /* eye in the sky */ - //cam.position.y += 64; - /* I know these are good at 60 fps. Per-second speed to move to FPS/independent movement. */ diff --git a/src/shaders/lighting.fs b/src/shaders/lighting.fs index 4d0f163..41357dc 100644 --- a/src/shaders/lighting.fs +++ b/src/shaders/lighting.fs @@ -139,9 +139,9 @@ void main() lumWeights = vec4(1.0f) * lumWeight; lumWeights *= dot(finalColor, lumWeights); - lighting_color = vec4(mix(orb_color.rgb * candle_weight, lumWeights.rgb, 0.2f), 1.0f); + //lighting_color = vec4(mix(orb_color.rgb * candle_weight, lumWeights.rgb, 0.2f), 1.0f); //lighting_color = vec4(mix(candle_color.rgb * candle_weight, lumWeights.rgb, 0.4f), 1.0f); - finalColor = finalColor * lighting_color; + //finalColor = finalColor * lighting_color; float factor = 35.0; finalColor.r = round((finalColor.r) * factor) / factor; @@ -151,4 +151,6 @@ void main() // All single color channel variations with this looks cool as FUCK // turns this into three levels going b-r-g //finalColor.b = 0.0f; + + finalColor.a = 0.5f; } diff --git a/src/structs.c b/src/structs.c index ea7a137..fabdb83 100644 --- a/src/structs.c +++ b/src/structs.c @@ -81,9 +81,6 @@ const IVec2 img_export_scale = {.x = 2, .y = 2}; float resource_generation_progress = 0.0f; int resource_state = 0; -const int room_count = 7; +const int room_count = 4; Vector3* room_positions = NULL; -int spawn_spoke_count; -Ray* spawn_spoke_rays; - diff --git a/src/structs.h b/src/structs.h index 0bc2604..6e87c1d 100644 --- a/src/structs.h +++ b/src/structs.h @@ -97,9 +97,6 @@ extern int resource_state; extern const int room_count; extern Vector3* room_positions; -extern int spawn_spoke_count; -extern Ray* spawn_spoke_rays; - //int generate_rd(int worker_count, RD_Opts active_opt, FVec2 **grid_buffer, IVec2 pgrid_size); void* generate_rd(void* args); #endif //__RD_STRUCTS__ diff --git a/src/utils.c b/src/utils.c index 5c33a69..49ce354 100644 --- a/src/utils.c +++ b/src/utils.c @@ -16,11 +16,14 @@ #include "external/stb_image_write.h" #include "external/stb_image_resize2.h" -#define SHADOW 1 +#define SHADOW 0 #if SHADOW #define printf(a,...) #endif +#define V3_UNROLL(v3) v3.x, v3.y, v3.z +#define V3_FORMAT(v3) #v3 ":{%.4f %.4f %.4f}" + FVec2 ** grid; FVec2 ** grid_prime; FVec2 ** grid_temp; @@ -134,22 +137,24 @@ int initialize(int worker_count, RD_Opts active_opt) /* Set up seed-points to create connected rooms */ const int seed_count = room_count; - const float small_room_radius = 10.0f; + const float small_room_radius = 8.0f; const float phase = ((rand() % 360)/(float)360) * (M_PI*2); for (int n = 0; n < seed_count; n++) { /* Generate n seeds at even radial points, random phase offset */ float angle = ((float)n/(float)seed_count) * (M_PI * 2); - float dist_offset = ((rand() % 14)+1); + float dist_offset = ((rand() % 14) + 1); angle += phase; int seed_x = ((cosf(angle) * (dist_offset + (grid_size.x/4.0f))) + (grid_size.x/2.0f)); int seed_y = ((sinf(angle) * (dist_offset + (grid_size.y/4.0f))) + (grid_size.y/2.0f)); - // TODO: One of these will probably have to be mirrored. - room_positions[n] = (Vector3){.x = seed_x, .y = 0.0f, .z = seed_y}; - printf("Set room %d to {%f %f %f}\n", n, VEC3_UNROLL(room_positions[n])); + // Swap dimensions prepping for rendering + room_positions[n] = (Vector3){.x = seed_y, .y = 0.0f, .z = seed_x}; + // mirror this across axis + room_positions[n].z = grid_size.y - room_positions[n].z; + printf("Set room %d to {%f %f %f}\n", n, V3_UNROLL(room_positions[n])); grid[seed_x][seed_y].b = 1.0f; grid[seed_x][seed_y].c = 0.0f; @@ -160,17 +165,21 @@ int initialize(int worker_count, RD_Opts active_opt) const float y_end = (seed_y+((small_room_radius))); const float distance_seed_to_center = sqrtf(pow(seed_x - center_x, 2) + pow(seed_y - center_y, 2)); - for (int x = x_start; x < x_end; x++) - { - for (int y = y_start; y < y_end; y++) - { - const float distance_from_center = sqrtf(((x-center_x)*(x-center_x))+((y-center_y)*(y-center_y))); - if (distance_from_center >= distance_seed_to_center) - { - grid[x][y].c = 1.0f; - } - } - } + const int generate_room = true; + if (generate_room) + { + for (int x = x_start; x < x_end; x++) + { + for (int y = y_start; y < y_end; y++) + { + const float distance_from_center = sqrtf(((x-center_x)*(x-center_x))+((y-center_y)*(y-center_y))); + if (distance_from_center >= distance_seed_to_center) + { + grid[x][y].c = 1.0f; + } + } + } + } } return 0; @@ -188,7 +197,7 @@ void* generate_rd(void* args) while(!should_quit) {} - printf("Opts: {\nIterations: %d\nTime delta: %f\nDiffA: %f\nDiffB: %f\nFeed: %f\nKill: %f\n\n}\n", active_opt.max_iterations, active_opt.delta_t, active_opt.diff_a, active_opt.diff_b, active_opt.feed, active_opt.kill); + //printf("Opts: {\nIterations: %d\nTime delta: %f\nDiffA: %f\nDiffB: %f\nFeed: %f\nKill: %f\n\n}\n", active_opt.max_iterations, active_opt.delta_t, active_opt.diff_a, active_opt.diff_b, active_opt.feed, active_opt.kill); /* png for the heightmap */ unsigned char barrow_mesh_buffer[grid_size.x][grid_size.y];