68 lines
2.3 KiB
C++
68 lines
2.3 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 vertices[3];
|
|
uint16_t attributeByteCount;
|
|
};
|
|
|
|
typedef int (ImportAdapter_fn)(XMFLOAT3&); // importáláskor a vertexek átalakítására szolgál
|
|
|
|
class ImportAdapters
|
|
{
|
|
public:
|
|
static int IAD_Default(XMFLOAT3& vertex); // alapértelmezett
|
|
static int IAD_SwapYZ_RH(XMFLOAT3& vertex); // y-z tengelyek cseréje
|
|
};
|
|
|
|
class Geometry : public IDrawable {
|
|
private:
|
|
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;
|
|
protected:
|
|
ComPtr<ID3D12Device> device; // device
|
|
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
|
|
virtual 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, ImportAdapter_fn * pIAD = nullptr); // bináris STL fájl betöltése
|
|
ComPtr<ID3D12Device> getDevice() const; // device elkérése
|
|
};
|
|
|
|
// geometriatároló típusa
|
|
using GeometryPool = std::vector<std::shared_ptr<Geometry>>;
|
|
}
|