MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
GeometryPrimitives.hpp
Go to the documentation of this file.
1#pragma once
2
5
7
8namespace MayaFlux::Kinesis {
9
10/**
11 * @brief Generate vertices along a circular path
12 * @param center Circle center in 3D space
13 * @param radius Circle radius
14 * @param segments Number of subdivisions (must be >= 3)
15 * @param normal Circle plane normal (default: XY plane, Z-up)
16 * @return Vertices generated by angle θ ∈ [0, 2π)
17 *
18 * Generates N+1 vertices where last vertex equals first (closed curve).
19 * For LINE_STRIP topology. For POINT_LIST, use N vertices.
20 */
21MAYAFLUX_API std::vector<glm::vec3> generate_circle(
22 const glm::vec3& center,
23 float radius,
24 size_t segments,
25 const glm::vec3& normal = glm::vec3(0, 0, 1));
26
27/**
28 * @brief Generate vertices along an elliptical path
29 * @param center Ellipse center
30 * @param semi_major Semi-major axis length
31 * @param semi_minor Semi-minor axis length
32 * @param segments Number of subdivisions
33 * @param normal Ellipse plane normal
34 * @return Vertices generated by eccentric anomaly
35 */
36MAYAFLUX_API std::vector<glm::vec3> generate_ellipse(
37 const glm::vec3& center,
38 float semi_major,
39 float semi_minor,
40 size_t segments,
41 const glm::vec3& normal = glm::vec3(0, 0, 1));
42
43/**
44 * @brief Generate vertices of an axis-aligned rectangular path
45 * @param center Rectangle centroid
46 * @param width Extent along local X axis
47 * @param height Extent along local Y axis
48 * @param normal Rectangle plane normal
49 * @return 5 vertices (closed rectangular path for LINE_STRIP)
50 */
51MAYAFLUX_API std::vector<glm::vec3> generate_rectangle(
52 const glm::vec3& center,
53 float width,
54 float height,
55 const glm::vec3& normal = glm::vec3(0, 0, 1));
56
57/**
58 * @brief Generate vertices of a regular n-gon
59 * @param center Polygon centroid
60 * @param radius Circumradius (center to vertex distance)
61 * @param sides Number of sides (must be >= 3)
62 * @param normal Polygon plane normal
63 * @param phase_offset Angular offset in radians (default: 0)
64 * @return N+1 vertices (closed path)
65 *
66 * Vertices positioned at angles: θ_k = (2πk/N) + phase_offset
67 */
68MAYAFLUX_API std::vector<glm::vec3> generate_regular_polygon(
69 const glm::vec3& center,
70 float radius,
71 size_t sides,
72 const glm::vec3& normal = glm::vec3(0, 0, 1),
73 float phase_offset = 0.0F);
74
75/**
76 * @brief Apply rigid transformation to vertex set
77 * @param vertices Vertices to transform (modified in-place)
78 * @param transform Affine transformation matrix (4x4)
79 */
80MAYAFLUX_API void apply_transform(
81 std::vector<glm::vec3>& vertices,
82 const glm::mat4& transform);
83
84/**
85 * @brief Apply rotation to vertex set around arbitrary axis
86 * @param vertices Vertices to transform (modified in-place)
87 * @param axis Rotation axis (will be normalized)
88 * @param angle Rotation angle in radians (right-hand rule)
89 * @param origin Rotation pivot (default: coordinate origin)
90 */
91MAYAFLUX_API void apply_rotation(
92 std::vector<glm::vec3>& vertices,
93 const glm::vec3& axis,
94 float angle,
95 const glm::vec3& origin = glm::vec3(0));
96
97/**
98 * @brief Apply translation to vertex set
99 * @param vertices Vertices to transform (modified in-place)
100 * @param displacement Translation vector
101 */
102MAYAFLUX_API void apply_translation(
103 std::vector<glm::vec3>& vertices,
104 const glm::vec3& displacement);
105
106/**
107 * @brief Rigid transform that rotates about a local pivot and lands the pivot on a world point
108 * @param pivot Point in local space that stays fixed under the rotation
109 * @param target World-space point the pivot is placed on
110 * @param rotation Rotation applied about the pivot
111 * @return Matrix mapping local space to world space
112 */
113[[nodiscard]] MAYAFLUX_API glm::mat4 pivot_transform(
114 const glm::vec3& pivot,
115 const glm::vec3& target,
116 const glm::quat& rotation);
117
118/**
119 * @brief Transform that scales and translates one box onto another
120 * @param source Box to map from
121 * @param target Box to map onto
122 * @return Matrix taking @p source onto @p target, scaling each axis independently
123 *
124 * An axis along which @p source has no extent, a flat mesh for example, is not
125 * scaled and is only centered. A @p target with no extent along an axis flattens
126 * that axis. For a uniform or unscaled fit, pass a @p target already resized and
127 * centered to suit.
128 */
129[[nodiscard]] MAYAFLUX_API glm::mat4 box_transform(
130 const AABB3D& source,
131 const AABB3D& target);
132
133/**
134 * @brief Apply uniform scaling to vertex set
135 * @param vertices Vertices to transform (modified in-place)
136 * @param scale Scale factor (must be > 0)
137 * @param origin Scaling pivot (default: coordinate origin)
138 */
139MAYAFLUX_API void apply_uniform_scale(
140 std::vector<glm::vec3>& vertices,
141 float scale,
142 const glm::vec3& origin = glm::vec3(0));
143
144/**
145 * @brief Apply non-uniform scaling to vertex set
146 * @param vertices Vertices to transform (modified in-place)
147 * @param scale Per-axis scale factors
148 * @param origin Scaling center
149 */
150MAYAFLUX_API void apply_scale(
151 std::vector<glm::vec3>& vertices,
152 const glm::vec3& scale,
153 const glm::vec3& origin = glm::vec3(0));
154
155/**
156 * @brief Compute normal vectors along a piecewise-linear path
157 * @param path_vertices Sequential vertices defining curve
158 * @param normal_length Magnitude of normal vectors
159 * @param stride Sample every stride-th vertex (default: 1)
160 * @return Line segments (pairs) representing normals (for LINE_LIST topology)
161 *
162 * Normal at vertex i: perpendicular to tangent (v[i+1] - v[i])
163 * Returned as pairs: [midpoint - normal/2, midpoint + normal/2]
164 */
165MAYAFLUX_API std::vector<Kakshya::LineVertex> compute_path_normals(
166 const std::vector<Kakshya::LineVertex>& path_vertices,
167 float normal_length,
168 size_t stride = 1);
169
170/**
171 * @brief Compute tangent vectors along a piecewise-linear path
172 * @param path_vertices Sequential vertices defining curve
173 * @param tangent_length Magnitude of tangent vectors
174 * @param stride Sample every stride-th vertex
175 * @return Line segments (pairs) representing tangents (for LINE_LIST topology)
176 *
177 * Tangent at vertex i: direction (v[i+1] - v[i])
178 * Returned as pairs: [vertex - tangent/2, vertex + tangent/2]
179 */
180MAYAFLUX_API std::vector<Kakshya::LineVertex> compute_path_tangents(
181 const std::vector<Kakshya::LineVertex>& path_vertices,
182 float tangent_length,
183 size_t stride = 1);
184
185/**
186 * @brief Compute curvature vectors along a path (2nd derivative approximation)
187 * @param path_vertices Sequential vertices defining curve
188 * @param curvature_scale Magnitude scaling factor
189 * @param stride Sample every stride-th vertex
190 * @return Line segments representing discrete curvature
191 *
192 * Curvature at i approximated by: (v[i+1] - 2*v[i] + v[i-1])
193 */
194MAYAFLUX_API std::vector<Kakshya::LineVertex> compute_path_curvature(
195 const std::vector<Kakshya::LineVertex>& path_vertices,
196 float curvature_scale,
197 size_t stride = 1);
198
199/**
200 * @brief Sample parametric curve uniformly in parameter space
201 * @param curve Parametric function: [0,1] → ℝ³
202 * @param samples Number of samples
203 * @return Vertices sampled at t_k = k/(N-1) for k ∈ [0, N-1]
204 */
205MAYAFLUX_API std::vector<glm::vec3> sample_parametric_curve(
206 const std::function<glm::vec3(float)>& curve,
207 size_t samples);
208
209/**
210 * @brief Resample path vertices for arc-length parameterization
211 * @param path_vertices Input vertices (arbitrary spacing)
212 * @param num_samples Desired output sample count
213 * @return Vertices uniformly distributed by arc length
214 *
215 * Uses piecewise linear arc length estimation.
216 * Output vertices have constant spacing along curve.
217 */
218MAYAFLUX_API std::vector<Kakshya::LineVertex> reparameterize_by_arc_length(
219 const std::vector<Kakshya::LineVertex>& path_vertices,
220 size_t num_samples);
221
222/**
223 * @brief Project vertices onto plane defined by normal
224 * @param vertices Vertices to project (modified in-place)
225 * @param plane_point Point on projection plane
226 * @param plane_normal Plane normal vector
227 */
228MAYAFLUX_API void project_onto_plane(
229 std::vector<glm::vec3>& vertices,
230 const glm::vec3& plane_point,
231 const glm::vec3& plane_normal);
232
233/**
234 * @brief Compute convex hull of vertex set (2D projection)
235 * @param vertices Input vertex set
236 * @param projection_normal Normal of projection plane (default: Z-axis)
237 * @return Vertices forming convex hull boundary (closed path)
238 *
239 * Uses Graham scan on projected coordinates.
240 */
241MAYAFLUX_API std::vector<glm::vec3> compute_convex_hull_2d(
242 const std::vector<glm::vec3>& vertices,
243 const glm::vec3& projection_normal = glm::vec3(0, 0, 1));
244
245/**
246 * @brief Apply color interpolation to position vertices
247 * @param positions Input position vertices
248 * @param colors Color stops for interpolation
249 * @param color_positions Normalized positions [0,1] for each color stop
250 * @param default_thickness Line thickness for all vertices (default: 1.0)
251 * @return LineVertex array with interpolated colors
252 *
253 * Example:
254 * colors = {red, blue}
255 * color_positions = {0.0, 1.0}
256 * → Linear gradient from red to blue along path
257 *
258 * If color_positions.empty(), distributes colors uniformly.
259 */
260[[nodiscard]] MAYAFLUX_API std::vector<Kakshya::Vertex> apply_color_gradient(
261 const std::vector<glm::vec3>& positions,
262 const std::vector<glm::vec3>& colors,
263 const std::vector<float>& color_positions = {},
264 float scalar = 1.0F);
265
266/**
267 * @brief Apply uniform color to position vertices
268 */
269[[nodiscard]] MAYAFLUX_API std::vector<Kakshya::Vertex> apply_uniform_color(
270 const std::vector<glm::vec3>& positions,
271 const glm::vec3& color,
272 float scalar = 1.0F);
273
274/**
275 * @brief Convert positions to LineVertex with per-vertex colors
276 */
277[[nodiscard]] MAYAFLUX_API std::vector<Kakshya::Vertex> apply_vertex_colors(
278 const std::vector<glm::vec3>& positions,
279 const std::vector<glm::vec3>& colors,
280 float scalar = 1.0F);
281
282/**
283 * @struct QuadGeometry
284 * @brief Textured quad vertex data together with its semantic layout descriptor.
285 *
286 * Returned by generate_quad(). Callers memcpy vertices into their staging
287 * buffer and forward layout to set_vertex_layout().
288 */
290 std::array<Kakshya::TextureQuadVertex, 4> vertices;
292};
293
294/**
295 * @brief Generate a textured quad centred on the origin.
296 * @param position Translation in XY (z remains 0). Default: no translation.
297 * @param scale Extents in XY before rotation. Default: {1,1} → NDC-spanning quad.
298 * @param rotation Rotation angle in radians around Z axis. Default: 0.
299 * @return QuadGeometry ready for TRIANGLE_STRIP draw.
300 *
301 * UV origin is bottom-left (0,1) to match Vulkan image layout.
302 * Base vertices sit at ±scale before rotation and translation are applied.
303 */
304[[nodiscard]] MAYAFLUX_API QuadGeometry generate_quad(
305 glm::vec2 position = glm::vec2(0.0F),
306 glm::vec2 scale = glm::vec2(1.0F),
307 float rotation = 0.0F);
308
309// ------------------------------------------------------------
310// 2D filled / textured quads
311// ------------------------------------------------------------
312
313/**
314 * @brief Generate a filled TRIANGLE_STRIP quad from an AABB2D.
315 * @param region NDC axis-aligned bounds.
316 * @param color Uniform fill color.
317 */
318[[nodiscard]] MAYAFLUX_API std::array<Kakshya::Vertex, 4> filled_rect(
319 Kinesis::AABB2D region,
320 glm::vec3 color = glm::vec3(1.F));
321
322/**
323 * @brief Generate a UV-mapped TRIANGLE_STRIP quad from an AABB2D.
324 *
325 * UV origin is bottom-left (0,1) matching Vulkan image layout.
326 * Replaces handwritten textured quad construction in Forma callers.
327 *
328 * @param region NDC axis-aligned bounds.
329 */
330[[nodiscard]] MAYAFLUX_API std::array<Kakshya::TextureQuadVertex, 4> textured_rect(
331 Kinesis::AABB2D region);
332
333/**
334 * @brief Generate a UV-mapped TRIANGLE_LIST quad (6 vertices, 2 triangles)
335 * from an AABB2D, as Kakshya::MeshVertex.
336 *
337 * UV origin is bottom-left (0,1), same convention as textured_rect(). Use
338 * this instead of textured_rect() when the target pipeline expects the
339 * full MeshVertex layout (color/weight/normal/tangent) rather than
340 * texture.vert.spv's plain position+texcoord input - textured_rect()'s
341 * TextureQuadVertex is not wire-compatible with a MeshVertex shader input.
342 *
343 * @p weight is written through unchanged, defaulting to MeshVertex's own
344 * neutral default (0). What it means - a blend factor, a sampler
345 * selector, anything - is entirely the caller's domain; this function has
346 * no opinion on it. @p color is likewise written through unchanged,
347 * defaulting to MeshVertex's own neutral default (white) - at weight >= 1
348 * a caller-side shader convention may read it as a texture tint; at
349 * weight <= 0 the same convention may render it as a flat fill with no
350 * texture read at all. Either reading is the caller's domain.
351 *
352 * @param region NDC axis-aligned bounds.
353 * @param weight Per-vertex weight value, written through as-is.
354 * @param color Per-vertex color value, written through as-is.
355 */
356[[nodiscard]] MAYAFLUX_API std::array<Kakshya::MeshVertex, 6> textured_mesh_rect(
357 Kinesis::AABB2D region,
358 float weight = 0.F,
359 glm::vec3 color = glm::vec3(1.F));
360
361// ------------------------------------------------------------
362// 3D wireframe shapes
363// ------------------------------------------------------------
364
365/**
366 * @brief Generate a cuboid wireframe as LINE_LIST pairs.
367 * @param center Centre of the cuboid.
368 * @param half Half-extents along each axis.
369 * @param color Uniform edge color.
370 */
371[[nodiscard]] MAYAFLUX_API std::vector<Kakshya::Vertex> cuboid_wireframe(
372 const glm::vec3& center,
373 const glm::vec3& half,
374 const glm::vec3& color = glm::vec3(1.F));
375
376/**
377 * @brief Generate a solid box as an indexed TRIANGLE_LIST mesh.
378 *
379 * Six faces, four vertices each, two triangles per face. Per-face normals point
380 * outward along the face axis. UV origin is bottom-left matching Vulkan image
381 * layout and the generate_quad convention.
382 *
383 * @param center Centre of the box in world space.
384 * @param half_extents Half-size along each axis. Non-uniform values yield a cuboid.
385 * @param subdivisions Reserved for future per-face tessellation. Currently ignored.
386 * @return MeshData ready for MeshBuffer::set_mesh_data() or MeshWriterNode::set_mesh().
387 */
388[[nodiscard]] MAYAFLUX_API Kakshya::MeshData generate_box(
389 const glm::vec3& center,
390 const glm::vec3& half_extents,
391 uint32_t subdivisions = 1);
392
393/**
394 * @brief Generate a subdivided flat grid in the XZ plane.
395 *
396 * Vertices lie at Y = 0. U maps to X, V maps to Z. UV covers [0,1] across
397 * the full extent. Normals point along +Y throughout.
398 *
399 * @param center World-space centre of the grid.
400 * @param extent_x Total width along X.
401 * @param extent_z Total depth along Z.
402 * @param cols Number of columns (cells along X). Clamped to minimum 1.
403 * @param rows Number of rows (cells along Z). Clamped to minimum 1.
404 * @return MeshData ready for TRIANGLE_LIST draw.
405 */
406[[nodiscard]] MAYAFLUX_API Kakshya::MeshData generate_grid(
407 const glm::vec3& center,
408 float extent_x,
409 float extent_z,
410 uint32_t cols,
411 uint32_t rows,
412 const glm::vec3& normal = glm::vec3(0.0F, 1.0F, 0.0F));
413
414/**
415 * @brief Generate a mesh from an arbitrary parametric surface function.
416 *
417 * @p fn maps (u, v) in [0,1]^2 to a world-space position. Normals are
418 * computed via finite differences on @p fn so they follow the surface
419 * exactly regardless of shape. UV is mapped directly from (u, v).
420 *
421 * Any surface expressible as a function of two parameters is valid:
422 * torus, Möbius band, Klein bottle approximation, spherical harmonic
423 * deformation, audio-driven terrain, or any procedural form.
424 *
425 * @param fn Surface function: (u, v) -> glm::vec3.
426 * @param u_segs Subdivisions along U. Clamped to minimum 1.
427 * @param v_segs Subdivisions along V. Clamped to minimum 1.
428 * @return MeshData ready for TRIANGLE_LIST draw.
429 */
431 const std::function<glm::vec3(float u, float v)>& fn,
432 uint32_t u_segs,
433 uint32_t v_segs);
434
435/**
436 * @brief Generate a mesh from the graph of a function sampled on a grid, y = f(x, z).
437 *
438 * @p heights holds one value per grid point, row-major, @p columns values along X
439 * for each of @p rows steps along Z. The surface is centred on @p center and spans
440 * @p extent in X and Z. Normals and tangents come from central differences of the
441 * heights, so they follow the surface and are never degenerate. The raw height is
442 * stored in each vertex's weight. UV runs (0, 1) at the first row and first column.
443 *
444 * Use it where the data is already a table of values: a sound's recent blocks,
445 * an image's brightness, a spectrogram, a column of a file. The triangle indices
446 * depend only on the grid size and are reused between calls, so regenerating every
447 * frame costs one pass over the heights; large grids are filled in parallel.
448 *
449 * @param heights columns * rows values.
450 * @param columns Grid points along X. Minimum 2.
451 * @param rows Grid points along Z. Minimum 2.
452 * @param extent World size in X and Z.
453 * @param height_scale Multiplier from a height to a world Y offset.
454 * @param center World position of the middle of the grid at zero height.
455 * @return MeshData ready for TRIANGLE_LIST draw, empty and logged if the sizes disagree.
456 */
457[[nodiscard]] MAYAFLUX_API Kakshya::MeshData generate_explicit_surface(
458 std::span<const float> heights,
459 uint32_t columns,
460 uint32_t rows,
461 const glm::vec2& extent,
462 float height_scale = 1.0F,
463 const glm::vec3& center = glm::vec3(0.0F));
464
465/**
466 * @brief Extrude a circle along an arbitrary 3D path.
467 *
468 * Each path point becomes a ring of @p radial_segments vertices. The ring
469 * frame is propagated along the path using parallel transport, which
470 * eliminates the twisting that naive normal-aligned cross-sections produce.
471 *
472 * @p radius_fn maps the normalised path parameter t in [0,1] to a radius.
473 * A constant lambda gives a uniform tube. Any callable works: audio node
474 * output, envelope, position-dependent modulation.
475 *
476 * Caps are flat and optional. An open tube (no caps) is suitable for chains
477 * and paths; a capped tube is suitable for solid cylindrical forms.
478 *
479 * @param path Ordered world-space positions defining the spine.
480 * Minimum 2 points. Clamped to minimum 2.
481 * @param radius_fn Callable: float(float t) returning radius at t.
482 * @param radial_segments Number of vertices per ring. Clamped to minimum 3.
483 * @param capped If true, flat polygon caps are added at both ends.
484 * @return MeshData ready for TRIANGLE_LIST draw.
485 */
486[[nodiscard]] MAYAFLUX_API Kakshya::MeshData generate_tube(
487 std::span<const glm::vec3> path,
488 const std::function<float(float t)>& radius_fn,
489 uint32_t radial_segments = 8,
490 bool capped = false);
491
492/**
493 * @brief Revolve a 2D profile curve around the Y axis.
494 *
495 * @p profile_fn maps t in [0,1] to a point in the XY plane. X is the radial
496 * distance from the Y axis; Y is the height. Negative X values are valid and
497 * produce interior geometry. The profile is revolved through @p sweep_radians,
498 * defaulting to a full revolution.
499 *
500 * UV: u maps to the revolution angle in [0,1]; v maps to the profile
501 * parameter t.
502 *
503 * @param profile_fn Callable: glm::vec2(float t) in the XY plane.
504 * @param profile_segs Samples along the profile. Clamped to minimum 2.
505 * @param radial_segs Subdivisions around the axis. Clamped to minimum 3.
506 * @param sweep_radians Arc of revolution. Default: full circle.
507 * @return MeshData ready for TRIANGLE_LIST draw.
508 */
509[[nodiscard]] MAYAFLUX_API Kakshya::MeshData generate_revolution(
510 const std::function<glm::vec2(float t)>& profile_fn,
511 uint32_t profile_segs,
512 uint32_t radial_segs,
513 float sweep_radians = glm::two_pi<float>());
514
515/**
516 * @brief Extract an isosurface from a scalar field using marching cubes.
517 *
518 * Evaluates @p field at every corner of a regular grid spanning
519 * [@p bounds_min, @p bounds_max] with @p res_x * @p res_y * @p res_z cells.
520 * Triangles are generated wherever the field crosses @p iso_level.
521 * Vertex normals are estimated via central finite differences on the field.
522 *
523 * Any Kinesis::SpatialField is valid: distance(), combine(), chain(),
524 * or any user-supplied glm::vec3 -> float lambda wrapped in a SpatialField.
525 *
526 * @param field SpatialField: glm::vec3 -> float.
527 * @param bounds_min World-space minimum corner of the evaluation volume.
528 * @param bounds_max World-space maximum corner of the evaluation volume.
529 * @param res_x Cell count along X. Clamped to minimum 1.
530 * @param res_y Cell count along Y. Clamped to minimum 1.
531 * @param res_z Cell count along Z. Clamped to minimum 1.
532 * @param iso_level Isosurface threshold value. Default 0.0.
533 * @return MeshData ready for TRIANGLE_LIST draw, or empty MeshData if the
534 * field produces no crossings at iso_level.
535 */
536[[nodiscard]] MAYAFLUX_API Kakshya::MeshData generate_sdf_mesh(
537 const Kinesis::SpatialField& field,
538 const glm::vec3& bounds_min,
539 const glm::vec3& bounds_max,
540 uint32_t res_x,
541 uint32_t res_y,
542 uint32_t res_z,
543 float iso_level = 0.0F);
544
545/**
546 * @brief Extract an isosurface mesh from a scalar field over a lattice.
547 * @param field Sampled at grid corners in world space.
548 * @param lattice Cell counts and world bounds of the evaluation volume.
549 * @param iso_level Field value the surface is placed at.
550 * @return Mesh data, empty if the field has no crossings at @p iso_level.
551 */
553 const Kinesis::SpatialField& field,
554 const Lattice3D& lattice,
555 float iso_level = 0.0F);
556
557} // namespace MayaFlux::Kinesis
glm::vec3 color
Definition Decoder.cpp:97
std::optional< glm::vec3 > position
Definition Decoder.cpp:93
uint32_t rows
uint32_t columns
float radius
uint32_t scalar
double weight
std::vector< glm::vec3 > positions
uint32_t width
uint32_t height
std::vector< glm::vec3 > generate_rectangle(const glm::vec3 &center, float width, float height, const glm::vec3 &normal)
Generate vertices of an axis-aligned rectangular path.
Kakshya::MeshData generate_revolution(const std::function< glm::vec2(float)> &profile_fn, uint32_t profile_segs, uint32_t radial_segs, float sweep_radians)
void apply_rotation(std::vector< glm::vec3 > &vertices, const glm::vec3 &axis, float angle, const glm::vec3 &origin)
Apply rotation to vertex set around arbitrary axis.
std::vector< Kakshya::Vertex > apply_vertex_colors(const std::vector< glm::vec3 > &positions, const std::vector< glm::vec3 > &colors, float scalar)
Convert positions to LineVertex with per-vertex colors.
std::array< Kakshya::MeshVertex, 6 > textured_mesh_rect(Kinesis::AABB2D region, float weight, glm::vec3 color)
Generate a UV-mapped TRIANGLE_LIST quad (6 vertices, 2 triangles) from an AABB2D, as Kakshya::MeshVer...
void apply_scale(std::vector< glm::vec3 > &vertices, const glm::vec3 &scale, const glm::vec3 &origin)
Apply non-uniform scaling to vertex set.
glm::mat4 pivot_transform(const glm::vec3 &pivot, const glm::vec3 &target, const glm::quat &rotation)
Rigid transform that rotates about a local pivot and lands the pivot on a world point.
Kakshya::MeshData generate_parametric_surface(const std::function< glm::vec3(float, float)> &fn, uint32_t u_segs, uint32_t v_segs)
void apply_uniform_scale(std::vector< glm::vec3 > &vertices, float scale, const glm::vec3 &origin)
Apply uniform scaling to vertex set.
Kakshya::MeshData generate_box(const glm::vec3 &center, const glm::vec3 &half_extents, uint32_t subdivisions)
Generate a solid box as an indexed TRIANGLE_LIST mesh.
std::vector< glm::vec3 > generate_regular_polygon(const glm::vec3 &center, float radius, size_t sides, const glm::vec3 &normal, float phase_offset)
Generate vertices of a regular n-gon.
std::vector< Kakshya::Vertex > apply_color_gradient(const std::vector< glm::vec3 > &positions, const std::vector< glm::vec3 > &colors, const std::vector< float > &color_positions, float scalar)
Apply color interpolation to position vertices.
void apply_transform(std::vector< glm::vec3 > &vertices, const glm::mat4 &transform)
Apply rigid transformation to vertex set.
QuadGeometry generate_quad(glm::vec2 position, glm::vec2 scale, float rotation)
Generate a textured quad centred on the origin.
std::vector< Kakshya::LineVertex > compute_path_tangents(const std::vector< Kakshya::LineVertex > &path_vertices, float tangent_length, size_t stride)
Compute tangent vectors along a piecewise-linear path.
glm::mat4 box_transform(const AABB3D &source, const AABB3D &target)
Transform that scales and translates one box onto another.
std::vector< glm::vec3 > generate_ellipse(const glm::vec3 &center, float semi_major, float semi_minor, size_t segments, const glm::vec3 &normal)
Generate vertices along an elliptical path.
void apply_translation(std::vector< glm::vec3 > &vertices, const glm::vec3 &displacement)
Apply translation to vertex set.
void project_onto_plane(std::vector< glm::vec3 > &vertices, const glm::vec3 &plane_point, const glm::vec3 &plane_normal)
Project vertices onto plane defined by normal.
std::vector< Kakshya::LineVertex > compute_path_curvature(const std::vector< Kakshya::LineVertex > &path_vertices, float curvature_scale, size_t stride)
Compute curvature vectors along a path (2nd derivative approximation)
std::vector< glm::vec3 > compute_convex_hull_2d(const std::vector< glm::vec3 > &vertices, const glm::vec3 &projection_normal)
Compute convex hull of vertex set (2D projection)
MAYAFLUX_API Kakshya::MeshData generate_sdf_mesh(const Kinesis::SpatialField &field, const glm::vec3 &bounds_min, const glm::vec3 &bounds_max, uint32_t res_x, uint32_t res_y, uint32_t res_z, float iso_level=0.0F)
Extract an isosurface from a scalar field using marching cubes.
Kakshya::MeshData generate_grid(const glm::vec3 &center, float extent_x, float extent_z, uint32_t cols, uint32_t rows, const glm::vec3 &normal)
Generate a subdivided flat grid in the XZ plane.
std::vector< Kakshya::Vertex > cuboid_wireframe(const glm::vec3 &center, const glm::vec3 &half, const glm::vec3 &color)
Generate a cuboid wireframe as LINE_LIST pairs.
std::array< Kakshya::TextureQuadVertex, 4 > textured_rect(Kinesis::AABB2D region)
Generate a UV-mapped TRIANGLE_STRIP quad from an AABB2D.
std::vector< glm::vec3 > generate_circle(const glm::vec3 &center, float radius, size_t segments, const glm::vec3 &normal)
Generate vertices along a circular path.
std::vector< Kakshya::LineVertex > compute_path_normals(const std::vector< Kakshya::LineVertex > &path_vertices, float normal_length, size_t stride)
Compute normal vectors along a piecewise-linear path.
Tendency< D, float > scale(const Tendency< D, float > &t, float factor)
Uniform scaling of a scalar-output tendency.
Definition Tendency.hpp:98
std::vector< Kakshya::LineVertex > reparameterize_by_arc_length(const std::vector< Kakshya::LineVertex > &path_vertices, size_t num_samples)
Resample path vertices for arc-length parameterization.
std::array< Kakshya::Vertex, 4 > filled_rect(Kinesis::AABB2D region, glm::vec3 color)
Generate a filled TRIANGLE_STRIP quad from an AABB2D.
std::vector< glm::vec3 > sample_parametric_curve(const std::function< glm::vec3(float)> &curve, size_t samples)
Sample parametric curve uniformly in parameter space.
Kakshya::MeshData generate_explicit_surface(std::span< const float > heights, uint32_t columns, uint32_t rows, const glm::vec2 &extent, float height_scale, const glm::vec3 &center)
Generate a mesh from the graph of a function sampled on a grid, y = f(x, z).
std::vector< Kakshya::Vertex > apply_uniform_color(const std::vector< glm::vec3 > &positions, const glm::vec3 &color, float scalar)
Apply uniform color to position vertices.
Kakshya::MeshData generate_tube(std::span< const glm::vec3 > path, const std::function< float(float)> &radius_fn, uint32_t radial_segments, bool capped)
Owning CPU-side representation of a loaded or generated mesh.
Definition MeshData.hpp:33
Complete description of vertex data layout in a buffer.
Axis-aligned bounding rectangle in a 2D coordinate space.
Definition Bounds.hpp:63
A regular subdivision of an AABB3D into a cell count per axis.
Definition Lattice.hpp:25
std::array< Kakshya::TextureQuadVertex, 4 > vertices
Textured quad vertex data together with its semantic layout descriptor.
Typed, composable, stateless callable from domain D to range R.
Definition Tendency.hpp:22