Editor-side settings and plan builder for an architecture generator in the Advanced Mapping Tools package. ArchitectureStudioSettings holds width, depth, elevation and three material paths; ArchitectureStudioPlan creates a root part group and adds named solid parts built through MeshKit, with contact faces left in place.
namespace AdvancedMappingTools;
public abstract class ArchitectureStudioSettings : GeneratorSettings
{
public float Width { get; set; } = 192;
public float Depth { get; set; } = 128;
[Property, Group( "Placement" ), Range( -4096, 4096, slider: false ), WideMode]
public float Elevation { get; set; }
[Property, Group( "Materials" ), Title( "Structure" ), ResourceType( "vmat" ), WideMode]
public string StructureMaterial { get; set; }
[Property, Group( "Materials" ), Title( "Trim / Frame" ), ResourceType( "vmat" ), WideMode]
public string DetailMaterial { get; set; }
[Property, Group( "Materials" ), Title( "Infill / Finish" ), ResourceType( "vmat" ), WideMode]
public string FinishMaterial { get; set; }
public override IReadOnlySet<string> UnusedOptions => new HashSet<string>
{
nameof( Variation )
};
}
/// <summary>Named, editable parts. Contact faces are kept in place rather than lifted apart.</summary>
internal sealed class ArchitectureStudioPlan
{
readonly GenContext context;
readonly ArchitectureStudioSettings settings;
public PartPlan Root { get; }
public Material Structure { get; }
public Material Detail { get; }
public Material Finish { get; }
public ArchitectureStudioPlan( GenContext context, ArchitectureStudioSettings settings, string name )
{
this.context = context;
this.settings = settings;
Root = context.Group( "root", name, "ArchitectureStudio", "architecture" );
Structure = context.Material( settings.StructureMaterial );
Detail = context.Material( settings.DetailMaterial ?? settings.StructureMaterial );
Finish = context.Material( settings.FinishMaterial ?? settings.StructureMaterial );
}
public void Add( string id, string name, Material material, Action<MeshKit> build ) => Root.Add( context.Solid( id, name, "ArchitecturePart", "architecture", material, kit =>
{
kit.LiftFlushFaces = false;
kit.Frame = new Transform( Vector3.Up * settings.Elevation, Rotation.Identity );
build( kit );
} ) );
public void Box( string id, string name, Material material, Vector3 min, Vector3 max ) => Add( id, name, material, kit => kit.Box( min, max ) );
}