Files
Mrpzx 977f97995a tripocli v2.0.0:Tripo AI 3D 生成与加工 CLI(面向 Agent 与开发者,纯 Python 标准库、零第三方依赖)
覆盖文生 3D、图生 3D、多视图、批量生成,以及重拓扑、绑定、动画、智能分割、
纹理、PBR、智能 UV、部件补全、格式导出与下载。

代码组织:一个功能一个模块(tripo/features/),入口薄壳 tripocli.py。
2026-10-13 19:22:54 +08:00

81 lines
2.8 KiB
Python

"""绑定 — auto rigging with UniRig.
tripocli rig -p <project_id> --type biped --spec mixamo --wait
A riggable check runs first (``pre_rig_check``); the model must be a humanoid in
T/A pose for good results. Verified body of ``rigging_model``:
``{project_id, model_version, rig_type, spec}``.
骨骼预设(界面 5 个选项 → API 的 spec 值,取自 studio 前端数据表,并用实测请求核对):
``Mixamo → mixamo``、``ActorCore → actorcore``、``UE5 Mannequin → unreal``、
``Unity Humanoid Compatible → unity``、``VRM 1.0 Humanoid → vrm``。
"""
from . import _common
NAME = "rig"
HELP = "自动绑定骨骼(人形/其他 + 5 种骨骼预设)"
RIG_TYPES = ("biped", "others")
# 界面预设名 → API spec 值
SPEC_ALIASES = {
"mixamo": "mixamo",
"actorcore": "actorcore",
"actor_core": "actorcore",
"unreal": "unreal",
"ue5": "unreal",
"ue5-mannequin": "unreal",
"ue5_mannequin": "unreal",
"unity": "unity",
"unity-humanoid": "unity",
"vrm": "vrm",
"vrm1": "vrm",
}
DEFAULT_SPEC = "mixamo"
def resolve_spec(name):
if not name:
return DEFAULT_SPEC
return SPEC_ALIASES.get(name.strip().lower(), name.strip())
def add_arguments(parser):
_common.add_op_options(parser, "绑定完成后保存到该路径(可选)")
parser.add_argument("--type", default="biped", choices=RIG_TYPES, help="绑定类型:biped=人形,others=其他")
parser.add_argument(
"--spec", default=DEFAULT_SPEC,
help="骨骼预设: mixamo(默认) / actorcore / unreal(UE5 Mannequin) / unity / vrm",
)
parser.add_argument("--check-only", action="store_true", help="只做绑定前检查,不执行绑定")
def run(ctx):
args = ctx.args
model_version = _common.project_version(ctx.client, args.project, args.model)
spec = resolve_spec(args.spec)
check_body = {"project_id": args.project}
if model_version:
check_body["model_version"] = model_version
check = ctx.client.get_data("POST", "/v2/studio/operation/pre_rig_check", body=check_body) or {}
if args.check_only:
ctx.out.data(
check,
human=lambda: (
ctx.out.line(f"可绑定: {check.get('riggable')}"),
ctx.out.line(f"绑定类型: {check.get('rig_type')}"),
),
)
return check
ctx.out.line(f"🔎 绑定前检查: riggable={check.get('riggable')} type={check.get('rig_type')}")
body = {"project_id": args.project, "rig_type": args.type, "spec": spec}
if model_version:
body["model_version"] = model_version
data = ctx.client.get_data("POST", "/v2/studio/operation/rigging_model", body=body)
return _common.run_operator(ctx, data, output=args.output, wait=args.wait, label="绑定")