// vulkan_engine.h : Include file for standard system include files, // or project specific include files. #pragma once #include #include "core/vk_descriptors.h" #include #include class VulkanEngine; struct Bounds { glm::vec3 origin; float sphereRadius; glm::vec3 extents; }; struct GLTFMaterial { MaterialInstance data; }; struct GeoSurface { uint32_t startIndex; uint32_t count; Bounds bounds; std::shared_ptr material; }; struct MeshAsset { std::string name; std::vector surfaces; GPUMeshBuffers meshBuffers; }; struct LoadedGLTF : public IRenderable { // storage for all the data on a given gltf file std::unordered_map > meshes; std::unordered_map > nodes; std::unordered_map images; std::unordered_map > materials; // nodes that dont have a parent, for iterating through the file in tree order std::vector > topNodes; std::vector samplers; DescriptorAllocatorGrowable descriptorPool; AllocatedBuffer materialDataBuffer; VulkanEngine *creator; struct AnimationChannel { enum class Target { Translation, Rotation, Scale }; enum class Interpolation { Linear, Step }; Target target = Target::Translation; Interpolation interpolation = Interpolation::Linear; std::shared_ptr node; std::vector times; std::vector vec3Values; // translation / scale std::vector vec4Values; // rotation (x,y,z,w) }; struct Animation { std::string name; float duration = 0.f; std::vector channels; }; std::vector animations; int activeAnimation = -1; float animationTime = 0.f; bool animationLoop = true; // Optional debug name (e.g., key used when loaded into SceneManager) std::string debugName; // Animation helpers void updateAnimation(float dt); void refreshAllTransforms(); std::shared_ptr getNode(const std::string &name); void setActiveAnimation(int index, bool resetTime = true); void setActiveAnimation(const std::string &name, bool resetTime = true); ~LoadedGLTF() { clearAll(); }; void clearMeshes(){ clearAll(); }; virtual void Draw(const glm::mat4 &topMatrix, DrawContext &ctx); private: void clearAll(); }; std::optional > loadGltf(VulkanEngine *engine, std::string_view filePath);