92 lines
2.0 KiB
C++
92 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include "Texture.h"
|
|
#include "Effects/BaseEffect.h"
|
|
|
|
#include <d3d11.h>
|
|
#include <vector>
|
|
|
|
class Effect;
|
|
|
|
using namespace dae;
|
|
|
|
struct VertexIn;
|
|
struct VertexOut;
|
|
|
|
enum class PrimitiveTopology {
|
|
TriangleList,
|
|
TriangleStrip
|
|
};
|
|
|
|
|
|
class Mesh final {
|
|
public:
|
|
Mesh(ID3D11Device *devicePtr, const std::vector<VertexIn> &verticesIn, const std::vector<Uint32> &indices,
|
|
std::shared_ptr<Material> material, std::unique_ptr<BaseEffect> 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<VertexIn>& GetVertices() { return m_VerticesIn; }
|
|
std::vector<Uint32>& 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<BaseEffect> m_EffectPtr;
|
|
|
|
Matrix m_WorldMatrix{};
|
|
|
|
ID3D11InputLayout *m_InputLayoutPtr;
|
|
ID3D11Buffer *m_VertexBufferPtr;
|
|
ID3D11Buffer *m_IndexBufferPtr;
|
|
|
|
std::vector<VertexIn> m_VerticesIn;
|
|
std::vector<uint32_t> m_Indices;
|
|
UINT m_IndicesCount;
|
|
|
|
std::shared_ptr<Material> 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 };
|
|
};
|
|
|