#pragma once #include "client.h" namespace f4mp { class Player; class Animator { public: enum Type { Human }; struct Transform { zpl_vec3 position; zpl_quat rotation; float scale; }; struct Frame { float duration; std::vector transforms; }; struct Animation { bool loops; float duration; std::vector nodes; std::vector frames; Animation(float duration = 0.f); }; private: static std::vector> animatedNodes; static std::vector> animatedNodeIndices; static std::vector stateNames; static std::unordered_map stateIDs; static std::unordered_map animations; Type type; const Animation* animation; double startTime; public: Animator(Type type); void Play(const Animation* newAnimation); size_t GetAnimatedNodeCount() const; bool IsAnimatedNode(const std::string& nodeName) const; const std::string& GetNodeName(UInt32 nodeIndex) const; UInt32 GetNodeIndex(const std::string& nodeName) const; const Animation* GetAnimation() const; std::vector GetTransforms() const; bool ForEachNode(TESObjectREFR* ref, const std::function& callback); bool Save(const std::string& path, const Animation& animation, bool binary = true) const; Animation Load(const std::string& path) const; void OnClientUpdate(const Player& player); static void Init(); static Animation Load(const UCHAR data[]); static const std::string& GetStateName(SInt32 id); static SInt32 GetStateID(const std::string& name); static bool Loops(SInt32 id); }; }