--- name: modeling display_name: Mesh Modeling description: Create and edit static/skeletal mesh geometry programmatically (ModelingService) โ€” primitives, booleans, extrude/inset/bevel on selections, remesh/simplify/subdivide, deform, voxel ops, auto-UV, normals, repair, collision, LODs, bake, and saving to assets. Use when the user asks to build, kitbash, block out, fix, clean up, or generate 3D meshes in the editor without Blender. vibe3d_classes: - ModelingService unreal_classes: - DynamicMesh - StaticMesh - GeometryScript_MeshPrimitives - GeometryScript_MeshBooleans - GeometryScript_MeshUVs - StaticMeshEditorSubsystem keywords: - modeling - mesh - geometry - geometry script - primitive - boolean - extrude - inset - bevel - remesh - simplify - subdivide - voxel - collision - lod - bake normal map - kitbash - blockout - procedural mesh --- > ๐Ÿง  **Brains complement:** IF an `unreal-engine-skills-manager` tool (external MCP) exists in this session, call it with `{action: "load", skill: "meshes-static-and-skeletal"}` for UE domain knowledge on this topic โ€” correct APIs, architecture, best practices โ€” and treat it as the rubric for any review / "best practices" question. If no such tool is available (e.g. running under Claude Code or Codex without that MCP), skip this line entirely and proceed with this skill alone โ€” do NOT attempt the call. # Mesh Modeling Skill `ModelingService` (`unreal.ModelingService`) is the programmatic half of Unreal's **Modeling Mode**: the same operators the 97 interactive tools are built on, exposed as functions on an in-memory `DynamicMesh` that you build up and then save as a `StaticMesh` / `SkeletalMesh` asset. Nothing here needs a viewport, a gizmo, or Blender. **Mental model โ€” a session of mesh handles:** 1. `create_mesh()` / `load_mesh_from_static_mesh(path)` / `load_mesh_from_actor(label)` โ†’ a result; check `success`, then use its integer **`.handle`**. 2. Every op mutates the handle's mesh in place and returns an `FModelingResult` (`success`, `message`, `triangle_count`, `vertex_count`). 3. `save_mesh_to_static_mesh(handle, "/Game/Props/SM_Crate")` writes the asset (creates or replaces); `spawn_static_mesh_actor(...)` places it. 4. `release_mesh(handle)` when done (or `release_all_meshes()`); handles are session-scoped and not saved. Operations that take a **selection** use a named selection created on the same handle (`select_all`, `select_by_normal_angle`, `select_in_box`, `select_in_sphere`, `select_by_material_id`, `expand_contract_selection`, `invert_selection`). Pass `""` as the selection name to mean "the whole mesh". ## Quick start โ€” a crate with a lid seam, UVs, collision, LODs ```python import unreal svc = unreal.ModelingService h = svc.create_mesh().handle svc.append_box(h, unreal.Transform(), 100, 100, 100) # body lid = svc.create_mesh().handle svc.append_box(lid, unreal.Transform(unreal.Vector(0, 0, 90)), 104, 104, 4) # lid slab svc.boolean(h, lid, "Union") svc.select_by_normal_angle(h, "top", unreal.Vector(0, 0, 1), 5.0) svc.inset_faces(h, "top", 6.0) # panel line on the lid svc.extrude_faces(h, "top", -1.5) # recess it svc.bevel_polygroups(h, 0.8) svc.recompute_normals(h, 30.0) svc.auto_uv(h, "PatchBuilder", 0) r = svc.save_mesh_to_static_mesh(h, "/Game/Props/SM_Crate", True, True) # nanite off, collision on print("CREATED:", r.asset_path, r.triangle_count, "tris") svc.generate_collision("/Game/Props/SM_Crate", "ConvexHulls", 4) svc.set_lods("/Game/Props/SM_Crate", [1.0, 0.5, 0.25]) svc.spawn_static_mesh_actor("/Game/Props/SM_Crate", unreal.Transform(unreal.Vector(0, 0, 0)), "Crate_01") svc.release_all_meshes() ``` Then **look at it**, framed on the actor, using the available viewport capture tool (native Unreal MCP exposes `capture_image` with `source="editor"`). A successful call is not proof the shape is right. A level made with `new_level()` has **no lighting**, so a black capture may be a lighting problem. For daylight, use a DirectionalLight pointing down (`Rotator(roll=0, pitch=-48, yaw=125)`), a SkyLight and SkyAtmosphere. A dark studio can instead use movable RectLights and a floor. Use an unbound PostProcessVolume with fixed exposure for consistent material evaluation; tune exposure to the actual light intensities rather than treating one bias value as universal. For modeled lettering and logos, read [modeled-lettering.md](modeled-lettering.md). For lit promotional images, high-resolution capture, or distributable asset packs, read [showcase-and-delivery.md](showcase-and-delivery.md). These sibling documents are also registered as native Unreal agent sub-doc skills by Vibe3D. ## Function map (Python names) | Area | Functions | |---|---| | Session | `create_mesh()`, `load_mesh_from_static_mesh(path, lod=0)`, `load_mesh_from_skeletal_mesh(path, lod=0)`, `load_mesh_from_actor(label)`, `copy_mesh(handle)`, `release_mesh(handle)`, `release_all_meshes()`, `list_meshes()`, `get_mesh_info(handle)` | | Primitives (append into a handle) | `append_box`, `append_sphere`, `append_sphere_box`, `append_cylinder`, `append_cone`, `append_capsule`, `append_torus`, `append_rectangle`, `append_disc`, `append_stairs`, `append_curved_stairs`, `append_extrude_polygon(handle, transform, points2d, height)`, `append_revolve_polygon(handle, transform, points2d, radius, steps, degrees)`, `append_sweep_polyline(handle, transform, profile2d, path_transforms)` (open tube โ€” prefer the next one for solids), `append_loft(handle, transform, closed_profile2d, frames)` (capped, always outward; frame scale = chord), `append_mesh(handle, other_handle, transform)`, `append_mesh_at_transforms(handle, other, [transforms])`, `append_mesh_along_polyline(handle, other, points, spacing, up)` | | Booleans | `boolean(target, tool, "Union|Subtract|Intersection", tool_transform)`, `self_union`, `plane_cut(handle, plane_transform, fill_holes)`, `mirror(handle, plane_transform, weld)`, `cut_groove_along_polyline(handle, points, width, depth, up)` | | Selections | `select_all(handle, name)`, `select_by_normal_angle(handle, name, normal, max_angle_deg)`, `select_in_box(handle, name, box_min, box_max)`, `select_in_sphere(handle, name, center, radius)`, `select_by_material_id(handle, name, material_id)`, `select_by_polygroup(handle, name, group_id)`, `select_connected(handle, name, point)` (whole connected piece nearest the point), `select_by_bone_weight(handle, name, "bone,bone", min_weight=0.25)` (vertices those bones drag โ€” region finding for weight repair), `expand_contract_selection(handle, name, new_name, iterations, contract)`, `invert_selection(handle, name, new_name)`, `selection_count(handle, name)`, `selection_bounds(handle, name)` โ†’ `(min, max)` (Python drops the bool; an empty selection gives zero vectors), `clear_selections(handle)` | | Poly edit on selections | `extrude_faces(handle, sel, distance, direction)`, `offset_faces(handle, sel, distance)`, `inset_faces(handle, sel, distance)`, `outset_faces(handle, sel, distance)`, `delete_faces(handle, sel)`, `translate_selection(handle, sel, delta)`, `bevel_polygroups(handle, distance, subdivisions)`, `offset_mesh(handle, distance)`, `shell_mesh(handle, thickness)` | | Mesh | `remesh(handle, target_triangles, edge_length=0)`, `simplify_to_triangle_count(handle, n)`, `simplify_to_vertex_count(handle, n)`, `simplify_to_tolerance(handle, tolerance)`, `simplify_planar(handle)` (lossless, coplanar only), `subdivide(handle, level, "PN|Uniform|CatmullClark|Loop")`, `smooth(handle, sel, iterations, alpha)`, `fill_holes(handle)`, `weld_edges(handle, tolerance)`, `repair(handle)` (degenerates + small components), `remove_hidden_triangles(handle)`, `split_by_components(handle)` โ†’ new handles | | Queries, sampling, hulls | `ray_cast(handle, origin, direction)` / `nearest_point(handle, point)` โ†’ `{found, position, triangle_id, distance}`, `is_point_inside(handle, point)`, `sample_surface_points(handle, radius, max)` โ†’ transforms for scattering, `convex_hull(handle)`, `convex_decomposition(handle, num_hulls)`, `swept_hull(handle, frame)` โ†’ NEW handles, `measure_distance(a, b)` โ†’ max/mean/rms (verify LODs and simplifications) | | Deform | `bend(handle, orientation, angle, extent)`, `twist(...)`, `flare(handle, orientation, percent_x, percent_y, extent)`, `noise(handle, sel, magnitude, frequency, seed)`, `displace_from_texture(handle, sel, texture_path, magnitude, uv_layer)` | | Voxel | `voxel_solidify(handle, grid_resolution)`, `voxel_morphology(handle, "Dilate|Contract|Open|Close", distance, grid_resolution)` | | UVs / normals / groups / materials / colors | `auto_uv(handle, "XAtlas|PatchBuilder", uv_layer)`, `project_uv(handle, "Planar|Box|Cylinder", transform, uv_layer, sel)`, `repack_uv(handle, uv_layer, resolution)`, `set_num_uv_layers`, `recompute_normals(handle, hard_angle_deg)`, `flip_normals`, `ensure_outward(handle)` (flip if the enclosed volume is negative), `compute_polygroups(handle, "Angle|UVIslands|Components|Polygons", crease_angle)`, `set_material_id(handle, sel, id)`, `remap_material_id(handle, from, to)`, `set_vertex_color(handle, sel, color)`, `set_polygroup(handle, sel, group_id=-1)`, `recompute_uvs(handle, uv_layer, "Polygroups|UVIslands", "SpectralConformal|Conformal|ExpMap", sel)`, `transform_uv(handle, uv_layer, sel, translation, scale, rotation_deg, origin)`, `layout_uv(handle, uv_layer, "Repack|Stack|Normalize|Transform", sel, resolution)`, `pack_uv_per_material(handle, uv_layer, resolution)`, `get_uv_stats(handle, uv_layer)` โ†’ islands/coverage/overlap/texel density, `world_to_uv(handle, point, uv_layer)` | | Transform | `transform_mesh(handle, transform)`, `translate_mesh`, `rotate_mesh`, `scale_mesh`, `recenter_mesh(handle, "Bounds|Base")` | | Assets | `save_mesh_to_static_mesh(handle, path, replace_existing, enable_collision, enable_nanite)`, `save_mesh_to_skeletal_mesh(handle, path, skeleton_path="")` ("" creates `_Skeleton` from the mesh bones), `set_asset_materials(asset_path, "/Game/M_A,/Game/M_B")`, `transfer_bone_weights(handle, source_skeletal_mesh_path)`, `smooth_bone_weights(handle, skeleton_path)`, `prune_bone_weights(handle, "bone,bone")`, `scale_bone_weights(handle, sel, "bone,bone", scale, receiver_bone="")` (regional weight repair; freed weight -> receiver or strongest other influence), `smooth_selection_bone_weights(handle, sel, iterations=3, alpha=0.5)` (feather weight seams), `inspect_bone_weights(handle, sel="")` (per-bone verts/avg/max, weight sums, max influences), `create_bones(handle, [ModelingBoneDef(name, parent_name, transform)])`, `bind_selection_to_bone(handle, sel, bone, weight=1)`, `list_bones(handle)` โ†’ per-bone vertex counts, `generate_collision(asset_path, "MinVolumeShapes|ConvexHulls|AlignedBoxes|OrientedBoxes|MinimalSpheres|Capsules|SweptHulls", max_hulls)`, `set_lods(asset_path, [percent_triangles...])`, `bake_textures(target_handle, source_handle, "TangentNormal,AmbientOcclusion,Curvature,ObjectNormal,Position,VertexColor,MaterialID,UVShell,Height", resolution, out_folder, base_name)`, `bake_texture_transfer(target, source, "T_A,T_B", resolution, out_folder, base_name)`, `import_texture(file, asset_path, srgb, "Default|Normalmap|Masks|Grayscale|HDR")`, `create_noise_texture(asset_path, w, h, cells, octaves)`, `draw_on_texture(asset_path, "Line|Dots|Rect|Fill", uv_points, color, thickness_px, spacing_px)`, `spawn_static_mesh_actor(asset_path, transform, label)`; `load_mesh_from_actor` also reads skeletal / dynamic mesh actors | ## GeometryScript coverage ModelingService wraps ~115 of GeometryScript's 622 functions โ€” every operator behind a Modeling Mode tool plus the asset plumbing. What it deliberately does not wrap, and how to reach it: | Not wrapped | Why | Reach it with | |---|---|---| | `GeometryScript_List*`, `VectorMath`, `Transform`, `Box`, `OrientedBox`, `Ray`, `SimplePolygon`, `PolyPath`, `PolygonList`, `PointSetSampling` | Pure math / container helpers, not editor operations | Call directly โ€” they take plain values | | `MeshWeightMap`, `MeshSculptLayers`, `MeshGeodesic`, `TextureMap`, `VolumeTextureBake`, `EditorTextureMap` | Niche; would double the API for rare use | `mesh = svc.get_dynamic_mesh(handle)` then e.g. `unreal.GeometryScript_MeshGeodesics.create_surface_path(mesh, ...)` | | Per-function option structs (remesh smoothing type, bake bit depth, XAtlas iterations, ...) | The wrappers fix sensible defaults | Same trick โ€” the handle's `UDynamicMesh` is the live object; GeometryScript calls edit it in place and the next `svc.*` call sees the result | Discover any of them with `discover_python_class('unreal.GeometryScript_')`. Exact signatures: `discover_python_class('unreal.ModelingService')`. The long tail โ€” anything not here โ€” is reachable directly: the mesh behind a handle is `svc.get_dynamic_mesh(handle)`, which you can pass to any `unreal.GeometryScript_*` library function in the same script. ## Critical rules - **Units are centimeters, +Z up, origin at the base by default** for `append_box`/`append_cylinder` (`origin="Center"` to change). A 100 cm crate at `Transform()` sits on the floor. - **`unreal.Rotator(a, b, c)` is `(roll, pitch, yaw)`** โ€” not the C++ `FRotator(Pitch, Yaw, Roll)` order. Passing a yaw positionally silently *pitches* the part instead of turning it, and nothing errors: a mug handle comes out as a horizontal donut, a sofa spawns upside down, a light aims at the sky. **Always pass by keyword** โ€” `unreal.Rotator(roll=0, pitch=0, yaw=90)` โ€” and confirm with `get_mesh_info` bounds (a flipped part shows negative Z) or by reading `.roll/.pitch/.yaw` back. - **Laying a cylinder/cone/capsule on an axis: `pitch=-90` gives +X, `pitch=+90` gives โˆ’X.** These primitives are built along local +Z from their base, and the intuitive `pitch=90` sends them *backwards* โ€” a windmill's windshaft and hub grew back into the roof instead of out to the sails, which only showed up as an unexpected `bounds_max.x`. `roll=-90` gives +Y, `roll=+90` gives โˆ’Y. Check `get_mesh_info` bounds after the first one and reuse whatever proved correct. - **Low-step primitives are polygons, and their flats sit inside the nominal radius.** A torus or cylinder with `steps=8` has radius `R` only at its corners and `Rยทcos(ฯ€/8) = 0.92ยทR` at the middle of each face. Parts placed at radius `R` between corners therefore miss it entirely: an octagonal gallery deck left its railing posts hanging in the air, connected to nothing. Either raise the step count until the difference is under your part's thickness (24 steps โ†’ 0.9% error), or place the parts at the corner angles. - **Booleans want closed meshes.** Run `get_mesh_info` โ€” `is_closed` false or `open_border_edges > 0` means fill holes / weld first, or the boolean produces flaps. `self_union` cleans up kitbash overlaps. - **Selections go stale when topology changes.** After boolean, remesh, bevel, subdivide, etc. re-run the `select_*` call before using the name again; the service refuses a selection made before the mesh changed (`success: false`, "stale") rather than acting on wrong triangles. `extrude_faces`, `offset_faces`, `inset_faces` and `outset_faces` are the exception: the selection they used then holds the faces they moved (an inset's inner panel), so inset โ†’ extrude chains. - **Order for a clean asset:** model โ†’ `repair` โ†’ `recompute_normals` โ†’ `auto_uv` โ†’ `save` โ†’ `generate_collision` โ†’ `set_lods`. UVs before save, collision and LODs after (they act on the asset). - **`save_mesh_to_static_mesh` replaces LOD0 of an existing asset** when `replace_existing` is true; its materials are kept. Existing collision/LODs on that asset are not touched โ€” regenerate them if the silhouette changed. - **Log for rollback:** `print("CREATED:", path)` after each save; there is no undo for handle ops (they are in memory), but assets go through the editor and `TransactionService` checkpoints apply. - **Verify with evidence.** `get_mesh_info` after each stage (triangle/vertex counts, bounds, closed), and a viewport capture once it is in the level. - **Swept surfaces can come out inside-out.** After `append_sweep_polyline` + `fill_holes`, check `get_mesh_info(h).volume`; a negative volume means the normals face inward and `self_union` / `boolean` will silently discard the part as negative space. Call `flip_normals(h)` first. Sweep frame semantics: with frame rotation yaw 90 the profile's X runs along world -X from the frame position and its Y along world Z; put the profile scale (e.g. a wing chord) in the frame's Scale. - **XAtlas needs a compact mesh.** `fill_holes` and boolean cuts leave id gaps; `auto_uv` compacts automatically from 2.2, older builds need `unreal.GeometryScript_MeshRepair.compact_mesh(svc.get_dynamic_mesh(h))` first. - **Budget triangles.** Voxel ops and PN tessellation explode counts; follow them with `simplify_to_triangle_count`. Keep props under ~20k tris unless Nanite is on. - **Don't boolean two surfaces that nearly coincide.** A coffee disc unioned at the exact radius of the mug's inner wall produced slivers and 214 open border edges. Either leave a clear margin (~2% of the feature size) or skip the boolean: appending the part into the same handle as its own nested closed component is valid for a StaticMesh and is what you want for liquid in a vessel, glass in a frame, or anything that never needs to be one watertight shell. - **`repair()` can open a closed mesh.** Collapsing degenerates leaves holes. It now re-closes a mesh that arrived watertight (`keep_closed=True` by default) โ€” pass `False` for the raw result โ€” but always re-check `is_closed` before a boolean or voxel op. ## Common mistakes - Calling `extrude_faces` with `""` (whole mesh) โ€” that shells the whole object outward. Select faces first. - Forgetting `auto_uv` before `bake_textures` or before saving a mesh that will take a textured material. - `set_lods` with `[1.0]` only โ€” that removes extra LODs. Give one entry per LOD, LOD0 first. - Loading a mesh from an actor and saving back to a *new* path, then wondering why the level didn't change โ€” spawn or reassign the actor's mesh. - **Passing `material_id` positionally.** These wrappers have long tails of optional arguments (`append_stairs(handle, transform, step_width, step_height, step_depth, num_steps, floating, material_id)`), so one missing argument silently feeds your material id to `floating`. Pass the tail by keyword: `svc.append_stairs(h, T(), step_width=40, step_height=10, step_depth=20, num_steps=4, material_id=7)`. - Assuming a rotation worked because the call returned `success`. Nothing here validates orientation โ€” check `get_mesh_info` bounds, then look at it. ## Material slots A mesh carries **material IDs**; the saved asset carries **material slots**, one per distinct ID in ascending order. So the workflow is: give each part its id as you append it, then point the slots at real materials after saving. ```python svc.append_revolve_polygon(h, T(), cup_profile, 0, 48, 360, 0) # id 0 = ceramic svc.append_cylinder(h, T(V(0,0,6.6)), 3.7, 1.2, 48, 0, True, "Base", 1) # id 1 = coffee print(svc.get_mesh_info(h).material_ids) # -> [0, 1] ALWAYS check svc.save_mesh_to_static_mesh(h, "/Game/Props/SM_Mug", True, True) svc.set_asset_materials("/Game/Props/SM_Mug", "/Game/M_Ceramic,/Game/M_Coffee") ``` - `get_mesh_info(h).material_ids` is the check that a part actually took its id โ€” do it before saving, not after wondering why the asset has one slot. - A part built in **another handle** keeps its ids through `append_mesh`, so either way works. - To give an id to something already merged in, select it and set it: `svc.select_connected(h, "shade", point_on_it)` then `svc.set_material_id(h, "shade", 1)`. - Without `set_asset_materials` every slot renders as the default grey โ€” a mesh with correct ids still looks untextured in the viewport. ## Return types - `FModelingResult`: `success`, `message`, `handle`, `triangle_count`, `vertex_count`, `asset_path`. - `FModelingMeshInfo` (`get_mesh_info`): `handle`, `triangle_count`, `vertex_count`, `is_closed`, `open_border_edges`, `connected_components`, `bounds_min`, `bounds_max`, `surface_area`, `volume`, `num_uv_layers`, `has_vertex_colors`, `material_ids`. - `FModelingSplitResult` (`split_by_components`): `success`, `handles`. ## Lofted solids (wings, fins, hulls) `append_loft(h, transform, profile, frames, material_id)` sweeps a **closed** 2D profile through a list of frames, caps both ends, and guarantees an outward-facing closed solid (it checks the enclosed volume and flips when the sweep came out inside-out). Frame semantics: - The profile lies in each frame's local **YZ** plane: profile X runs along the frame's Y axis, profile Y along its Z axis. - The frame's **scale** multiplies the profile, axis for axis: **scale.Y scales profile X, scale.Z scales profile Y** (scale.X does nothing). So with identity-rotation frames marching along world X, a frame scale of `(1, half_width, half_height)` gives you a section that many cm wide and tall โ€” which makes a hull or fuselage a table of `(x, z, half_width, half_height)` rows and nothing else: ```python prof = [V2(-1,-0.9), V2(-0.55,-1), V2(0.55,-1), V2(1,-0.9), V2(1,0.72), V2(0.6,1), V2(-0.6,1), V2(-1,0.72)] sections = [(-980,200,16,18), (-300,178,50,70), (60,188,64,96), (500,196,54,66), (760,176,14,15)] frames = [T(V(x, 0, z), R(0,0,0), V(1.0, w, h)) for (x, z, w, h) in sections] svc.append_loft(h, T(), prof, frames, 0) ``` - Frames are positioned along the path; two frames make a straight tapered section. - Verify the mapping with a unit square through two frames and read `get_mesh_info` bounds before committing to a complex shape โ€” it costs one call and saves rebuilding a hull. A wing running out along +Y with its chord toward โˆ’X and 6 % thickness: ```python airfoil = [unreal.Vector2D(x, y) for x, y in ((0,0),(0.05,0.03),(0.3,0.06),(0.7,0.04),(1,0),(0.7,-0.03),(0.3,-0.04),(0.05,-0.02))] frames = [unreal.Transform(unreal.Vector(880, 100, 0), unreal.Rotator(0, 0, 90), unreal.Vector(480, 480, 480)), # root: LE at x=880, chord 480 unreal.Transform(unreal.Vector(600, 640, 0), unreal.Rotator(0, 0, 90), unreal.Vector(160, 160, 160))] # tip svc.append_loft(h, unreal.Transform(), airfoil, frames, 0) ``` `ensure_outward(h)` does the same volume check on any closed part you built another way (revolves, raw sweeps) โ€” run it before `self_union`, which silently discards inside-out parts as negative space. Apply this to each separate part before appending it to an assembly, especially after reflecting polygon coordinates. The assembly's total signed volume can be positive while a smaller component is still inside-out; a single check on the combined handle will miss that component. ## Rigging control surfaces (rudders, flaps, canopies, turrets) Bones and skin weights are authored straight on the session mesh; saving with an empty skeleton path creates the Skeleton asset for you. **Plan the components before you model.** `select_connected` is the only selection that grabs a moving part exactly, so build each part that will get its own bone in its **own handle**, `self_union` it there, and only then `append_mesh` it into the assembly. Appending never welds parts together, so the result is one mesh whose pieces are still separately selectable โ€” no cutting required: ```python tower = svc.create_mesh().handle; ...; svc.self_union(tower) # stays on the root bone cap = svc.create_mesh().handle; ...; svc.self_union(cap) # will yaw sails = svc.create_mesh().handle; ...; svc.self_union(sails) # will spin h = svc.create_mesh().handle for part in (tower, cap, sails): svc.append_mesh(h, part, unreal.Transform()); svc.release_mesh(part) assert svc.get_mesh_info(h).connected_components == 3 # check before rigging ``` Check `connected_components` matches the number of pieces you expect *before* rigging โ€” a piece that merged into its neighbour, or split into two, is far cheaper to fix now than after binding. Parts that merely touch do **not** union: overlap them by a few cm, or they stay separate and a "solid" assembly comes apart. A box selection is the fallback when two pieces genuinely are one component, but it will also catch anything else inside the box (a shaft passing through a hub), and those stray triangles tear when the bone moves. 1. **Isolate each moving piece** as its own connected component โ€” either built separately as above, or cut free with a through-slot along the hinge line and at both ends (`boolean` Subtract with thin boxes). 2. **Grab it** with `select_connected(h, "flap_L", point_on_the_flap)` โ€” no radius to tune, it takes the whole piece nearest the point. `selection_bounds` then gives you the hinge line (the piece's forward edge). 3. **Define the hierarchy** with `create_bones(h, [ModelingBoneDef, ...])`: the first bone is the root, every other one names a parent listed earlier. Transforms are in mesh space; point each bone's **X axis along its hinge** so the surface deflects by rolling the bone (a swept hinge just needs the right yaw). Everything starts bound to the root. 4. **Bind** each piece: `bind_selection_to_bone(h, "flap_L", "flap_L", 1.0)`. 5. **Verify** with `list_bones(h)` โ€” every control bone should report the vertex count of its piece and the root the rest; a bone with 0 vertices means the selection missed. 6. **Save**: `save_mesh_to_skeletal_mesh(h, "/Game/Vehicles/SK_Jet", "", True, True)` creates `SK_Jet` plus `SK_Jet_Skeleton`; then `set_asset_materials("/Game/Vehicles/SK_Jet", "/Game/M_Paint,/Game/M_Glass")` fills the material slots (one slot per material ID). ```python B = unreal.ModelingBoneDef hinge_yaw = 0.0 # yaw of the hinge line in the XY plane svc.create_bones(h, [ B(name="root"), B(name="flap_L", parent_name="root", transform=unreal.Transform(unreal.Vector(534, 100, 0), unreal.Rotator(0, 0, 90 + hinge_yaw), unreal.Vector(1, 1, 1))), ]) ``` Animate the result like any skeletal mesh โ€” an AnimSequence keyed on the control bones (see the `animation` skill), a Control Rig, or `SetBoneRotationByName` on a PoseableMeshComponent for a quick check in a level. For continuous or variable-driven motion (a rotor, a windmill sail, a turret) the usual answer is an **Anim Blueprint driving the bone directly**, with no animation asset at all: Local Space Ref Pose โ†’ Local To Component โ†’ one Modify Bone per control bone โ†’ Component To Local โ†’ Output, and an EventGraph that accumulates the angle on `Event Blueprint Update Animation`. If VibeUE is installed, its `animation-blueprint` skill has the whole recipe, including the trap that a Modify Bone node ignores its Rotation pin until you set `rotation_mode` to additive in component space. ## Repairing skin weights (clothing that follows the wrong bone) The classic failure on a transferred garment: a collar rides up with the head, a hem is glued to one thigh. The cause is weight on bones that shouldn't own the region, and the fix is four calls โ€” no Blender round-trip: ```python h = svc.load_mesh_from_skeletal_mesh("/Game/.../SK_Jacket").handle n = svc.select_by_bone_weight(h, "collar", "head,neck_02", 0.15) # the vertices those bones drag print(svc.selection_bounds(h, "collar")) # sanity: is this really the collar? svc.scale_bone_weights(h, "collar", "head,neck_02", 0.25, "spine_05") # keep 25%, rest -> spine_05 svc.smooth_selection_bone_weights(h, "collar", 3, 0.5) # feather the seam print(svc.inspect_bone_weights(h, "collar").message) # per-bone verts/avg/max + sums svc.save_mesh_to_skeletal_mesh(h, "/Game/.../SK_Jacket", "") ``` - `select_by_bone_weight` builds the region from the weights themselves โ€” more reliable than a box when the garment's geometry is irregular. Intersect with `select_in_box` output via `expand_contract_selection`/`invert_selection` when only part of a bone's territory is wrong. - `scale_bone_weights(h, sel, bones, scale, receiver)`: scale 0 removes the influence; with no receiver the freed weight goes to each vertex's strongest other influence. Vertices bound *only* to the listed bones are skipped unless a receiver is named โ€” read the message. - `smooth_selection_bone_weights` is a Laplacian pass over the selection: run it whenever a repair or a rigid `bind_selection_to_bone` leaves a visible cliff at the boundary. - `inspect_bone_weights(h, sel="")` is the audit: influencing bones, per-bone average/max, weight sums (should be 1.0 ยฑ quantization), max influences. Check it before saving, and verify the pose in the animation skill afterwards โ€” bad weights are invisible in the ref pose. ## Texturing pipeline (UVs you control, masks you can make, pixels you can draw) Auto-unwraps (`auto_uv`) are fine for baking AO, useless for markings: hundreds of seams and uneven texel density. For anything an artist would paint, build the islands yourself and verify them. 1. **Define islands.** Assign a polygroup per panel/region: `compute_polygroups(h, "Angle", 30)` for hard-surface parts, then override with selections โ€” `select_in_box` / `select_by_normal_angle` / `select_connected` + `set_polygroup(h, sel, -1)` (a new group) so a wing top, a fuselage side or a whole rudder is one island. 2. **Unwrap** each island conformally: `recompute_uvs(h, 0, "Polygroups", "SpectralConformal")`. Big round shapes (fuselage) can instead take `project_uv(h, "Cylinder", transform, 0, sel)`. 3. **Pack** โ€” `layout_uv(h, 0, "Repack", "", 4096)` for one texture set, or `pack_uv_per_material(h, 0, 4096)` so every material slot (fuselage / wings / details) fills its own 0โ€“1 range and gets its own 4K. 4. **Verify** with `get_uv_stats(h)`: islands, coverage, `overlap_fraction` (must be ~0 unless you packed per material), `num_unset_triangles` (must be 0) and `texels_per_cm_at_1k`. Fix before baking. `world_to_uv(h, point)` tells you where a spot on the mesh lands on the texture. 5. **Masks without painting.** Select regions on the mesh, `set_vertex_color(h, sel, color)` per channel (R walkways, G stripes, B dirtโ€ฆ) and bake with `bake_textures(h, h, "VertexColor", โ€ฆ)`. `"MaterialID"` bakes a per-slot mask for free; `"UVShell"` draws the island outlines โ€” panel lines when islands are panels; `"Height"` and the normals/AO/curvature bakes remain. 6. **Pixels.** `create_noise_texture(path, 2048, 2048, cells, octaves)` for tileable grunge/wear; `draw_on_texture(path, "Line|Dots|Rect|Fill", uv_points, color, thickness_px, spacing_px)` to draw rivet rows, stripes and blocks straight into an 8-bit texture in UV space (use `world_to_uv` to place them); `import_texture(file, path, srgb, "Default|Normalmap|Masks|Grayscale")` for anything made elsewhere (a PolyHaven PBR set downloaded with `urllib` in the same Python script works). `bake_texture_transfer(target, source, "T_A,T_B", โ€ฆ)` re-projects textures from one unwrap onto another (after re-unwrapping, or from a detail mesh). 7. **Geometry detail for normal maps.** Build it on a copy: `append_mesh_along_polyline(h, rivet, points, spacing)` for fastener rows, `append_mesh_at_transforms(h, bolt, sample_surface_points(...))` for scatter, `cut_groove_along_polyline(h, points, width, depth)` for recessed panel lines โ€” then `bake_textures(game_mesh, detail_mesh, "TangentNormal,AmbientOcclusion", 4096, โ€ฆ)`. Crisp markings (roundels, numbers) are still best as decals: `set_num_uv_layers(h, 2)` + `project_uv(h, "Planar", transform, 1, sel)` gives a clamped UV1 the material samples a decal through.