Fixup skeletal animation and armatures

This commit is contained in:
James Lambert 2022-08-08 22:08:00 -06:00
parent 0fafeee5b0
commit c8c56abdb5
5 changed files with 14 additions and 5 deletions

View file

@ -1 +1 @@
-r 0,0,0 -m assets/materials/static.skm.yaml -m assets/materials/elevator.skm.yaml --default-material default
-r 90,0,0 -m assets/materials/static.skm.yaml -m assets/materials/elevator.skm.yaml --default-material default

View file

@ -94,6 +94,8 @@ int Bone::GetBoneIndex(Bone* a) {
}
void BoneHierarchy::PopulateWithAnimationNodeInfo(const NodeAnimationInfo& animInfo, float fixedPointScale, aiQuaternion& rotation) {
aiMatrix4x4 rotationMatrix(rotation.GetMatrix());
for (auto& node : animInfo.nodesWithAnimation) {
Bone* parent = nullptr;
@ -113,6 +115,10 @@ void BoneHierarchy::PopulateWithAnimationNodeInfo(const NodeAnimationInfo& animI
aiMatrix4x4 fullRestTransform = node->relativeTransform * node->node->mTransformation;
if (parent == nullptr) {
fullRestTransform = rotationMatrix * fullRestTransform;
}
fullRestTransform.Decompose(restScale, restRotation, restPosition);
mBones.push_back(std::unique_ptr<Bone>(new Bone(

View file

@ -53,6 +53,9 @@ unsigned convertByteRange(float value) {
ErrorResult VertexBufferDefinition::Generate(float fixedPointScale, float modelScale, aiQuaternion rotate, std::unique_ptr<FileDefinition>& output, const std::string& fileSuffix) {
std::unique_ptr<StructureDataChunk> dataChunk(new StructureDataChunk());
// aiQuaternion rotateInverse = rotate;
// rotateInverse.Conjugate();
for (unsigned int i = 0; i < mTargetMesh->mMesh->mNumVertices; ++i) {
std::unique_ptr<StructureDataChunk> vertexWrapper(new StructureDataChunk());

View file

@ -34,8 +34,8 @@ struct Vector3 gClosedPosition[] = {
struct Vector3 gOpenPosition[] = {
[PROPS_ROUND_ELEVATOR_ELEVATOR_BONE] = {0, 0, 0},
[PROPS_ROUND_ELEVATOR_DOORLEFT_BONE] = {1.188716 * SCENE_SCALE, 0.653916 * SCENE_SCALE, 0.0f},
[PROPS_ROUND_ELEVATOR_DOORRIGHT_BONE] = {1.188716 * SCENE_SCALE, -0.653916 * SCENE_SCALE, 0.0f},
[PROPS_ROUND_ELEVATOR_DOORLEFT_BONE] = {1.188716 * SCENE_SCALE, 0.0f, 0.653916 * SCENE_SCALE},
[PROPS_ROUND_ELEVATOR_DOORRIGHT_BONE] = {1.188716 * SCENE_SCALE, 0.0f, -0.653916 * SCENE_SCALE},
};
void elevatorRender(void* data, struct RenderScene* renderScene) {

View file

@ -87,9 +87,9 @@ void pedestalUpdate(struct Pedestal* pedestal) {
if (vector2RotateTowards(&pedestal->currentRotation, &target, &gMaxPedistalRotation, &pedestal->currentRotation)) {
pedestal->flags &= ~PedestalFlagsIsPointing;
}
quatAxisComplex(&gUp, &pedestal->currentRotation, &pedestal->armature.boneTransforms[PEDESTAL_HOLDER_BONE].rotation);
}
quatAxisComplex(&gUp, &pedestal->currentRotation, &pedestal->armature.boneTransforms[PEDESTAL_HOLDER_BONE].rotation);
}
void pedestalHide(struct Pedestal* pedestal) {