MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MeshWriterNode.hpp
Go to the documentation of this file.
1#pragma once
2
5#include "VertexSpec.hpp"
6
8
9/**
10 * @class MeshWriterNode
11 * @brief Indexed triangle mesh for static or infrequently-updated geometry.
12 *
13 * Holds CPU-side MeshVertex and uint32_t index arrays.
14 * Topology is always TRIANGLE_LIST. Index buffer is uploaded via
15 * GeometryWriterNode::set_indices() on compute_frame().
16 *
17 * For GPU-deformed mesh data, populate m_vertices externally via
18 * set_mesh() and let compute_frame() handle the upload on the next cycle.
19 */
20class MAYAFLUX_API MeshWriterNode : public GeometryWriterNode {
21public:
22 explicit MeshWriterNode(size_t initial_vertex_capacity = 1024);
23
24 /**
25 * @brief Replace all vertex and index data from a MeshData owner.
26 * @param data Source mesh; vertex_variant must hold vector<uint8_t>,
27 * index_variant must hold vector<uint32_t>.
28 */
29 void set_mesh(const Kakshya::MeshData& data);
30
31 /**
32 * @brief Replace all vertex and index data atomically.
33 * @param vertices Mesh vertices
34 * @param indices Triangle indices (must be a multiple of 3)
35 */
36 void set_mesh(
37 std::span<const MeshVertex> vertices,
38 std::span<const uint32_t> indices);
39
40 /**
41 * @brief Replace vertex array only; index array is unchanged.
42 * @param vertices New vertex data
43 */
44 void set_mesh_vertices(std::span<const MeshVertex> vertices);
45
46 /**
47 * @brief Replace index array only; vertex array is unchanged.
48 * @param indices New index data (must be a multiple of 3)
49 */
50 void set_mesh_indices(std::span<const uint32_t> indices);
51
52 [[nodiscard]] const std::vector<MeshVertex>& get_mesh_vertices() const { return m_vertices; }
53 [[nodiscard]] const std::vector<uint32_t>& get_mesh_indices() const { return m_indices; }
54 [[nodiscard]] size_t get_mesh_vertex_count() const { return m_vertices.size(); }
55 [[nodiscard]] size_t get_mesh_face_count() const { return m_indices.size() / 3; }
56
57 void clear_mesh();
58
59 [[nodiscard]] Portal::Graphics::PrimitiveTopology get_primitive_topology() const override;
60
61 void compute_frame() override;
62
63private:
64 std::vector<MeshVertex> m_vertices;
65 std::vector<uint32_t> m_indices;
66};
67
68} // namespace MayaFlux::Nodes::GpuSync
Base class for nodes that generate 3D geometry data.
const std::vector< uint32_t > & get_mesh_indices() const
const std::vector< MeshVertex > & get_mesh_vertices() const
Indexed triangle mesh for static or infrequently-updated geometry.
PrimitiveTopology
Vertex assembly primitive topology.
Owning CPU-side representation of a loaded or generated mesh.
Definition MeshData.hpp:33