#include "Mesh.hpp" #include "MathF.hpp" #include TSE::Mesh::Mesh() { name = ""; } TSE::Mesh::Mesh(string _name, const std::vector &_vertecies, const std::vector &_indecies, const std::vector &_uvs) { name = _name; vertecies = std::move(_vertecies); indecies = std::move(_indecies); uvs = std::move(_uvs); } size_t TSE::Mesh::IndeciesCount() const { return indecies.size(); } size_t TSE::Mesh::VerteciesCount() const { return vertecies.size(); } TSE::Mesh TSE::Mesh::GetCircleMesh(ushort segments) { std::vector verts; std::vector indices; std::vector uvs; verts.emplace_back(0.0f, 0.0f, 0.0f); uvs.emplace_back(0.5f, 0.5f); float angleStep = 2.0f * TSE_PI / segments; for (int i = 0; i <= segments; ++i) { float angle = i * angleStep; float x = std::cos(angle) * 0.5f; float y = std::sin(angle) * 0.5f; verts.emplace_back(x, y, 0); uvs.emplace_back(x + 0.5f, y + 0.5f); if (i > 0) { indices.push_back(0); indices.push_back(i); indices.push_back(i + 1); } } return Mesh("Circle", verts, indices, uvs); } TSE::Mesh TSE::Mesh::GetQuadMesh() { std::vector verts = { Vector3(-0.5f, -0.5f, 0), Vector3( 0.5f, -0.5f, 0), Vector3( 0.5f, 0.5f, 0), Vector3(-0.5f, 0.5f, 0) }; std::vector uvs = { Vector2(0.0f, 0.0f), Vector2(1.0f, 0.0f), Vector2(1.0f, 1.0f), Vector2(0.0f, 1.0f) }; std::vector indices = { 0, 1, 2, 2, 3, 0 }; return Mesh("Quad", verts, indices, uvs); }