mirror of https://github.com/AxioDL/metaforce.git
CFlyingPirateRagDoll: Implement PreRender, Prime
This commit is contained in:
parent
57386e6269
commit
932615593e
|
@ -13,16 +13,18 @@ class CLayoutDescription;
|
||||||
class CPoseAsTransforms;
|
class CPoseAsTransforms;
|
||||||
|
|
||||||
class CHierarchyPoseBuilder {
|
class CHierarchyPoseBuilder {
|
||||||
CLayoutDescription x0_layoutDesc;
|
public:
|
||||||
CSegId x30_rootId;
|
|
||||||
bool x34_hasRoot = false;
|
|
||||||
|
|
||||||
struct CTreeNode {
|
struct CTreeNode {
|
||||||
CSegId x0_child = 0;
|
CSegId x0_child = 0;
|
||||||
CSegId x1_sibling = 0;
|
CSegId x1_sibling = 0;
|
||||||
zeus::CQuaternion x4_rotation;
|
zeus::CQuaternion x4_rotation;
|
||||||
zeus::CVector3f x14_offset;
|
zeus::CVector3f x14_offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
CLayoutDescription x0_layoutDesc;
|
||||||
|
CSegId x30_rootId;
|
||||||
|
bool x34_hasRoot = false;
|
||||||
TSegIdMap<CTreeNode> x38_treeMap;
|
TSegIdMap<CTreeNode> x38_treeMap;
|
||||||
|
|
||||||
void BuildIntoHierarchy(const CCharLayoutInfo& layout, const CSegId& boneId, const CSegId& nullId);
|
void BuildIntoHierarchy(const CCharLayoutInfo& layout, const CSegId& boneId, const CSegId& nullId);
|
||||||
|
|
|
@ -167,13 +167,50 @@ CFlyingPirate::CFlyingPirateRagDoll::CFlyingPirateRagDoll(CStateManager& mgr, CF
|
||||||
AddJointConstraint(5, 2, 8, 5, 6, 7);
|
AddJointConstraint(5, 2, 8, 5, 6, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFlyingPirate::CFlyingPirateRagDoll::PreRender(const zeus::CVector3f& pos, CModelData& mData) {
|
void CFlyingPirate::CFlyingPirateRagDoll::PreRender(const zeus::CVector3f& v, CModelData& mData) {
|
||||||
// TODO
|
if (!x68_25_over) {
|
||||||
CRagDoll::PreRender(pos, mData);
|
CAnimData* const animData = mData.GetAnimationData();
|
||||||
|
const CCharLayoutInfo& layout = animData->GetCharLayoutInfo();
|
||||||
|
CHierarchyPoseBuilder& poseBuilder = animData->PoseBuilder();
|
||||||
|
for (const auto& id : layout.GetSegIdList().GetList()) {
|
||||||
|
if (layout.GetRootNode()->GetBoneMap()[id].x10_children.size() > 1) {
|
||||||
|
poseBuilder.GetTreeMap()[id].x4_rotation = zeus::CQuaternion();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CHierarchyPoseBuilder::CTreeNode& skeletonRoot =
|
||||||
|
poseBuilder.GetTreeMap()[animData->GetLocatorSegId("Skeleton_Root"sv)];
|
||||||
|
const zeus::CVector3f& rHipPos = x4_particles[8].GetPosition(); // R_hip
|
||||||
|
const zeus::CVector3f& lHipPos = x4_particles[11].GetPosition(); // L_hip
|
||||||
|
const zeus::CVector3f& rShoulderPos = x4_particles[2].GetPosition(); // R_shoulder
|
||||||
|
const zeus::CVector3f& lShoulderPos = x4_particles[5].GetPosition(); // L_shoulder
|
||||||
|
const zeus::CVector3f& collarPos = x4_particles[0].GetPosition(); // Collar
|
||||||
|
skeletonRoot.x14_offset = (0.5f * (rHipPos + lHipPos) - v) / mData.GetScale();
|
||||||
|
|
||||||
|
const zeus::CVector3f& rootRight = rShoulderPos - lShoulderPos;
|
||||||
|
const zeus::CVector3f& rootUp = (collarPos - (rHipPos + lHipPos) * 0.5f).normalized();
|
||||||
|
const zeus::CVector3f& rootFore = rootUp.cross(rootRight).normalized();
|
||||||
|
const zeus::CQuaternion& rootRot = zeus::CMatrix3f(rootFore.cross(rootUp), rootFore, rootUp);
|
||||||
|
skeletonRoot.x4_rotation = rootRot;
|
||||||
|
|
||||||
|
const CRagDollParticle& head = x4_particles[1]; // Head_1
|
||||||
|
const zeus::CVector3f& neckRestVec = layout.GetFromParentUnrotated(head.GetBone());
|
||||||
|
poseBuilder.GetTreeMap()[head.GetBone()].x4_rotation = zeus::CQuaternion::shortestRotationArc(
|
||||||
|
neckRestVec, rootRot.inverse().transform(head.GetPosition() - collarPos));
|
||||||
|
|
||||||
|
BoneAlign(poseBuilder, layout, 3, 4, rootRot * BoneAlign(poseBuilder, layout, 2, 3, rootRot));
|
||||||
|
BoneAlign(poseBuilder, layout, 6, 7, rootRot * BoneAlign(poseBuilder, layout, 5, 6, rootRot));
|
||||||
|
BoneAlign(poseBuilder, layout, 9, 10, rootRot * BoneAlign(poseBuilder, layout, 8, 9, rootRot));
|
||||||
|
BoneAlign(poseBuilder, layout, 12, 13, rootRot * BoneAlign(poseBuilder, layout, 11, 12, rootRot));
|
||||||
|
|
||||||
|
animData->MarkPoseDirty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFlyingPirate::CFlyingPirateRagDoll::Prime(CStateManager& mgr, const zeus::CTransform& xf, CModelData& mData) {
|
void CFlyingPirate::CFlyingPirateRagDoll::Prime(CStateManager& mgr, const zeus::CTransform& xf, CModelData& mData) {
|
||||||
// TODO
|
if (x6c_actor->x6a1_30_) {
|
||||||
|
xa0_ = CSfxManager::AddEmitter(x9c_, x6c_actor->GetTranslation(), zeus::skZero3f, true, true, 0x7f, kInvalidAreaId);
|
||||||
|
}
|
||||||
CRagDoll::Prime(mgr, xf, mData);
|
CRagDoll::Prime(mgr, xf, mData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,14 +61,14 @@ private:
|
||||||
float x8c_ = 0.f;
|
float x8c_ = 0.f;
|
||||||
zeus::CVector3f x90_ = zeus::skZero3f;
|
zeus::CVector3f x90_ = zeus::skZero3f;
|
||||||
u16 x9c_;
|
u16 x9c_;
|
||||||
int xa0_ = 0;
|
CSfxHandle xa0_;
|
||||||
zeus::CVector3f xa4_;
|
zeus::CVector3f xa4_;
|
||||||
bool xb0_24_ : 1;
|
bool xb0_24_ : 1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CFlyingPirateRagDoll(CStateManager& mgr, CFlyingPirate* actor, u16 w1, u16 w2);
|
CFlyingPirateRagDoll(CStateManager& mgr, CFlyingPirate* actor, u16 w1, u16 w2);
|
||||||
|
|
||||||
void PreRender(const zeus::CVector3f& pos, CModelData& mData) override;
|
void PreRender(const zeus::CVector3f& v, CModelData& mData) override;
|
||||||
void Prime(CStateManager& mgr, const zeus::CTransform& xf, CModelData& mData) override;
|
void Prime(CStateManager& mgr, const zeus::CTransform& xf, CModelData& mData) override;
|
||||||
void Update(CStateManager& mgr, float dt, float waterTop) override;
|
void Update(CStateManager& mgr, float dt, float waterTop) override;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue