Pipe Network Generator

README

Pipe Network Generator
======================

Place a start point, an end point and any points in between, and a pipe
routes itself through them round whatever is in the way: straight runs on
the axes, an elbow at every turn, flanges, welds, valves, gauges, labels and
pipe markers, insulation, and supports to the floor, ceiling or wall. Cable
trays, ducts and glowing sci-fi conduits too.

Quick start
-----------

  Open the project and press Play (Maps/L_PN_Demo): one pipe routed round
  four blocks. Fly with WASD and the mouse. Tab opens the settings panel: a
  preset, style, size, service, wear, elbows, valves, supports, the route's
  bend cost and height, flanges, loops, welds, slope, labels, diagonals and
  stripes. Generate builds the pipe, Random tries a mix, and Show Search
  draws the route search. The panel shows how the route went.

  In the editor, select the pipe and drag its Start, End and Via handles:
  it routes again as you move them.

In your own project
-------------------

  1. Migrate the PipeGenerator folder into your project (right-click it in
     the Content Browser, Asset Actions > Migrate).
  2. Drag Blueprints/BP_PN_Pipe into a level. Move its Start and End
     handles, and add Via points where it should pass.
  3. The route keeps clear of anything with collision. Tag an actor
     PipeIgnore to let pipes pass through it, or PipeWall to pass through it
     with a sleeve and cover plates.
  4. After moving what is in the way, press Rebuild. Bake turns a finished
     pipe into one plain actor.

  Unreal stops a Blueprint call after 1,000,000 loop steps; a long pipe with
  a fine grid can pass that, so this project raises it (Project Settings >
  Engine > General Settings > Maximum Loop Iteration Count, 10,000,000). Do
  the same in your project if a pipe stops with an infinite loop message.

How it works
------------

  The route is an A* search on a 3D grid in the pipe's space: Start, End
  and the Via points are grid lines, so the route meets them exactly. A
  step costs its length, a turn BendCost more, and a level run away from
  PreferHeight more again. A step is free when a box the size of the
  section plus Clearance, swept along it, hits nothing. Each leg's cells
  are closed to the legs after it. The search stops after MaxSearchSteps, so a boxed-in end is
  reported (RouteFound, RouteMessage) and drawn as straight moves. Then the
  corners may be cut to 45 degrees (Diagonals) and the level runs sloped
  (Slope).

  The route is dressed with instanced meshes, one component per mesh and
  material: the material reads each piece's color, rust, and distance along
  the run (for the conduits' moving glow). Bends of any angle are spline
  meshes.

Settings (on BP_PN_Pipe, in the Details panel)
----------------------------------------------

  Route
    Start, End              The ends, in the pipe's space (drag the handles in
                            the viewport).
    StartDir, EndDir        The way the pipe leaves Start, and the way End faces
                            out (the pipe arrives heading the other way). Any
                            lets the route choose.
    Via                     Points the route passes through, in order (each has
                            a handle).

  Grid
    GridSize                The route's grid (cm), grown to at least two elbows'
                            reach.
    Clearance               Space kept from obstacles (cm).
    BendCost                What a turn costs, in grid cells: higher makes
                            straighter routes.
    PreferHeight, HeightWeight
                            A height the level runs are drawn to, and how
                            strongly (0 off): run high under the ceiling like a
                            real plant.
    SearchMargin            How many cells beyond the points the route may
                            wander.
    MaxSearchSteps          The most search steps for a route; one not found is
                            drawn as straight moves and RouteMessage says so.
    MaxCells                The most grid cells: a bigger area gets a coarser
                            grid.
    AvoidObstacles, ObstacleTypes
                            Route round anything of these object types. Pawns
                            and actors tagged PipeIgnore never block. Actors
                            tagged PipeWall are passed through, with a sleeve
                            and cover plates.
    Diagonals, DiagonalCut  Square corners of level runs cut by 45-degree runs
                            where clear, DiagonalCut back along each run (two
                            cuts that meet make a jog one diagonal).
    Slope                   Level runs fall toward End by this many cm a metre
                            (drains); the risers take up the fall.

  Pipe
    Style                   Industrial Steel, Painted, Copper, PVC, Rusted, Sci-
                            Fi Conduit, Cable Tray or HVAC Duct.
    Diameter                The pipe's outside diameter (cm).
    Width, Height           A tray's or duct's section (cm).
    ElbowType               Long radius (1.5 diameters) or short radius elbows,
                            or Bent (BendRadius) at every corner.
    BendRadius              The radius of bent corners (cm).
    Color                   The paint, the plastic or the glow.
    Service                 Water, Steam, Gas, Oil, Fire Water, Air, Chilled
                            Water, Hot Water, Nitrogen, Fuel, Sewer, Sprinkler,
                            Chemical or Reclaimed Water: the label's legend and
                            colors, after ASME A13.1 (steam, nitrogen, sewer and
                            reclaimed water in its user-defined colors).
    Wear                    Rust, 0 to 1.
    Insulated, InsulationThickness
                            An aluminum-clad insulation jacket with bands; bent
                            jackets on elbows.
    Collision               The pipe blocks players and traces.

  Fittings
    FlangeEvery             A flanged joint every so far (cm; 0 none): couplings
                            on copper and PVC, glowing bands on conduits, frames
                            on ducts.
    WeldEvery               A butt weld every so far along welded steel runs
                            (cm; 0 none).
    StartFitting, EndFitting
                            A free end's flange, cap, or nothing.
    ExpansionLoopEvery, ExpansionLoopSize
                            An expansion loop every so far along level runs, and
                            its depth. A loop goes to whichever side is clear of
                            obstacles, or is left out.

  Equipment
    Seed                    The random equipment.
    ValveType               Gate (handwheel), Ball (lever), Butterfly (lever),
                            or Random. Conduits get ball valves.
    ValveAtStart            A valve just after the start.
    ValveEvery, ValveChance
                            A valve every so far, and the chance of one on each
                            straight.
    GaugeEvery, GaugeChance
                            Pressure gauges.
    CheckValveChance        Check valves.
    DrainVentChance         Small drains (down) and vents (up) with a valve and
                            a cap.
    LabelEvery, Label       A label every so far; its text (empty: the Service's
                            name).
    LabelStyle              Plate: a plate with the text, a flow arrow and color
                            bands. Wrap: a snap-around marker with the service's
                            legend and arrow (round pipes, no Label text).
    HazardStripes           Yellow and black stripes either side of each valve.

  Supports
    Supports                Auto (floor, then ceiling, then wall), Floor stands,
                            Ceiling hangers, Wall brackets, or None. Trays and
                            ducts get trapezes.
    SupportSpacing          Supports at most this far apart (cm).
    SupportReach, SupportTypes
                            How far a support looks for a surface, and what it
                            may stand on.
    Trunnions               A dummy leg to the floor under the elbow at the foot
                            of each riser.

  Look
    FlowSpeed               How fast the glow runs along a conduit (cm/s;
                            negative runs the other way).
    Preset                  A PDA_PN_Preset to copy with Apply Preset.

Blueprint API (BP_PN_Pipe)
--------------------------

  Rebuild()
      Routes and dresses the pipe again (the construction script's work;
      callable at runtime).
  ShowSearch(), DrawSearch(Duration)
      The route's search drawn in the viewport: the cells it tried, the steps
      it found blocked, the route.
  Bake(), Unbake()
      Details panel buttons: the pipe's pieces as one BP_PN_Baked actor
      (instanced meshes, bends and text), and back.
  ApplyPreset()
      The Preset's look copied onto the pipe.

Baking
------

  Bake makes one BP_PN_Baked actor holding the pipe's pieces, attached to
  the pipe, and the pipe stops routing. For a single static mesh (and
  Nanite), select the BP_PN_Baked actor and use Tools > Merge Actors.

Presets
-------

  Put a preset in a pipe's Preset slot and press Apply Preset.
    DA_PN_SteamLine       insulated steel, steam, gauges
    DA_PN_FireWater       red painted fire water, gate valves, markers
    DA_PN_RustyOld        rusted, with valves
    DA_PN_SciFiConduit    a cyan conduit with a running glow
    DA_PN_CableTray       a cable tray
    DA_PN_HVACDuct        a galvanized duct with flanged joints
    DA_PN_Plumbing        hot water in copper, couplings and ball valves
    DA_PN_PVCDrain        a sloped PVC drain

Content
-------

  Blueprints
    BP_PN_Pipe (the generator), BP_PN_Baked (a baked pipe)
  Presets
    PDA_PN_Preset; DA_PN_SteamLine, DA_PN_FireWater, DA_PN_RustyOld,
    DA_PN_SciFiConduit, DA_PN_CableTray,
    DA_PN_HVACDuct, DA_PN_Plumbing, DA_PN_PVCDrain
  Meshes
    Pipe, bends, elbows 90 and 45 (long and short), cap, flanges, knuckle, weld
    Gate, ball, butterfly and check valves, handwheel, lever, gauge, label
    plate, arrow, band, marker
    Shoe, clamp, post, base plate, rod, ceiling plate, wall plate, arm, strut,
    wall sleeve, cover plate
    Cable tray, cables and tray corners; duct, duct corner and flange; conduit
    segment and band
    The demo's block
    The round parts have three LODs
  Materials
    M_PN_Metal (steel, paint, galvanizing, cladding, rust), M_PN_Copper,
    M_PN_PVC, M_PN_Band,
    M_PN_Conduit (emissive flow), M_PN_Marker (pipe markers), M_PN_Gauge,
    M_PN_Prop and their instances
  Textures
    T_PN_Markers (the markers' legends and hazard stripes)
  Enums
    E_PN_Dir, E_PN_Style, E_PN_Elbow, E_PN_Service, E_PN_Label, E_PN_Valve,
    E_PN_Support, E_PN_EndFit
  Demo
    Maps/L_PN_Demo, Demo/BP_PN_DemoPawn, Demo/BP_PN_GameMode, UI/WBP_PN_Settings

Unreal Engine 5.8. Blueprint only; the project enables no plugins.