#pragma once #include "Log.hpp" #include #include #include #include #include #include #include #include #include #include #include #include #include #include extern "C" { #include "FlutterFilamentApi.h" } template class std::vector; namespace polyvox { using namespace filament; using namespace filament::gltfio; using namespace utils; using namespace std; typedef std::chrono::time_point time_point_t; enum AnimationType { MORPH, BONE, GLTF }; struct AnimationStatus { time_point_t start = time_point_t::max(); bool loop = false; bool reverse = false; float durationInSecs = 0; }; struct GltfAnimation : AnimationStatus { int index = -1; }; // // Use this to construct a dynamic (i.e. non-glTF embedded) morph target animation. // struct MorphAnimation : AnimationStatus { utils::Entity meshTarget; int numFrames = -1; float frameLengthInMs = 0; vector frameData; vector morphIndices; int lengthInFrames; }; // // Use this to construct a dynamic (i.e. non-glTF embedded) bone/joint animation. // struct BoneAnimation : AnimationStatus { size_t boneIndex; vector meshTargets; size_t skinIndex = 0; int lengthInFrames; float frameLengthInMs = 0; vector frameData; }; struct SceneAsset { FilamentAsset* asset = nullptr; vector initialJointTransforms; vector gltfAnimations; vector morphAnimations; vector boneAnimations; // the index of the last active glTF animation, // used to cross-fade int fadeGltfAnimationIndex = -1; float fadeDuration = 0.0f; float fadeOutAnimationStart = 0.0f; // a slot to preload textures filament::Texture* texture = nullptr; // initialized to identity math::mat4f position; // initialized to identity math::mat4f rotation; float mScale = 1; SceneAsset( FilamentAsset* asset ) : asset(asset) {} }; }