#pragma once

#include <Magnum/Math/Color.h>
#include <Magnum/Math/Range.h>
#include <Magnum/Math/Vector3.h>
#include <Magnum/Math/Quaternion.h>

#include <memory>
#include <string>
#include <vector>

namespace osim_viewer {

struct CpuMesh {
    struct Vertex {
        Magnum::Vector3 position;
        Magnum::Vector3 normal;
    };

    std::vector<Vertex> vertices;
    std::vector<Magnum::UnsignedInt> indices;
    Magnum::Range3D bounds;
};

struct GeometrySpec {
    std::shared_ptr<CpuMesh> mesh;
    Magnum::Vector3 scale{1.0f};
    Magnum::Color4 color{1.0f};
    std::string name;
};

struct FrameTrack {
    std::string name;
    std::vector<GeometrySpec> geometries;
    std::vector<Magnum::Vector3> translations;
    std::vector<Magnum::Quaternion> rotations;
};

struct MarkerTrack {
    std::string name;
    Magnum::Color4 color{1.0f};
    std::vector<Magnum::Vector3> positions;
};

struct LoadedScene {
    std::string modelName;
    std::string motionName;
    std::vector<float> times;
    std::vector<FrameTrack> frames;
    std::vector<MarkerTrack> markers;
    Magnum::Range3D initialBounds;
};

LoadedScene loadScene(const std::string& modelPath,
                      const std::string& motionPath,
                      const std::vector<std::string>& geometryDirs);

}
