Polyphase Game Engine
Loading...
Searching...
No Matches
HumanoidAvatarAsset.h
Go to the documentation of this file.
1#pragma once
2
3#include "Asset.h"
4#include "AssetRef.h"
5#include "Factory.h"
6
7#include <string>
8#include <vector>
9
10class SkeletalMesh;
11
12// Standard humanoid bone slots. Matches Unity's small-set Humanoid avatar.
13// Additions go at the end so older HumanoidAvatarAssets keep loading; the
14// SaveStream/LoadStream version-gate handles size changes.
41
43
45{
46public:
47
49
52
53 virtual void LoadStream(Stream& stream, Platform platform) override;
54 virtual void SaveStream(Stream& stream, Platform platform) override;
55 virtual void Create() override;
56 virtual void Destroy() override;
57
58 virtual void GatherProperties(std::vector<Property>& outProps) override;
59 virtual glm::vec4 GetTypeColor() override;
60 virtual const char* GetTypeName() override;
61
62 // The SkeletalMesh this avatar describes. Optional — clips can be retargeted
63 // without a reference mesh if both source and target avatars are filled in
64 // by hand, but having a mesh lets the editor "Auto-map" button do its job
65 // and lets PR5's retarget bake read reference-pose matrices.
66 SkeletalMesh* GetReferenceMesh() const;
67 void SetReferenceMesh(SkeletalMesh* mesh);
68
69 const std::string& GetBoneName(HumanoidBone slot) const;
70 void SetBoneName(HumanoidBone slot, const std::string& boneName);
71
72 // Try to fill empty slots from the reference mesh's bones by matching the
73 // built-in alias tables (Mixamo, ARP, common defaults). Existing non-empty
74 // mappings are left alone unless overwriteAll is true. Returns the number
75 // of slots that were filled.
76 uint32_t AutoMap(bool overwriteAll = false);
77
78 // Convenience: validate that every slot maps to a bone present in the
79 // reference mesh. Fills outMissing / outUnknownBones for editor display.
80 bool Validate(std::vector<HumanoidBone>* outMissing,
81 std::vector<std::string>* outUnknownBones) const;
82
83 // Reference (bind-pose) local transform for the given humanoid slot,
84 // sampled from the reference mesh. Identity when the slot is unmapped
85 // or there is no reference mesh.
86 glm::mat4 GetReferenceLocalBind(HumanoidBone slot) const;
87
88protected:
89
91 std::vector<std::string> mBoneNames; // size == HumanoidBone::Count
92};
Platform
Definition EngineTypes.h:31
POLYPHASE_API const char * HumanoidBoneName(HumanoidBone bone)
Definition HumanoidAvatarAsset.cpp:163
HumanoidBone
Definition HumanoidAvatarAsset.h:16
#define POLYPHASE_API
Definition PolyphaseAPI.h:31
Definition AssetRef.h:18
Definition Asset.h:119
virtual void Create()
Definition Asset.cpp:77
virtual void SaveStream(Stream &stream, Platform platform)
Definition Asset.cpp:284
virtual glm::vec4 GetTypeColor()
Definition Asset.cpp:302
virtual const char * GetTypeName()
Definition Asset.cpp:307
virtual void GatherProperties(std::vector< Property > &outProps) override
Definition Asset.cpp:297
virtual void LoadStream(Stream &stream, Platform platform)
Definition Asset.cpp:270
virtual void Destroy()
Definition Asset.cpp:92
Definition HumanoidAvatarAsset.h:45
DECLARE_ASSET(HumanoidAvatarAsset, Asset)
SkeletalMeshRef mReferenceMesh
Definition HumanoidAvatarAsset.h:90
std::vector< std::string > mBoneNames
Definition HumanoidAvatarAsset.h:91
Definition SkeletalMesh.h:99
Definition Stream.h:21