#pragma once #include "Texture.h" #include "Effects/BaseEffect.h" #include #include class Effect; using namespace dae; struct VertexIn; struct VertexOut; enum class PrimitiveTopology { TriangleList, TriangleStrip }; class Mesh final { public: Mesh(ID3D11Device *devicePtr, const std::vector &verticesIn, const std::vector &indices, std::shared_ptr material, std::unique_ptr effectPtr); ~Mesh(); void Render(ID3D11DeviceContext *deviceContextPtr, const Matrix &worldViewProj) const; void SetCameraPos(const Vector3 &pos) const; Matrix GetWorldMatrix() const { return m_WorldMatrix; } void ToggleNormals(); void NextSamplingState(); Material* GetMaterial() const { return m_Material.get(); } void SetWorldMatrix(const Matrix &matrix); std::vector& GetVertices() { return m_VerticesIn; } std::vector& GetIndices() { return m_Indices; } PrimitiveTopology GetPrimitiveTopology() const { return m_PrimitiveTopology; } void SetMaterial(Material *pMaterial); void CycleCullMode(); void SetShouldRender(bool shouldRender) { m_ShouldRender = shouldRender; } bool GetShouldRender() const { return m_ShouldRender; } private: std::unique_ptr m_EffectPtr; Matrix m_WorldMatrix{}; ID3D11InputLayout *m_InputLayoutPtr; ID3D11Buffer *m_VertexBufferPtr; ID3D11Buffer *m_IndexBufferPtr; std::vector m_VerticesIn; std::vector m_Indices; UINT m_IndicesCount; std::shared_ptr m_Material{}; PrimitiveTopology m_PrimitiveTopology{PrimitiveTopology::TriangleList}; bool m_ShouldRender{ true }; }; struct VertexIn { Vector3 position{}; Vector2 uv{}; Vector3 normal{}; Vector3 tangent{}; }; struct VertexOut { Vector4 position{}; ColorRGB color{}; Vector2 uv{}; Vector3 normal{}; Vector3 tangent{}; Vector3 viewDir{}; Mesh* mesh{}; bool valid{ true }; };