#bevy #2d-3d #tile #mesh #region #level #building

bevy_clay_tiles

A procedural-mesh building system for bevy

16 releases

new 0.15.1 Dec 9, 2024
0.15.0 Nov 30, 2024
0.14.17 Oct 9, 2024
0.14.16 Aug 26, 2024

#512 in Game dev

Download history 931/week @ 2024-08-21 119/week @ 2024-08-28 24/week @ 2024-09-04 8/week @ 2024-09-11 22/week @ 2024-09-18 45/week @ 2024-09-25 9/week @ 2024-10-02 231/week @ 2024-10-09 17/week @ 2024-10-16 5/week @ 2024-10-23 5/week @ 2024-10-30 7/week @ 2024-11-06 2/week @ 2024-11-13 6/week @ 2024-11-20 148/week @ 2024-11-27 139/week @ 2024-12-04

295 downloads per month
Used in spirit_edit_core

MIT license

120KB
2K SLoC

Bevy Clay Tiles

Paint tiles and walls within a constrained+layered 2D grid system and they are extruded to 3D meshes for 3D games. This is meant to be useful for blocking out levels.

(Inspired by DreamerTalin)

Installing

cargo add bevy_clay_tiles

clay_tiles

image

Run example

cargo run --example basic

Config

In the tile_types config, for each 'tile type' you can set:

  1. the texture index used for diffuse texture
  2. texture UV expansion factor (stretch material)
  3. color tint of the diffuse texture

Editing

When creating the clay tiles, you can use either a Rectangle paint mode or a Polygon paint mode, similar to the Rectangle or Polygon select tools in typical photo editor softwares.

The edit mode allows you to control:

  1. the Y height offset of created tiles
  2. the height scale that new tiles will be extruded up to
  3. the tile type index (see the Config section and tile_types.ron)
  4. the default parent entity for the tile meshes when created

Tile Materials

When clay tiles blocks spawn, they will not have a material on them, only a component ClayTileMaterial { material_name: String }. Therefore it is your responsibility to replace the component with your own material handle. The example use the BevyMaterialTool to help with this but you can just insert a Handle if you wish.


fn add_material_handles(
  mut commands:Commands, 
  block_query: Query<(Entity, &ClayTileMaterial), Added<ClayTileMaterial>>
){

  for (tile_entity, tile_material_comp) in block_query.iter(){

      let material_name = &tile_material_comp.material_name;  

      commands.get_entity(tile_entity).map( |mut cmd| { 


          cmd.remove::<ClayTileMaterial>( ); 

          cmd.insert( MaterialOverrideComponent {
              material_override:  material_name.clone()
          }  ); 


      } );

  }

}

Do you like this crate? Support the creator on Patreon

https://www.patreon.com/infernaltoast

creatinggames-preview

Dependencies

~31–43MB
~734K SLoC