#pragma once #include #include #include #include #include #include #include using glm::quat; using glm::vec3; using glm::vec4; struct AnimationKeyPosition { vec3 pos; float time; }; struct AnimationKeyRotation { quat rot; float time; }; struct AnimationKeyScale { vec3 scale; float time; }; struct AnimationChannel { std::vector pos; std::vector rot; std::vector scale; }; #define MAX_MORPH_WEIGHTS 8 #define MAX_MORPHS 100 struct MorphingChannelKey { float time = 0.0f; uint32_t mesh[MAX_MORPH_WEIGHTS] = { 0, 0, 0, 0, 0, 0, 0, 0 }; float weight[MAX_MORPH_WEIGHTS] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; }; struct MorphingChannel { std::string name; std::vector key; }; struct Animation { std::unordered_map channels; std::vector morphChannels; float duration; // In seconds float ticksPerSecond; std::string name; }; struct MorphState { uint32_t meshId = ~0u; uint32_t morphTarget[MAX_MORPH_WEIGHTS] = { 0, 0, 0, 0, 0, 0, 0, 0 }; float weights[MAX_MORPH_WEIGHTS] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; }; struct AnimationState { uint32_t animId = ~0u; float currentTime = 0.0f; bool playOnce = false; bool active = false; }; struct GLTFContext; struct aiScene; void initAnimations(GLTFContext& glTF, const aiScene* scene); void updateAnimation(GLTFContext& glTF, AnimationState& anim, float dt); void updateAnimationBlending(GLTFContext& glTF, AnimationState& anim1, AnimationState& anim2, float weight, float dt);