Files
HelloVulkan/Engine/include/Engine/Animation/HumanoidRig.h
T
atdunbg cc837bc605 Add animation controller system, material assets and skeleton visualization
- .animctrl state machine asset (params/transitions/blend trees, 1D+2D
  directional blending) with Unity Animator-style editor panel: state
  list, transitions, params, directional pad preview driving live
  CrossFade on the selected entity
- Split animation evaluation out of SceneRenderer into
  AnimationSystem/AnimationEvaluator; skin palettes with rest-pose
  fallback and blend-weight epsilon filtering
- MaterialAsset (.material) with reload-safe preview tile pool
  (DropMaterial clears dirty refs before instance destruction)
- EditorGizmoPass skeleton wires + viewport joint overlay; camera
  projection rework (baked Vulkan Y-flip, ortho support)
- Editor/game build split via HELLOVULKAN_EDITOR option
2026-10-07 01:50:04 +08:00

72 lines
2.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//
// HumanoidRig:Unity Avatar 语义的跨骨架重定向映射。
//
// 资产组装现实:角色模型与动画 clip 是两套独立资产,骨骼命名完全
// 不同源(英文/Mixamo/UE/Blender/MMD 日文)。Unity Humanoid 的解法
// 是把任意命名骨架映射到标准人形槽位(Avatar bone mapping),动画
// 经槽位转换后即可驱动任意人形角色。
//
// 这里实现其中枢:名字归一化 → 槽位识别(关键词表,en/Mixamo/MMD)
// → 源/目标骨架间生成 node 下标映射对。同名直映是映射的特例。
//
#ifndef HELLOVULKAN_HUMANOIDRIG_H
#define HELLOVULKAN_HUMANOIDRIG_H
#include <Engine/Core/Types.h>
#include <Engine/Renderer/Model.h>
#include <string_view>
#include <utility>
#include <vector>
namespace Engine::Animation {
// 标准人形槽位(最小主干集,不含手指/表情——主干驱动即可行走)
enum class HumanoidSlot : u32 {
Hips = 0,
Spine,
Chest,
UpperChest,
Neck,
Head,
LeftShoulder,
LeftUpperArm,
LeftLowerArm,
LeftHand,
RightShoulder,
RightUpperArm,
RightLowerArm,
RightHand,
LeftUpperLeg,
LeftLowerLeg,
LeftFoot,
RightUpperLeg,
RightLowerLeg,
RightFoot,
Count
};
// 槽位侧别(左右对称骨骼的识别结果)
enum class Side : u8 { None, Left, Right };
// 槽位显示名("Hips"/"LeftUpperArm"...;调试映射表用)
const char* HumanoidSlotName(HumanoidSlot slot);
// 名字归一化 + 槽位识别。
// "mixamorig:LeftForeArm" → {LowerArm, Left};"左ひじ" → {LowerArm, Left};
// "Upper Arm_L" → {UpperArm, Left}。识别失败 ok=false。
HumanoidSlot MatchHumanoidSlot(std::string_view name, Side& side,
bool& ok);
// 跨骨架自动映射:返回 (srcNodeIdx, dstNodeIdx) 对列表。
// 同名 node 直映优先(同源拆分资产零损耗),余下按槽位匹配;
// 一槽多候选时取语义关键词优先级表中的顺序(先高后低)。
std::vector<std::pair<u32, u32>> AutoMapHumanoid(
const std::vector<ModelNode>& srcNodes,
const std::vector<ModelNode>& dstNodes);
} // namespace Engine::Animation
#endif // HELLOVULKAN_HUMANOIDRIG_H