ProtoTank/Engine/Utils/MeshHelper.hpp

50 lines
1.1 KiB
C++

#pragma once
#include <vector>
#include <SFML/Graphics/Color.hpp>
//#include "../Utils/3DMaths.hpp" // Using PCH instead
#define MHELPER_INDICES_TRI_ADD(array, i1, i2, i3) \
array.push_back(i1); \
array.push_back(i2); \
array.push_back(i3);
struct Vertex {
Vertex() = default;
Vertex(const Vertex&) = default;
Vertex& operator=(const Vertex&) = default;
Vertex(Vertex&&) = default;
Vertex& operator=(Vertex&&) = default;
Vertex(M3D_F3 const& _pos) noexcept : pos(_pos) {}
Vertex(M3D_F3 const& _pos, sf::Color const& _color) noexcept : pos(_pos), color(_color) {}
Vertex(const float _x, const float _y, const float _z) noexcept : pos(M3D_F3(_x,_y,_z)) {}
Vertex(M3D_VECTOR const _pos) noexcept {
M3D_V4StoreF3(&this->pos, _pos);
}
M3D_F3 pos = {0.0f, 0.0f, 0.0f};
sf::Color color = {255, 255, 255, 255};
};
struct MeshPart{
MeshPart() = default;
std::vector<unsigned int> indices = {};
M3D_F4X4 transform = M3D_MIdentity4x4();
std::vector<MeshPart> subparts;
};
struct Mesh {
std::vector<Vertex> vertices;
std::vector<MeshPart> parts;
};