feat(component): add CCharacterComponent::ComponentCloseFingers

This commit is contained in:
fallenoak 2025-11-03 20:35:39 -06:00
parent 9ef900f80f
commit 0c77e82e14
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
3 changed files with 25 additions and 4 deletions

View File

@ -200,12 +200,10 @@ void CCharacterComponent::AddLink(CM2Model* parent, GEOCOMPONENTLINKS link, char
parent->DetachAllChildrenById(link);
model->AttachToParent(parent, link, nullptr, 0);
// Add link point
if (link == ATTACH_HANDR) {
// TODO CCharacterComponent::AddLinkpt(parent, 0);
CCharacterComponent::ComponentCloseFingers(parent, HAND_RIGHT);
} else if (link == ATTACH_HANDL) {
// TODO CCharacterComponent::AddLinkpt(parent, 1);
CCharacterComponent::ComponentCloseFingers(parent, HAND_LEFT);
}
// Replace item particle color
@ -229,6 +227,23 @@ CCharacterComponent* CCharacterComponent::AllocComponent() {
return component;
}
void CCharacterComponent::ComponentCloseFingers(CM2Model* model, COMP_HAND_SLOT handSlot) {
uint32_t firstBone;
uint32_t lastBone;
if (handSlot == HAND_LEFT) {
firstBone = 13;
lastBone = 17;
} else {
firstBone = 8;
lastBone = 12;
}
for (uint32_t boneId = firstBone; boneId <= lastBone; boneId++) {
model->SetBoneSequence(boneId, 15, 0xFFFFFFFF, 0, 1.0f, 0, 1);
}
}
HTEXTURE CCharacterComponent::CreateTexture(const char* fileName, CStatus* status) {
auto texFlags = CGxTexFlags(GxTex_LinearMipNearest, 0, 0, 0, 0, 0, 1);
return TextureCreate(fileName, texFlags, status, 0);

View File

@ -50,6 +50,7 @@ class CCharacterComponent {
static int32_t AddHandItem(CM2Model* model, const ItemDisplayInfoRec* displayRec, INVENTORY_SLOTS invSlot, SHEATHE_TYPE sheatheType, bool sheathed, bool shield, bool a7, int32_t a8);
static void AddLink(CM2Model* parent, GEOCOMPONENTLINKS link, char const* modelPath, char const* texturePath, int32_t visualID, const ItemDisplayInfoRec* displayRec);
static CCharacterComponent* AllocComponent();
static void ComponentCloseFingers(CM2Model* model, COMP_HAND_SLOT handSlot);
static HTEXTURE CreateTexture(const char* fileName, CStatus* status);
static GEOCOMPONENTLINKS GetSheatheLink(SHEATHE_TYPE sheatheType, bool a2);
static void Initialize();

View File

@ -6,6 +6,11 @@
class CM2Model;
enum COMP_HAND_SLOT {
HAND_RIGHT = 0,
HAND_LEFT = 1,
};
enum COMPONENT_GEOSET {
GEOSET_HEAD = 0,
GEOSET_BEARD = 1,