#pragma once #include "Deer/Components.h" #include "DeerRender/Mesh.h" #include "DeerRender/Shader.h" #define GLM_ENABLE_EXPERIMENTAL #include "glm/gtc/quaternion.hpp" #include "glm/glm.hpp" #include "glm/gtc/matrix_transform.hpp" #define MAX_TEXTURE_BINDINGS 4 namespace Deer { struct MeshComponent { MeshComponent() { clear(); } MeshComponent(uint16_t _meshId) : meshId(_meshId), active(true) { } MeshComponent(const MeshComponent&) = default; inline void setMesh(uint16_t _meshId) { active = true; meshId = _meshId; } inline void clear() { active = false; meshId = 0; } inline VertexArray& getMesh() { return MeshManager::getModel(meshId); } inline Path& getMeshName() { return MeshManager::getModelName(meshId); } inline bool hasMesh() { return meshId != 0; } inline bool isActive() { return active; } private: uint16_t meshId; bool active; }; struct ShaderComponent { ShaderComponent() { clear(); } ShaderComponent(uint16_t _shaderId) : shaderId(_shaderId), active(true) { } ShaderComponent(const ShaderComponent&) = default; inline void setShader(uint16_t _shaderId) { active = true; shaderId = _shaderId; } inline void clear() { active = false; shaderId = 0; } inline Shader& getShader() { return ShaderManager::getShader(shaderId); } inline bool isActive() { return active; } private: uint16_t shaderId; bool active; }; struct TextureBindingComponent { TextureBindingComponent() { for (int x = 0; x < MAX_TEXTURE_BINDINGS; x++) { textureAssetID[x] = 0; textureBindID[x] = 0; } } TextureBindingComponent(const TextureBindingComponent&) = default; uint32_t textureAssetID[MAX_TEXTURE_BINDINGS]; unsigned char textureBindID[MAX_TEXTURE_BINDINGS]; }; struct CameraComponent { CameraComponent() = default; CameraComponent(const CameraComponent&) = default; CameraComponent(float _fov, float _aspect, float _nearZ, float _farZ) : fov(_fov), aspect(_aspect), nearZ(_nearZ), farZ(_farZ) { } inline glm::mat4 getMatrix() const { return glm::perspective(fov, aspect, nearZ, farZ); } float fov = glm::radians(50.0f), aspect = 16 / 9, nearZ = 0.1f, farZ = 1000; }; }