mca-cuboids

Crates.iomca-cuboids
lib.rsmca-cuboids
version0.2.0
sourcesrc
created_at2022-08-01 08:22:57.948453
updated_at2022-08-05 06:04:51.522364
descriptionmerge blocks from mca files
homepage
repositoryhttps://github.com/EazyDizzy/mca-cuboids
max_upload_size
id636619
size29,826
e33 (Vitaliy-Svinchyak)

documentation

README

mca-cuboids

crates.io

A simple tool to merge blocks from your minecraft world to as less amount of cuboids as possible.

Example usage

use mca_cuboids::{BlockCoordinates, ExportParams};

let collisions = mca_cuboids::export_cuboids(
                        "dbg_lvl/region",
                        ExportParams {
                            start: BlockCoordinates::new(0, -64, 0),
                            end: BlockCoordinates::new(64, 0, 64),
                            ..Default::default()
                        },
                    ).expect("Failed to build collisions")
                    
for shape in collisions {
        let x_width = shape.end.x as f32 - shape.start.x as f32 + 1.0;
        let z_width = shape.end.z as f32 - shape.start.z as f32 + 1.0;
        let y_height = shape.end.y as f32 - shape.start.y as f32 + 1.0;

        commands
            .spawn_bundle((
                Transform::from_xyz(
                    shape.end.x as f32 - x_width / 2.0 + 0.5,
                    shape.end.y as f32 - y_height / 2.0 + 0.5,
                    shape.end.z as f32 - z_width / 2.0 + 0.5,
                ),
                GlobalTransform::identity(),
            ))
            .insert(RigidBody::Static)
            .insert(CollisionShape::Cuboid {
                half_extends: Vec3::new(x_width / 2.0, y_height / 2.0, z_width / 2.0),
                border_radius: None,
            });
    }

Original img_1.png Result rendered with bevy + heron(CollisionShape::Cuboid + debug-3d feature) img.png

Commit count: 30

cargo fmt