80 lines
1.5 KiB
C++
80 lines
1.5 KiB
C++
#ifndef MODEL_H
|
|
#define MODEL_H
|
|
|
|
#include <vector>
|
|
|
|
#include "boundingbox.h"
|
|
#include "render_shared.h"
|
|
#include "animation.h"
|
|
|
|
#include <glm/glm.hpp>
|
|
#include <glm/gtc/type_ptr.hpp>
|
|
|
|
class GPUBuffer;
|
|
class Texture2D;
|
|
|
|
struct ModelData_t
|
|
{
|
|
Texture2D* m_AlbedoTexture;
|
|
GPUBuffer* vb;
|
|
GPUBuffer* ib;
|
|
uint32_t vbcount;
|
|
uint32_t ibcount;
|
|
};
|
|
|
|
void ReleaseModelData(ModelData_t& data);
|
|
|
|
class Render;
|
|
|
|
class Model
|
|
{
|
|
friend class Render;
|
|
public:
|
|
Model();
|
|
~Model();
|
|
|
|
void LoadIqm(const char* filename);
|
|
void LoadObj(const char* filename);
|
|
Texture2D* LoadMtl(const char* filename);
|
|
|
|
void Draw(const glm::mat4& model, SkeletonInstance* instance = nullptr);
|
|
|
|
const BoundingBox& GetBoundingBox() { return m_boundingBox; }
|
|
|
|
// Animation
|
|
AnimationId_t FindAnimation(const char* name);
|
|
uint32_t GetNumAnimations();
|
|
|
|
const Animation* GetAnimation(AnimationId_t index);
|
|
|
|
int GetNumPoses();
|
|
|
|
SkeletonInstance* CreateSkeletonInstance();
|
|
void UpdateSkeletonInstance(SkeletonInstance* instance, float dt);
|
|
|
|
// void PlayAnimation(AnimationId_t id, bool looped);
|
|
// void StopAnimation();
|
|
|
|
private:
|
|
std::vector<Joint> m_joints;
|
|
std::vector<Joint> m_basePose;
|
|
std::vector<glm::mat4> m_inverseBasePose;
|
|
std::vector<glm::mat4> m_jointMatrices;
|
|
std::vector<glm::mat4> m_finalMatrices;
|
|
|
|
std::vector<Animation> m_animations;
|
|
|
|
std::vector<StaticMeshVertex> m_Vertices;
|
|
|
|
|
|
std::vector<ModelData_t> m_meshes;
|
|
|
|
BoundingBox m_boundingBox;
|
|
|
|
int m_numPoses;
|
|
|
|
bool m_iqm;
|
|
};
|
|
|
|
#endif // !MODEL_H
|