fix morph animations

This commit is contained in:
Nick Fisher
2023-04-19 22:10:51 +08:00
parent a162ff2400
commit dd01249547
6 changed files with 237 additions and 174 deletions

View File

@@ -75,8 +75,9 @@ namespace polyvox {
MaterialProvider* _ubershaderProvider = nullptr;
gltfio::ResourceLoader* _gltfResourceLoader = nullptr;
gltfio::TextureProvider* _stbDecoder = nullptr;
tsl::robin_map<EntityId, SceneAsset> _assets;
vector<SceneAsset> _assets;
tsl::robin_map<EntityId, int> _entityIdLookup;
void setBoneTransform(
FilamentInstance* instance,
vector<BoneAnimationData> animations,

View File

@@ -1,5 +1,7 @@
#pragma once
#include "Log.hpp"
#include <filament/Engine.h>
#include <filament/RenderableManager.h>
#include <filament/Renderer.h>
@@ -36,9 +38,38 @@ namespace polyvox {
bool mReverse = false;
float mDuration = 0;
int mFrameNumber = -1;
// AnimationStatus() {
// Log("default constr");
// }
// AnimationStatus(AnimationStatus& a) {
// mStart = a.mStart;
// mLoop = a.mLoop;
// mReverse = a.mReverse;
// mDuration = a.mDuration;
// mFrameNumber = a.mFrameNumber;
// }
// AnimationStatus& operator=(AnimationStatus a) {
// mStart = a.mStart;
// mLoop = a.mLoop;
// mReverse = a.mReverse;
// mDuration = a.mDuration;
// mFrameNumber = a.mFrameNumber;
// return *this;
// }
// AnimationStatus(AnimationStatus&& a) {
// mStart = a.mStart;
// mLoop = a.mLoop;
// mReverse = a.mReverse;
// mDuration = a.mDuration;
// mFrameNumber = a.mFrameNumber;
// }
};
//
//
// Use this to manually construct a buffer of frame data for morph animations.
//
struct MorphAnimationBuffer {
@@ -70,13 +101,10 @@ namespace polyvox {
};
struct SceneAsset {
bool mAnimating = false;
FilamentAsset* mAsset = nullptr;
Animator* mAnimator = nullptr;
// animation flags;
bool mAnimating = false;
// fixed-sized vector containing the status of the morph, bone and GLTF animations.
// entries 0 and 1 are the morph/bone animations.
// subsequent entries are the GLTF animations.
@@ -96,10 +124,40 @@ namespace polyvox {
float mScale = 1;
// SceneAsset(const SceneAsset&& a) {
// Log("MOVE");
// }
// SceneAsset(const SceneAsset& a) {
// mAsset = a.mAsset;
// mAnimator = a.mAnimator;
// mAnimations = a.mAnimations;
// mMorphAnimationBuffer = a.mMorphAnimationBuffer;
// mBoneAnimationBuffer = a.mBoneAnimationBuffer;
// mTexture = a.mTexture;
// mPosition = a.mPosition;
// mRotation = a.mRotation;
// mScale = a.mScale;
// }
// SceneAsset& operator=(SceneAsset a) {
// mAsset = a.mAsset;
// mAnimator = a.mAnimator;
// mAnimations = a.mAnimations;
// mMorphAnimationBuffer = a.mMorphAnimationBuffer;
// mBoneAnimationBuffer = a.mBoneAnimationBuffer;
// mTexture = a.mTexture;
// mPosition = a.mPosition;
// mRotation = a.mRotation;
// mScale = a.mScale;
// return *this;
// }
SceneAsset(
FilamentAsset* asset
) : mAsset(asset) {
mAnimator = mAsset->getInstance()->getAnimator();
mAnimations.resize(2 + mAnimator->getAnimationCount());