Skip to content
1        10        20        30        40        50        60        70        80        90        100       110       1201"""Build Finella the Assassin as a game-ready GLB.23Lady Finella is a knife in the dark: a hooded leather-clad assassin with a4split tunic, gold buckles, twin curved daggers, and a short braid. She is posed5mid-step, one blade thrust forward and the other reversed behind her. The whole6model is procedural, so it can be rebuilt and tweaked from a terminal.78    blender -b --factory-startup -P tools/blender/finella.py -- \9      --out assets/models/finella.glb1011The character is about 1.7 Blender units tall and faces -Y in Blender, which12becomes +Z (towards the game camera) after the glTF Y-up conversion.13"""1415import argparse16import math17import sys18from pathlib import Path1920import bpy21from mathutils import Vector2223sys.path.insert(0, str(Path(__file__).resolve().parent))24from export_glb import export_scene  # noqa: E402  (needs Blender's sys.path)25from rig import rig_character  # noqa: E402  (needs Blender's sys.path)26from hero_parts import (  # noqa: E402  (needs Blender's sys.path)27    box,28    capsule,29    cylinder,30    group,31    limb,32    material,33    mesh_object,34    revolve,35    sculpted_head,36    sphere,37    subdivide,38    torus,39    tube,40)4142SKIN = (0.80, 0.77, 0.80)43HAIR = (0.025, 0.022, 0.03)44HAIR_SHADE = (0.05, 0.04, 0.06)45LEATHER = (0.035, 0.03, 0.04)46LEATHER_LIGHT = (0.08, 0.065, 0.075)47CLOTH = (0.02, 0.022, 0.03)48CLOTH_DEEP = (0.01, 0.01, 0.015)49GOLD = (0.30, 0.22, 0.12)50STEEL = (0.30, 0.32, 0.36)51BLOOD = (0.55, 0.08, 0.11)52EYE = (0.02, 0.01, 0.01)53IRIS = (0.55, 0.04, 0.06)54LIPS = (0.22, 0.05, 0.07)555657def cape(name, mat, *, top_z=1.27, bottom_z=0.42, top_width=0.22, bottom_width=0.29):58    """A ragged, wind-caught cloak hanging behind the shoulders."""59    rows = 960    cols = 1161    verts = []62    faces = []63    for row in range(rows):64        t = row / (rows - 1)65        width = top_width + (bottom_width - top_width) * t66        for col in range(cols):67            u = col / (cols - 1) * 2 - 168            x = u * width69            y = 0.10 + 0.19 * t * t + 0.035 * (1 - u * u) * t70            z = top_z + (bottom_z - top_z) * t71            if row == rows - 1:72                # Torn hem: alternating points and notches instead of a hem line.73                tatter = 0.5 + 0.5 * math.sin(u * math.pi * 4.5)74                z += 0.045 * tatter + 0.018 * math.cos(u * math.pi * 7.0) - 0.0275            elif row > 0:76                z += 0.012 * (1 - u * u)77            verts.append((x, y, z))78    for row in range(rows - 1):79        for col in range(cols - 1):80            a = row * cols + col81            faces.append((a, a + 1, a + cols + 1, a + cols))82    obj = mesh_object(name, verts, faces, mat)83    solidify = obj.modifiers.new(f"{name} Thickness", "SOLIDIFY")84    solidify.thickness = 0.01285    solidify.offset = 0.086    return obj878889def dagger(name, hand, direction, length, *, steel, gold, grip):90    """A curved-looking assassin blade built from a hilt, guard, and mesh blade."""91    hand = Vector(hand)92    axis = Vector(direction).normalized()93    pommel = hand - axis * 0.09594    guard = hand + axis * 0.0295    tip = guard + axis * length9697    parts = [98        limb(f"{name} Grip", pommel, guard, 0.019, 0.016, grip, vertices=8),99        sphere(f"{name} Pommel", tuple(pommel), 0.025, gold, scale=(1.0, 1.0, 0.9), segments=12, rings=8),100    ]101102    across = axis.cross(Vector((0, 0, 1)))103    if across.length < 0.1:104        across = axis.cross(Vector((1, 0, 0)))105    across.normalize()106    center = guard - axis * 0.006107    parts.append(108        limb(109            f"{name} Guard",110            tuple(center - across * 0.062),111            tuple(center + across * 0.062),112            0.014,113            0.014,114            gold,115            vertices=6,116        )117    )118119    # A diamond-section blade, widest just past the guard and tapering to a point.120    span = (tip - guard).length121    width = 0.042122    thickness = 0.011123    verts = [124        (width / 2, 0, 0),125        (0, thickness / 2, 0),126        (-width / 2, 0, 0),127        (0, -thickness / 2, 0),128        (width * 0.42, 0, span * 0.68),129        (0, thickness * 0.34, span * 0.68),130        (-width * 0.42, 0, span * 0.68),131        (0, -thickness * 0.34, span * 0.68),132        (0, 0, span),133    ]134    faces = [135        (0, 1, 5, 4),136        (1, 2, 6, 5),137        (2, 3, 7, 6),138        (3, 0, 4, 7),139        (4, 5, 8),140        (5, 6, 8),141        (6, 7, 8),142        (7, 4, 8),143        (0, 3, 2, 1),144    ]145    blade = mesh_object(f"{name} Blade", verts, faces, steel, smooth_shading=False)146    blade.location = guard147    blade.rotation_euler = (tip - guard).to_track_quat("Z", "Y").to_euler()148    parts.append(blade)149    return parts150151152def HOOD_EDGE(phi):153    """Lower limit (radians from the crown) of the hood: brow at the front, nape at the back."""154    return math.radians(96 + 34 * math.sin(phi))155156157def HAIR_EDGE(phi):158    """Lower limit of the hair shell: rises over the forehead and drops at the nape."""159    return math.radians(95.5 + 22.5 * math.sin(phi))160161162# Soft cloth and the hair shell get one Catmull-Clark pass so their seams round163# off. Limbs stay as tapered primitives: subdividing their open ends pinches them.164ORGANIC = ("Tunic", "Bodice", "Bust", "Cowl", "Hood", "Hair Crown", "Pouch")165166167def build():168    bpy.ops.wm.read_factory_settings(use_empty=True)169170    skin = material("Finella Skin", SKIN, roughness=0.62)171    hair = material("Finella Hair", HAIR, roughness=0.4)172    hair_shade = material("Finella Hair Shade", HAIR_SHADE, roughness=0.45)173    leather = material("Finella Leather", LEATHER, roughness=0.68)174    leather_light = material("Finella Leather Light", LEATHER_LIGHT, roughness=0.62)175    cloth = material("Finella Cloak", CLOTH, roughness=0.82)176    cloth_deep = material("Finella Cloak Deep", CLOTH_DEEP, roughness=0.86)177    gold = material("Finella Gold", GOLD, metallic=0.85, roughness=0.36)178    steel = material("Finella Steel", STEEL, metallic=0.9, roughness=0.26)179    blood = material(180        "Finella Blood Light",181        BLOOD,182        roughness=0.3,183        emission=(0.7, 0.08, 0.10),184        emission_strength=1.6,185    )186    eye = material("Finella Eyes", EYE, roughness=0.28)187    sclera = material("Finella Sclera", (0.92, 0.93, 0.92), roughness=0.34)188    iris = material(189        "Finella Iris",190        IRIS,191        roughness=0.24,192        emission=(0.7, 0.05, 0.06),193        emission_strength=0.9,194    )195    lips = material("Finella Lips", LIPS, roughness=0.58)196197    parts = []198199    # Legs: one forward, one trailing, both in fitted leather and tall boots.200    legs = [201        ("R", 1, (0.082, 0.00, 0.86), (0.092, -0.11, 0.48), (0.104, -0.20, 0.10)),202        ("L", -1, (-0.082, 0.01, 0.86), (-0.10, 0.09, 0.48), (-0.112, 0.18, 0.09)),203    ]204    for label, side, hip, knee, ankle in legs:205        hip = Vector(hip)206        knee = Vector(knee)207        ankle = Vector(ankle)208        parts.append(capsule(f"Finella Thigh {label}", hip, knee, 0.072, 0.053, leather, bulge=0.12, bulge_at=0.3))209        parts.append(capsule(f"Finella Calf {label}", knee, ankle, 0.053, 0.039, leather, bulge=0.14, bulge_at=0.3))210        parts.append(211            sphere(212                f"Finella Knee Guard {label}",213                tuple(knee + Vector((side * 0.008, -0.05, 0.008))),214                0.051,215                leather_light,216                scale=(1.0, 0.55, 0.82),217                segments=16,218                rings=10,219            )220        )221        boot_top = knee.lerp(ankle, 0.32)222        parts.append(223            cylinder(224                f"Finella Boot Cuff {label}",225                tuple(boot_top),226                0.052,227                0.075,228                leather_light,229                vertices=14,230            )231        )232        # The boot shaft closes the gap between calf and foot so the leg reads233        # as one piece down to the sole.234        parts.append(235            cylinder(236                f"Finella Boot Shaft {label}",237                (ankle.x, ankle.y, ankle.z - 0.045),238                0.043,239                0.09,240                leather_light,241                vertices=14,242            )243        )244        parts.append(245            sphere(246                f"Finella Foot {label}",247                (ankle.x, ankle.y - 0.07, 0.042),248                0.06,249                leather_light,250                scale=(0.7, 1.55, 0.52),251                segments=14,252                rings=10,253            )254        )255256    # Split leather tunic and a fitted bodice.257    parts.append(258        revolve(259            "Finella Tunic",260            [261                (0.66, 0.205),262                (0.73, 0.195),263                (0.80, 0.180),264                (0.86, 0.168),265            ],266            leather_light,267            y_scale=0.88,268            ripple=0.03,269            wave=0.012,270            thickness=0.011,271        )272    )273    parts.append(274        revolve(275            "Finella Bodice",276            [277                (0.84, 0.172),278                (0.90, 0.156),279                (0.97, 0.136),280                (1.03, 0.140),281                (1.09, 0.154),282                (1.15, 0.170),283                (1.20, 0.180),284                (1.25, 0.176),285                (1.29, 0.150),286                (1.31, 0.117),287            ],288            leather,289            y_scale=0.72,290            ripple=0.012,291            thickness=0.012,292        )293    )294    for side in (-1, 1):295        parts.append(296            sphere(297                f"Finella Bust {'L' if side < 0 else 'R'}",298                (side * 0.062, -0.052, 1.16),299                0.075,300                leather,301                scale=(1.0, 0.86, 0.72),302                segments=18,303                rings=12,304            )305        )306307    # Belt, buckle, pouches, and the sheaths at each hip.308    parts.append(torus("Finella Belt", (0, 0, 0.90), 0.158, 0.022, leather_light, major_segments=36))309    parts.append(box("Finella Buckle", (0, -0.137, 0.90), (0.065, 0.025, 0.055), gold))310    parts.append(box("Finella Buckle Inset", (0, -0.152, 0.90), (0.032, 0.012, 0.026), leather))311    for side, label in ((-1, "L"), (1, "R")):312        parts.append(313            sphere(314                f"Finella Pouch {label}",315                (side * 0.145, -0.085, 0.83),316                0.055,317                leather_light,318                scale=(0.85, 0.7, 1.0),319                segments=12,320                rings=8,321            )322        )323        sheath = box(324            f"Finella Sheath {label}",325            (side * 0.14, 0.02, 0.72),326            (0.035, 0.05, 0.24),327            leather_light,328            rotation=(0, side * 0.18, 0),329        )330        parts.append(sheath)331        parts.append(332            sphere(333                f"Finella Sheath Tip {label}",334                (side * 0.158, 0.02, 0.60),335                0.022,336                gold,337                segments=10,338                rings=8,339            )340        )341342    # Diagonal baldric with a gold clasp.343    parts.append(344        tube(345            "Finella Baldric",346            [347                (-0.155, -0.095, 1.275),348                (-0.045, -0.142, 1.17),349                (0.065, -0.136, 1.07),350                (0.155, -0.088, 0.98),351            ],352            [0.016, 0.015, 0.014, 0.013],353            leather_light,354            sides=6,355        )356    )357    parts.append(sphere("Finella Clasp", (0.02, -0.146, 1.115), 0.026, gold, segments=12, rings=8))358359    # One spiked shoulder guard on her leading side.360    parts.append(361        sphere(362            "Finella Shoulder Guard",363            (-0.205, -0.005, 1.265),364            0.095,365            leather_light,366            scale=(1.05, 1.15, 0.62),367            segments=18,368            rings=12,369        )370    )371    parts.append(372        limb(373            "Finella Shoulder Ridge",374            (-0.245, -0.005, 1.285),375            (-0.30, -0.005, 1.34),376            0.02,377            0.004,378            gold,379            vertices=6,380        )381    )382383    # The ragged cloak, its hood, and a draped cowl.384    parts.append(cape("Finella Cloak", cloth))385    cowl = revolve(386        "Finella Cowl",387        [(1.24, 0.178), (1.285, 0.162), (1.325, 0.132)],388        cloth,389        y_scale=0.9,390        thickness=0.012,391    )392    cowl.location.y = 0.012393    parts.append(cowl)394    parts.append(395        sculpted_head(396            "Finella Hood",397            (0, 0.012, 1.49),398            (0.13, 0.126, 0.148),399            cloth,400            jaw=0.0,401            cheek=0.0,402            brow=0.0,403            chin=0.0,404            edge=HOOD_EDGE,405            ripple=0.035,406            rings=20,407            sides=40,408        )409    )410    rim_points = []411    for index in range(10):412        phi = 2 * math.pi * index / 10413        theta = HOOD_EDGE(phi)414        rim_points.append(415            (416                0.13 * math.sin(theta) * math.cos(phi),417                0.012 + 0.126 * math.sin(theta) * math.sin(phi) - 0.004,418                1.49 + 0.148 * math.cos(theta),419            )420        )421    rim_points.append(rim_points[0])422    parts.append(423        tube(424            "Finella Hood Rim",425            rim_points,426            [0.008] * len(rim_points),427            cloth_deep,428            sides=5,429        )430    )431    parts.append(432        sphere("Finella Cloak Clasp", (0, 0.205, 1.275), 0.034, gold, scale=(1.5, 0.4, 1.0), segments=12, rings=8)433    )434435    # Neck and an angular, watchful face.436    parts.append(cylinder("Finella Neck", (0, 0, 1.345), 0.04, 0.11, skin, vertices=20))437    parts.append(sculpted_head("Finella Head", (0, -0.005, 1.485), (0.108, 0.106, 0.128), skin, rings=26, sides=40))438    for side in (-1, 1):439        parts.append(440            sphere(441                f"Finella Ear {'L' if side < 0 else 'R'}",442                (side * 0.11, -0.002, 1.465),443                0.028,444                skin,445                scale=(0.4, 0.78, 1.08),446                segments=12,447                rings=8,448            )449        )450451    for side in (-1, 1):452        label = "L" if side < 0 else "R"453        parts.append(454            sphere(455                f"Finella Sclera {label}",456                (side * 0.044, -0.111, 1.487),457                0.023,458                sclera,459                scale=(1.3, 0.5, 0.82),460                segments=16,461                rings=10,462            )463        )464        parts.append(465            sphere(466                f"Finella Iris {label}",467                (side * 0.044, -0.124, 1.487),468                0.013,469                iris,470                scale=(1.0, 0.35, 1.0),471                segments=14,472                rings=10,473            )474        )475        parts.append(476            sphere(477                f"Finella Pupil {label}",478                (side * 0.044, -0.129, 1.487),479                0.006,480                eye,481                scale=(1.0, 0.35, 1.0),482                segments=10,483                rings=8,484            )485        )486        parts.append(487            sphere(488                f"Finella Catchlight {label}",489                (side * 0.048, -0.132, 1.491),490                0.0028,491                gold,492                segments=8,493                rings=6,494            )495        )496        # Upper lid: a thin skin cap over the top of the eye that makes the gaze read.497        parts.append(498            sphere(499                f"Finella Eyelid {label}",500                (side * 0.044, -0.113, 1.5),501                0.0255,502                skin,503                scale=(1.45, 0.42, 0.46),504                segments=18,505                rings=10,506            )507        )508        parts.append(509            sphere(510                f"Finella Lash {label}",511                (side * 0.044, -0.121, 1.502),512                0.019,513                eye,514                scale=(1.3, 0.28, 0.2),515                segments=14,516                rings=8,517            )518        )519        parts.append(520            tube(521                f"Finella Brow {label}",522                [523                    (side * 0.016, -0.115, 1.521),524                    (side * 0.046, -0.121, 1.527),525                    (side * 0.077, -0.109, 1.515),526                ],527                [0.005, 0.0045, 0.0018],528                hair_shade,529                sides=5,530            )531        )532533    parts.append(534        tube(535            "Finella Nose",536            [(0, -0.105, 1.505), (0, -0.121, 1.473), (0, -0.128, 1.459)],537            [0.01, 0.008, 0.006],538            skin,539            sides=7,540        )541    )542    parts.append(sphere("Finella Nose Tip", (0, -0.13, 1.455), 0.013, skin, scale=(1.2, 0.9, 0.8), segments=12, rings=8))543    for side in (-1, 1):544        parts.append(545            sphere(546                f"Finella Upper Lip {'L' if side < 0 else 'R'}",547                (side * 0.009, -0.119, 1.421),548                0.0085,549                lips,550                scale=(1.0, 0.32, 0.34),551                segments=12,552                rings=8,553            )554        )555    parts.append(sphere("Finella Lower Lip", (0, -0.121, 1.413), 0.0125, lips, scale=(1.25, 0.38, 0.4), segments=14, rings=10))556557    # Hair under the hood: a crown, swept bangs, and a braid over one shoulder.558    # The hair shell covers the crown and back of the head and stops above the brow.559    parts.append(560        sculpted_head(561            "Finella Hair Crown",562            (0, 0.004, 1.49),563            (0.12, 0.114, 0.14),564            hair,565            jaw=0.0,566            cheek=0.0,567            brow=0.0,568            chin=0.0,569            edge=HAIR_EDGE,570            rings=18,571            sides=40,572        )573    )574    for side, label in ((-1, "L"), (1, "R")):575        parts.append(576            tube(577                f"Finella Bangs {label}",578                [579                    (side * 0.02, -0.09, 1.578),580                    (side * 0.06, -0.114, 1.545),581                    (side * 0.098, -0.104, 1.495),582                    (side * 0.12, -0.07, 1.435),583                ],584                [0.014, 0.013, 0.008, 0.002],585                hair,586                sides=6,587            )588        )589    # The braid falls over her left shoulder instead of crossing the chest like590    # a strap; it stays outside the cloak so the silhouette reads as hair.591    parts.append(592        tube(593            "Finella Braid",594            [595                (0.10, 0.01, 1.545),596                (0.145, -0.015, 1.47),597                (0.175, -0.045, 1.36),598                (0.19, -0.07, 1.24),599                (0.185, -0.085, 1.13),600                (0.17, -0.09, 1.04),601            ],602            [0.024, 0.022, 0.019, 0.015, 0.009, 0.003],603            hair_shade,604            sides=7,605        )606    )607    parts.append(torus("Finella Braid Band", (0.105, 0.005, 1.535), 0.026, 0.007, gold, major_segments=20))608609    # Arms: leading blade thrust forward, reverse grip trailing low.610    right = {611        "shoulder": (-0.20, -0.01, 1.25),612        "elbow": (-0.32, -0.15, 1.08),613        "hand": (-0.30, -0.36, 1.04),614    }615    left = {616        "shoulder": (0.20, 0.0, 1.25),617        "elbow": (0.33, 0.06, 1.03),618        "hand": (0.275, -0.075, 0.885),619    }620    for label, arm in (("R", right), ("L", left)):621        shoulder = Vector(arm["shoulder"])622        elbow = Vector(arm["elbow"])623        hand = Vector(arm["hand"])624        parts.append(625            capsule(f"Finella Upper Arm {label}", shoulder, elbow, 0.073, 0.05, leather, bulge=0.1, bulge_at=0.3)626        )627        parts.append(628            capsule(f"Finella Forearm {label}", elbow, hand, 0.05, 0.036, leather_light, bulge=0.08, bulge_at=0.25)629        )630        parts.append(631            sphere(632                f"Finella Hand {label}",633                tuple(hand),634                0.044,635                skin,636                scale=(1.1, 1.35, 0.7),637                segments=14,638                rings=10,639            )640        )641    parts.extend(642        dagger(643            "Finella Leading Dagger",644            right["hand"],645            (-0.36, -1.0, -0.16),646            0.46,647            steel=steel,648            gold=gold,649            grip=leather,650        )651    )652    parts.extend(653        dagger(654            "Finella Reverse Dagger",655            left["hand"],656            (0.16, -0.18, -1.0),657            0.4,658            steel=steel,659            gold=gold,660            grip=leather,661        )662    )663    for label, arm in (("R", right), ("L", left)):664        elbow = Vector(arm["elbow"])665        parts.append(666            tube(667                f"Finella Sleeve Tail {label}",668                [tuple(elbow), (elbow.x + (0.02 if label == "L" else -0.02), elbow.y + 0.04, elbow.z - 0.16)],669                [0.04, 0.006],670                cloth,671                sides=6,672            )673        )674675    # A few drops of blood-red light hang around the blades.676    for index, (x, y, z, size) in enumerate(677        [678            (-0.40, -0.56, 1.10, 0.013),679            (-0.28, -0.60, 0.99, 0.01),680            (-0.52, -0.46, 1.02, 0.009),681            (0.30, -0.13, 0.80, 0.011),682            (0.25, -0.16, 0.73, 0.008),683            (0.14, -0.20, 1.02, 0.007),684        ]685    ):686        parts.append(sphere(f"Finella Blood Mote {index + 1}", (x, y, z), size, blood, segments=10, rings=8))687688    for part in parts:689        if part.type == "MESH" and any(key in part.name for key in ORGANIC):690            subdivide(part, 1)691    return group(parts, "Finella")692693694def main(argv):695    parser = argparse.ArgumentParser()696    parser.add_argument("--out", required=True)697    args = parser.parse_args(argv)698    root = build()699    rig_character(root, "Finella")700    export_scene(args.out, animations=True)701702703if __name__ == "__main__":704    main(sys.argv[sys.argv.index("--") + 1 :] if "--" in sys.argv else [])