3#include "structure/engine/2d/spk_collision_mesh_2d.hpp"
4#include "structure/geometry/spk_mesh.hpp"
5#include "structure/graphics/spk_sprite_sheet.hpp"
6#include "structure/math/spk_vector2.hpp"
7#include "structure/opengl/spk_vertex_buffer_object.hpp"
49 std::vector<Polygon> _polygons;
87 Builder &
insertRectangle(
const spk::Vector2 &p_anchor,
const spk::Vector2 &p_size,
const spk::Vector2 &p_uvAnchor,
const spk::Vector2 &p_uvSize, PolygonOrder p_order = PolygonOrder::TriangleFanFromFirst);
154 layout.addAttribute({0, Attribute::Type::Vector2});
155 layout.addAttribute({1, Attribute::Type::Vector2});
Convex collision mesh built from 2D points.
Definition spk_collision_mesh_2d.hpp:21
Stores polygon data and exposes GPU-ready vertex/index buffers.
Definition spk_mesh.hpp:29
const std::shared_ptr< spk::OpenGL::BufferSetObject > & bufferSet() const
Definition spk_mesh.hpp:338
const std::vector< Polygon > & polygons() const
Definition spk_mesh.hpp:301
void append(const Polygon &p_shape)
Definition spk_mesh.hpp:270
IPolygon< Mesh2DVertex > Polygon
Definition spk_mesh.hpp:34
void clear()
Definition spk_mesh.hpp:258
Builder & insertSprite(const spk::SpriteSheet &p_spriteSheet, const spk::Vector2UInt &p_spriteID, spk::Vector2 p_center, spk::Vector2 p_size)
Adds a sprite quad sourced from a sprite sheet.
Definition spk_mesh_2d.cpp:71
Builder & insertTriangle(const Vertex &p_a, const Vertex &p_b, const Vertex &p_c)
Adds a triangle to the builder.
Definition spk_mesh_2d.cpp:44
Builder & clear()
Clears existing polygons.
Definition spk_mesh_2d.cpp:38
Builder & insertQuad(const Vertex &p_a, const Vertex &p_b, const Vertex &p_c, const Vertex &p_d, PolygonOrder p_order=PolygonOrder::TriangleFanFromFirst)
Adds a quad to the builder.
Definition spk_mesh_2d.cpp:50
Builder()=default
Creates an empty builder.
Mesh2D construct()
Builds a Mesh2D from the stored polygons.
Definition spk_mesh_2d.cpp:85
Builder & insertRectangle(const spk::Vector2 &p_anchor, const spk::Vector2 &p_size, const spk::Vector2 &p_uvAnchor, const spk::Vector2 &p_uvSize, PolygonOrder p_order=PolygonOrder::TriangleFanFromFirst)
Adds a rectangle with UVs to the builder.
Definition spk_mesh_2d.cpp:56
Mesh2D & operator+=(const Mesh2D &p_other)
Appends polygons from another mesh.
Definition spk_mesh_2d.cpp:95
CollisionMesh2D collisionMesh() const
Builds a collision mesh from this mesh.
Definition spk_mesh_2d.cpp:108
Mesh2D()
Creates an empty mesh.
Definition spk_mesh_2d.cpp:5
Mesh2DVertex Vertex
Vertex type used by the mesh.
Definition spk_mesh_2d.hpp:35
Base::Polygon Polygon
Polygon type used by the mesh.
Definition spk_mesh_2d.hpp:37
void _configureBufferSet() const override
Configures the vertex buffer layout for this mesh.
Definition spk_mesh_2d.hpp:150
Mesh2D & operator=(const Mesh2D &p_other)
Copy-assigns another mesh.
Definition spk_mesh_2d.cpp:15
Mesh2D fuze(const Mesh2D &p_other) const
Returns a new mesh combining this mesh with another.
Definition spk_mesh_2d.cpp:101
spk::IMesh< Mesh2DVertex > Base
Base IMesh type.
Definition spk_mesh_2d.hpp:33
VertexBufferObject & vbo()
Access mutable VBO.
Definition spk_buffer_set_object.cpp:76
Layout & layout()
Access layout descriptor.
Definition spk_vertex_buffer_object.cpp:253
Loads an image and exposes individual sprite regions.
Definition spk_sprite_sheet.hpp:21
Vertex data for 2D meshes.
Definition spk_mesh_2d.hpp:18
spk::Vector2 uv
Texture coordinates for the vertex.
Definition spk_mesh_2d.hpp:22
spk::Vector2 position
Position of the vertex in local space.
Definition spk_mesh_2d.hpp:20
Describes a vertex attribute entry in the layout.
Definition spk_vertex_buffer_object.hpp:38