Skip to content

johnmknight/KSPExternalVesselUtilities

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KSPExternalVesselUtilities (KSPEVU)

In-game Kerbal Space Program 1.12.5 plugin that exports the active vessel's geometry to a lightweight glTF on vessel load, serves it over a small built-in HTTP listener, and publishes a "model ready" MQTT notification so external consoles, dashboards, or mods can fetch and render the ship.

Pairs with KSPBridge — KSPEVU reuses the same Mosquitto broker for notifications, while KSPBridge continues to publish realtime vessel state (telemetry + staging).

Status — v0.9.4

Full pipeline end-to-end. Plugin captures vessels, writes glTF to a content-addressable cache, serves the files over HTTP, publishes an MQTT notification, and a bundled web viewer renders each ship as a clean solid+wireframe schematic with per-design overrides persisted to disk.

What it does

  1. Event hookGameEvents.onVesselChange + onVesselWasModified. The initial vessel-change snapshot is deferred by two FixedUpdate frames so KSP has finished instantiating part models and ModuleJettison has resolved its transform references before capture.
  2. Snapshot — walks vessel.parts, pulls each part's MeshFilter data. Runs a filter pass that:
    • drops inactive renderers, hidden layers, particle-system volumes
    • bounds-caps general hull meshes at 25 m and 20 000 verts
    • tags any mesh under a ModuleJettison shroud root with IsShroud / JettisonName / HeuristicallyHidden
    • relaxes the active/renderer/size checks for shrouds AND children of any ModuleDeployablePart so connecting boom/panel meshes survive KSP's SetActive(false) parking
    • force-samples ModuleDeployableSolarPanel animations to their end-frame so panels export in their deployed pose
  3. Structural hash — SHA-256 over per-part persistentId, name, parent, orgPos / orgRot. Content-addressable cache key in <cacheDir>/<hash>.glb. Identical designs share one file.
  4. Custom .glb writer — hand-rolled glTF 2.0 packer (GlbWriter.cs). No native deps, Mono-friendly. Emits:
    • per-part root node with orgPos + orgRot
    • one child node per ModuleJettison shroud with glTF extras ({shroud:true, jettisonName, heuristicallyHidden})
    • uint16 indices when the mesh fits, uint32 otherwise
    • content-hash-based primitive dedup so radially-repeated parts (4 boosters, 8 panels, truss segments) share one buffer range
  5. HTTP serve — in-plugin HttpListener on port 8090 (default). Routes:
    • GET /vessel/<hash>.glb — serve cached glb
    • GET /viewer/ — the bundled web viewer
    • GET /overrides/<hash>.json — per-design shroud overrides
    • PUT /overrides/<hash>.json — atomic write, 64 KB max, JSON object
  6. MQTT notification — publishes ksp/vessel_model/ready (retained) via the same Mosquitto broker KSPBridge uses.

Web viewer

GameData/KSPEVU/viewer/index.html — Three.js r128 + glTF loader + mqtt.js. Renders each part as a double-sided fill, a bright silhouette outline via inverted-hull, and feature-edge overlay lines (not full triangulation). Subscribes to the ready topic, fetches the referenced glb, fits the camera to the vessel bounds.

Shroud editor: "EDIT SHROUDS" button flips the viewer into a click-to- toggle mode. Each shroud is visible in edit mode, colour-coded by current override state. Clicks toggle that shroud's overrides.show entry and auto-save to the plugin via PUT /overrides/<hash>.json. Default is "all shrouds hidden" for a clean schematic look; any the user clicks are persisted per-design-hash.

Design quick links

License

MIT. See LICENSE.

About

KSP 1.12.5 plugin: exports active vessel geometry to glTF, serves via HTTP + MQTT. Web viewer with shroud toggle.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors