58 lines
1.9 KiB
C++
58 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include <mutex>
|
|
#include "IDrawable.h"
|
|
#include "Vertex.h"
|
|
|
|
#include <DirectXMath.h>
|
|
|
|
using namespace DirectX;
|
|
|
|
namespace eg3d {
|
|
|
|
struct STLTriangle {
|
|
XMFLOAT3 normal;
|
|
XMFLOAT3 v1, v2, v3;
|
|
uint16_t attributeByteCount;
|
|
};
|
|
|
|
class Geometry : public IDrawable {
|
|
private:
|
|
ComPtr<ID3D12Device> mDevice; // device
|
|
|
|
std::vector<Vertex> mVertices; // vertexek
|
|
std::vector<uint32_t> mIndices; // indexek
|
|
|
|
std::mutex mModifMtx; // ...
|
|
|
|
// topológia
|
|
D3D_PRIMITIVE_TOPOLOGY mTopology;
|
|
|
|
// bufferek
|
|
ComPtr<ID3D12Resource> mVertexBuffer;
|
|
ComPtr<ID3D12Resource> mIndexBuffer;
|
|
|
|
// leírók
|
|
D3D12_VERTEX_BUFFER_VIEW mVertexBufferView;
|
|
D3D12_INDEX_BUFFER_VIEW mIndexBufferView;
|
|
public:
|
|
explicit Geometry(ComPtr<ID3D12Device> device); // konstr.
|
|
Geometry(const Geometry& other); // másolókonstruktor
|
|
void setVertices(const std::vector<Vertex> &vertices); // vertexek beállítása
|
|
std::vector<Vertex> getVertices() const; // vertexek lekérése
|
|
void setIndices(const std::vector<uint32_t> &indices); // indexek beállítása
|
|
std::vector<uint32_t> getIndices() const; // indexek lekérése
|
|
void setTopology(D3D_PRIMITIVE_TOPOLOGY topology); // topológia beállítása
|
|
D3D_PRIMITIVE_TOPOLOGY getTopology() const; // topológia lekérése
|
|
void setupInputAssembler(ComPtr<ID3D12GraphicsCommandList> commandList) const; // input assembler beállítása
|
|
void draw(ComPtr<ID3D12GraphicsCommandList> commandList) const override; // kirajzolás
|
|
void merge(const Geometry& other); // két geometria egyesítése
|
|
Geometry& operator+=(const Geometry& other); // két geometria egyesítése
|
|
void loadBinarySTL(const std::string& fileName); // bináris STL fájl betöltése
|
|
};
|
|
|
|
// geometriatároló típusa
|
|
using GeometryPool = std::vector<std::shared_ptr<Geometry>>;
|
|
}
|