Libove Blog

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

Tag: rust

#

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



#

Geometry generation is now in an okay state. Next improvements are significantly harder and have almost no visual effect. For example merging the "pillar" geometry (green) correctly. At the moment these are just overlapping tubes.

Decided to work on the room layouts instead and started with a classical grid dungeon layout. Corridors still look incorrect and need an edge flip to align the flow of the ceiling correctly.

2D layout of rooms of classical grid dungeon 3D rendering of the classical grid dungeon

#gamedev #rust #geometry


#

Progress on room generation.

  • Implemented 2D editing view.
  • Nodes can be moved and snapped to full coordinates
  • Change height of ceiling and node type.

#rust #geometry #gamedev


#

Added walls to the room and removed the pillars in the room itself. These can still be placed in the data structure but my random generator isn't using them at the moment. The geometry is now mostly done for my purposes. The next step will be tooling to create and edit rooms manually.

#gamedev #rust #geometry


#

Cleaned up everything a bit and added a floor. All still in debug colors. Next will be to create proper UV coordinates to enable texturing.

#rust #wgpu

Debug rendering of a room with arched ceiling.



#

Combined the Delaunay triangulation with the Bezier curves to create the "walls" of a room. Next step will be figuring out how to create surfaces between curves.

#geometry #rust

Screenshot of a 3D mesh with bezier curves sticking out