Libove Blog

Personal Blog about anything - mostly programming, cooking and random thoughts

#

#gamedev progress:

  • Procedural book shelves are now used within the level, replacing the fixed model.
  • Started implementation of a world state object as "array of fat structs"
  • Implemented an algorithm to find free space within a shelf for a new book.

Screenshot showing shelves filled with books in a 3D "game"

#rust


#

#gamedev progress:

Implemented a procedural version of the book shelves. The geometry is created by simple inset and extrusion operations on quads.

GIF showing change of of number of boards in a book shelf

#rust #geometry


#

#gamedev progress:

I've spent the last couple of evenings implementing a #GLTF 2.0 parser to support animations. Today I've achieved the first step towards that goal and can now load meshes from .glb files.

#rust #geometry #dev

Obligatory screenshot showing a Suzanne model inside my game


#

#gamedev progress:

I've implemented a new algorithm to create level layouts. The previous approach added on chamber after the other only connecting it at one suitable location. This lead to "tree like" layout.

The new approach creates a Delaunay triangulation where each chambers center is a vertex. Then it discards edges as long as the graph stays connected. The remaining edge are used to as corridors.

Screenshot showing the corridor plan graph Screenshot showing the resulting level layout


#

small step forward: added shelves to rooms.

screenshot of a 3d scene with shelves standing on a wall

#gamedev #rust


#

Worked a bit on my project which currently acts as a dungeon/level generator. Added the ability to use multiple textures for different parts of the room.

Screenshot of a 3D scene with different textures for floor, walls and ceilings

#gamedev #rust #wgpu


#

I made a small improvement to the corridor curve sampling to create an equidistant sampling.

        let t_samples = 100;

        // determine length of path
        let path_len = {
            let mut l = 0.0;
            let mut prev_point = control_a;
            for t in 1..=t_samples {
                let t = t as f32 / t_samples as f32;
                let point = corridor.sample(t);
                l += point.pos.dist(&prev_point);
                prev_point = point.pos;
            }
            l
        };
        // determine spacing based on a desired spacing
        // E.g. if we want 1.0 spacing but the curve is 1.1 long,
        // a naive approach would result in a 0.1 segment at the end.
        // Instead we want a 1.1 segement or a 0.55 segment
        let desired_spacing = 1.0;
        let spacing = {
            let needed_steps = path_len / desired_spacing;
            let low = needed_steps.floor().max(1.0);
            let high = needed_steps.ceil();
            let low_step = path_len / low;
            let high_step = path_len / high;

            if (low_step - desired_spacing).abs() <= (high_step - desired_spacing).abs() {
                low_step
            } else {
                high_step
            }
        };

        let mut dist = 0.0;
        let mut prev_dist_point = control_a;
        for t in 1..t_samples {
            let t = t as f32 / t_samples as f32;
            let point = corridor.sample(t);
            dist += point.pos.dist(&prev_dist_point);
            prev_dist_point = point.pos;

            if dist >= spacing {
                 // create sample point
            }
        }

Screenshot showing 2D mesh of a room/dungeon design

#gamedev #rust #geometry


#

I've added the possibility that new rooms can also be connected to existing corridors.

Additionally added round rooms to the generation. They use my previously implemented Delauney triangulation. I guess there are better ways to generate them but these are just placeholders for the moment.

screenshot showing the 2D layout of connected rooms.

#gamedev


#

After some time doing Advent of Code I've returned to my "game" project. The grid based approach to create maps was too restrictive and didn't take full advantage of the free geometry generation.

I've reworked this to allow arbitrarily shaped rooms in the future. Rooms are added to the layout one by one. Each new room is connected to the existing ones with a corridor defined by a cubic Bézier curve. Each "wall edge" of a room is treated a potential exit.

Next steps will be refining the corridor generation. At the moment I connect the two closest edge of new and existing rooms with control points placed at a fixed distance along the walls normals. This leads to misshaped corridors if the room are too close or at a bad angle.

2D room layout with 3 rooms connected by curved corridors

#gamedev #3d #geometry