EHS/include/io/model/Model.h

81 lines
1.4 KiB
C++

#pragma once
#include "EHS.h"
#include "Array.h"
#include "io/File.h"
#include "Mesh.h"
#include "Bone.h"
#include "Animation.h"
namespace ehs
{
enum class ModelEncoding : UInt_8
{
EHM
};
class Model : public Resource
{
protected:
Array<Mesh> meshes;
Bone skeleton;
Array<Animation> animations;
public:
Model();
Model(const Str_8& filePath);
Model(Str_8 id, Array<Mesh> meshes, Bone skeleton, Array<Animation> animations);
Model(Str_8 id, Array<Mesh> meshes, Bone skeleton);
Model(Str_8 id, Array<Mesh> meshes);
Model(Model&& model) noexcept;
Model(const Model& model) = default;
Model& operator=(Model&& model) noexcept;
Model& operator=(const Model& model) = default;
bool UploadToGpu(GpuCmdBuffer* cmdBuffer) override;
bool PostGpuUpload() override;
bool ReleaseFromGpu() override;
bool IsUploaded() const override;
void Draw(GpuCmdBuffer* cmdBuffer, const UInt_32 instances = 1);
Array<Mesh> GetMeshes() const;
Array<Mesh>& GetMeshes();
Mesh* GetMesh(const UInt_64 hashId);
Mesh* GetMesh(const Str_8& id);
Bone GetSkeleton() const;
Bone& GetSkeleton();
Animation* GetAnimation(const UInt_64 hashId);
Array<Animation> GetAnimations() const;
Array<Animation>& GetAnimations();
void Calculate();
void Export(const Str_8& filePath, const ModelEncoding encoding);
private:
void ToEHM(File& file);
void FromEHM(File& file);
};
}