mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-01 00:02:45 +03:00
feat(model): add CM2Model::GetAttachmentWorldTransform
This commit is contained in:
parent
9e4cdf4204
commit
f276902621
@ -731,6 +731,46 @@ LABEL_36:
|
||||
}
|
||||
}
|
||||
|
||||
C44Matrix CM2Model::GetAttachmentWorldTransform(uint32_t id) {
|
||||
if (!this->m_loaded) {
|
||||
this->WaitForLoad("GetAttachmentWorldTransform");
|
||||
}
|
||||
|
||||
auto& attachmentIndicesById = this->m_shared->m_data->attachmentIndicesById;
|
||||
auto& attachments = this->m_shared->m_data->attachments;
|
||||
|
||||
// Look up attachment index
|
||||
|
||||
uint16_t attachIndex = 0xFFFF;
|
||||
if (id < attachmentIndicesById.count) {
|
||||
attachIndex = attachmentIndicesById[id];
|
||||
}
|
||||
|
||||
// Look up bone index
|
||||
|
||||
uint16_t boneIndex = 0xFFFF;
|
||||
if (attachIndex < this->m_shared->m_data->attachments.count) {
|
||||
boneIndex = attachments[attachIndex].boneIndex;
|
||||
}
|
||||
|
||||
// Animate
|
||||
|
||||
this->Animate();
|
||||
|
||||
// Calculate attachment world transform
|
||||
|
||||
C44Matrix transform;
|
||||
|
||||
if (attachIndex == 0xFFFF) {
|
||||
transform = this->m_boneMatrices[0];
|
||||
} else {
|
||||
transform = this->m_boneMatrices[boneIndex];
|
||||
transform.Translate(attachments[attachIndex].position);
|
||||
}
|
||||
|
||||
return transform * this->m_scene->m_viewInv;
|
||||
}
|
||||
|
||||
CAaBox& CM2Model::GetBoundingBox(CAaBox& bounds) {
|
||||
// TODO
|
||||
// WaitForLoad
|
||||
|
||||
@ -147,6 +147,7 @@ class CM2Model {
|
||||
void DetachFromParent();
|
||||
void DetachFromScene();
|
||||
void FindKey(M2ModelBoneSeq* sequence, const M2TrackBase& track, uint32_t& currentKey, uint32_t& nextKey, float& ratio);
|
||||
C44Matrix GetAttachmentWorldTransform(uint32_t id);
|
||||
CAaBox& GetBoundingBox(CAaBox& bounds);
|
||||
HCAMERA GetCameraByIndex(uint32_t index);
|
||||
C3Vector GetPosition();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user