101 lines
2.0 KiB
C++
101 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include "EHS.h"
|
|
#include "Array.h"
|
|
#include "Vertex.h"
|
|
|
|
namespace ehs
|
|
{
|
|
const Array<Vertex_f> portraitGuiVerts({
|
|
{{0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, -1.0f}, {0.0f, 0.0f}},
|
|
{{0.0f, 1.0f, 1.0f}, {0.0f, 0.0f, -1.0f}, {0.0f, 1.0f}},
|
|
{{1.0f, 0.0f, 1.0f}, {0.0f, 0.0f, -1.0f}, {1.0f, 0.0f}},
|
|
{{1.0f, 1.0f, 1.0f}, {0.0f, 0.0f, -1.0f}, {1.0f, 1.0f}}
|
|
});
|
|
|
|
const Array<UInt_32> portraitGuiIndices({
|
|
0,
|
|
1,
|
|
2,
|
|
3,
|
|
2,
|
|
1
|
|
});
|
|
|
|
const Array<Vertex_f> portraitVerts({
|
|
{{-0.5f, -0.5f, 0.0f}, {0.0f, 0.0f, -1.0f}, {0.0f, 0.0f}},
|
|
{{-0.5f, 0.5f, 0.0f}, {0.0f, 0.0f, -1.0f}, {0.0f, 1.0f}},
|
|
{{0.5f, -0.5f, 0.0f}, {0.0f, 0.0f, -1.0f}, {1.0f, 0.0f}},
|
|
{{0.5f, 0.5f, 0.0f}, {0.0f, 0.0f, -1.0f}, {1.0f, 1.0f}}
|
|
});
|
|
|
|
const Array<UInt_32> portraitIndices({
|
|
0,
|
|
1,
|
|
2,
|
|
3,
|
|
2,
|
|
1
|
|
});
|
|
|
|
class Mesh : public Resource
|
|
{
|
|
protected:
|
|
Array<Vertex_f> vertices;
|
|
Array<UInt_32> indices;
|
|
GpuBuffer srcVertBuffer;
|
|
GpuBuffer dstVertBuffer;
|
|
GpuBuffer srcIndBuffer;
|
|
GpuBuffer dstIndBuffer;
|
|
|
|
public:
|
|
Mesh();
|
|
|
|
Mesh(Str_8 id, Array<Vertex_f> vertices, Array<UInt_32> indices);
|
|
|
|
Mesh(Str_8 id, Array<Vertex_f> vertices);
|
|
|
|
Mesh(Str_8 id);
|
|
|
|
Mesh(Mesh&& mesh) noexcept;
|
|
|
|
Mesh(const Mesh& mesh);
|
|
|
|
Mesh& operator=(Mesh&& mesh) noexcept;
|
|
|
|
Mesh& operator=(const Mesh& mesh);
|
|
|
|
bool UploadToGpu(GpuCmdBuffer* cmdBuffer) override;
|
|
|
|
bool PostGpuUpload() override;
|
|
|
|
bool HasPostGpuUploaded() const override;
|
|
|
|
bool ReleaseFromGpu() override;
|
|
|
|
bool IsUploaded() const override;
|
|
|
|
void Bind(GpuCmdBuffer* cmdBuffer);
|
|
|
|
void Draw(GpuCmdBuffer* cmdBuffer, const UInt_32 instances = 1);
|
|
|
|
void SetVertices(const Array<Vertex_f>& newVertices);
|
|
|
|
Array<Vertex_f> GetVertices() const;
|
|
|
|
Array<Vertex_f>& GetVertices();
|
|
|
|
void SetIndices(const Array<UInt_32>& newIndices);
|
|
|
|
bool HasIndices() const;
|
|
|
|
Array<UInt_32> GetIndices() const;
|
|
|
|
Array<UInt_32>& GetIndices();
|
|
|
|
void Calculate();
|
|
|
|
private:
|
|
static void Calculate(Vertex_f& vert1, Vertex_f& vert2, Vertex_f& vert3);
|
|
};
|
|
} |