Editor tool that stamps pallet racking geometry into a MeshKit mesh. Builds upright frames per bay boundary, horizontal beams at each level, and optional shelf decks between levels.
namespace AdvancedMappingTools;
/// <summary>
/// Pallet racking: upright frames, horizontal beams and optional shelf decks.
/// </summary>
[ToolCategory( "Industrial" )]
[Title( "Storage Racks" ), Icon( "dns" )]
public sealed class StorageRackEditor( PrimitiveTool tool ) : StampEditor( tool )
{
[Property, Group( "Rack" ), Range( 1, 12, slider: false ), WideMode]
public int Bays { get; set; } = 3;
[Property, Group( "Rack" ), Title( "Bay Width" ), Range( 16, 512, slider: false ), WideMode]
public float BayWidth { get; set; } = 96.0f;
[Property, Group( "Rack" ), Range( 16, 256, slider: false ), WideMode]
public float Depth { get; set; } = 48.0f;
[Property, Group( "Rack" ), Range( 32, 1024, slider: false ), WideMode]
public float Height { get; set; } = 192.0f;
[Property, Group( "Rack" ), Range( 1, 12, slider: false ), WideMode]
public int Levels { get; set; } = 3;
[Property, Group( "Rack" ), WideMode]
public bool Shelves { get; set; } = true;
protected override void Stamp( MeshKit kit, Transform frame, Random random )
{
var bays = Math.Clamp( Bays, 1, 12 );
var bay = MathF.Max( BayWidth, 16.0f );
var depth = MathF.Max( Depth, 16.0f );
var height = MathF.Max( Height, 32.0f );
var levels = Math.Clamp( Levels, 1, 12 );
var total = bay * bays;
var half = total * 0.5f;
var d = depth * 0.5f;
var upright = 4.0f;
var step = height / levels;
for ( var i = 0; i <= bays; i++ )
{
var x = -half + bay * i;
kit.Box( new Vector3( x - upright * 0.5f, -d, 0.0f ), new Vector3( x + upright * 0.5f, -d + upright, height ) );
kit.Box( new Vector3( x - upright * 0.5f, d - upright, 0.0f ), new Vector3( x + upright * 0.5f, d, height ) );
}
for ( var level = 1; level <= levels; level++ )
{
var z = step * level - 2.0f;
kit.Box( new Vector3( -half, -d + upright, z ), new Vector3( half, -d + upright + 2.0f, z + 4.0f ) );
kit.Box( new Vector3( -half, d - upright - 2.0f, z ), new Vector3( half, d - upright, z + 4.0f ) );
if ( !Shelves || level >= levels ) continue;
kit.Box( new Vector3( -half, -d + upright, z + 2.0f ), new Vector3( half, d - upright, z + 4.0f ) );
}
}
}