feat(hair): hair cards as their own skinned mesh, attached as a second component
Follows the character-artist skill on two points it is explicit about: hair for a game character is a card system, and swappable parts stay separate meshes. - Tools/character_hair_build.py builds SM_Char_Hair: a scalp cap plus 18 cards in three rings, quads only, every vertex weighted 1.0 to the head bone, UV-mapped for the strand sheet from Tools/generate_character_textures.py. 321 verts / 404 tris. - Tools/ue_character_hair_import.py imports it as its own skeletal mesh, which is the point: joined into the body, Unreal collapses the second material slot and the hair renders with the skin material. - The pawn carries it as a second USkeletalMeshComponent on SetLeaderPoseComponent, so it follows the head bone with no second rig and hides with the body in first person. Still wrong and recorded: the cards point outward, so the silhouette reads as a spiked crown rather than a short cut. The next pass orients them tangentially along the skull with a second overlapping row. Tools/ue_character_materials.py also segfaults in the headless commandlet when editing a material graph, so the generated textures are not wired yet and the hair keeps its Blender base colour.
This commit is contained in:
1 parent
72d00bdfbd
commit
39f07b0f5f
46 files changed
+519
-47
No files matched your search
@@ -0,0 +1,70 @@
|
||||
# Import the hair cards as their own skeletal mesh (0.2.2).
|
||||
#
|
||||
# blender -b Art/blender/character/character-2026-11-07.blend \
|
||||
# --python Tools/character_hair_build.py -- --out /tmp/gigline/character-hair.fbx
|
||||
# <engine>/Engine/Binaries/Linux/UnrealEditor-Cmd <uproject> -run=pythonscript \
|
||||
# -script=<repo>/Tools/ue_character_hair_import.py -nullrhi -unattended -nopause -stdout
|
||||
#
|
||||
# The hair is a separate asset on purpose: Unreal collapses the second material slot
|
||||
# when hair is joined into the body mesh, so a card system has to be its own object
|
||||
# (which is what the character-artist skill asks for anyway).
|
||||
#
|
||||
# Result file: /tmp/gigline/character-hair-import.txt
|
||||
|
||||
import unreal
|
||||
|
||||
SRC = "/tmp/gigline/character-hair.fbx"
|
||||
DEST = "/Game/Test/Character"
|
||||
NAME = "CharacterHair"
|
||||
RESULT = "/tmp/gigline/character-hair-import.txt"
|
||||
lines = []
|
||||
|
||||
|
||||
def log(msg):
|
||||
lines.append(str(msg))
|
||||
unreal.log(str(msg))
|
||||
|
||||
|
||||
def main():
|
||||
task = unreal.AssetImportTask()
|
||||
task.filename = SRC
|
||||
task.destination_path = DEST
|
||||
task.destination_name = NAME
|
||||
task.automated = True
|
||||
task.save = True
|
||||
task.replace_existing = True
|
||||
|
||||
ui = unreal.FbxImportUI()
|
||||
ui.import_mesh = True
|
||||
ui.import_as_skeletal = True
|
||||
ui.import_animations = False
|
||||
ui.import_materials = True
|
||||
ui.import_textures = False
|
||||
ui.skeletal_mesh_import_data.import_uniform_scale = 1.0
|
||||
task.options = ui
|
||||
unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task])
|
||||
|
||||
mesh = unreal.EditorAssetLibrary.load_asset(f"{DEST}/{NAME}")
|
||||
if mesh is None:
|
||||
log(f"MISSING {DEST}/{NAME}")
|
||||
lines.append("VERDICT: FAIL")
|
||||
return
|
||||
mats = mesh.get_editor_property("materials")
|
||||
log(f"{NAME}: {len(mats)} material slot(s)")
|
||||
for i, m in enumerate(mats):
|
||||
face = m.get_editor_property("material_interface")
|
||||
log(f" slot {i}: {face.get_name() if face else 'None'}")
|
||||
lines.append("VERDICT: PASS")
|
||||
|
||||
|
||||
try:
|
||||
main()
|
||||
except Exception as exc: # noqa: BLE001
|
||||
import traceback
|
||||
log(f"FAILED: {type(exc).__name__}: {exc}")
|
||||
log(traceback.format_exc())
|
||||
lines.append("VERDICT: FAIL")
|
||||
|
||||
unreal.EditorLoadingAndSavingUtils.save_dirty_packages(True, True)
|
||||
with open(RESULT, "w") as f:
|
||||
f.write("\n".join(lines) + "\n")
|
||||
Reference in new issue
Block a user