meshGenerated
Category: Packages · Manifest: use "kernels/";
Triangle meshes as two rows, points and faces.
Description
Section titled “Description”Triangle meshes as two rows, points and faces: lattices that make the torus, the sphere and the plane, midpoint subdivision, and the surface where a field sampled on a lattice crosses a level. The faces are the raster package’s, so a mesh projected point by point is drawn as it is.
Layer: Graphics. Uses: parallel, raster.
use "mesh.entpkg";Kernels
Section titled “Kernels”kernels/iso.ent— The surface where a field sampled on a lattice (IsoLattice) crosses a level (dual contouring): a point in each cell it crosses, where the planes it crosses the cell’s edges on meet, so edges and corners stay sharp as far as the samples show them, and a quad across each lattice edge it crosses. Kernels:mesh.iso_crossed_cells@1,mesh.iso_slots@1,mesh.iso_points@1,mesh.iso_crossed_edges@1,mesh.iso_faces@1.kernels/lattice.ent— A lattice of points,columnsa row androwsof them, and two faces to each of its cells. Kernels:mesh.lattice_faces@1,mesh.torus_points@1,mesh.sphere_points@1,mesh.plane_points@1.kernels/subdivision.ent— Midpoint subdivision, the step that changes a mesh’s topology. Kernels:mesh.split_points@1,mesh.split_faces@1.
Graph presets
Section titled “Graph presets”graphs/iso.esn— A field’s samples on a lattice in, the surface where they cross a level out, as points and faces.graphs/subdivision.esn— One level of midpoint subdivision.
tests/ holds scenes and their replays, run on every backend:
iso.replay, lattice.replay. Every Kernel of the package is reached by one of them.
Used by the animation, culled, mesh, surface examples.
Kernels
Section titled “Kernels”| Kernel | Mode | Brief |
|---|---|---|
mesh.iso_crossed_cells@1 |
map | One flag a cell: whether the surface crosses it; none for a point on the lattice’s far sides, which has no cell. |
mesh.iso_crossed_edges@1 |
map | One flag an edge of the lattice, edge 3 * point + axis from a point to the next along the axis: whether the surface crosses it with the four cells round it inside the lattice. |
mesh.iso_faces@1 |
map | Two faces a crossed edge, from the crossed edges gathered: the quad of the four cells round it, turned to face out of the inside. |
mesh.iso_points@1 |
map | The point of each crossed cell, where the planes of its edges’ crossings meet (iso_quadric_point), its normal the field’s slope there, its uv zero. |
mesh.iso_slots@1 |
scatter into input 1 with max | Each crossed cell’s point among the points, from the crossed cells gathered (parallel.entpkg’s compaction), into a row of -1 a cell. |
mesh.lattice_faces@1 |
map | The faces of a lattice. |
mesh.plane_points@1 |
map | A flat sheet facing up, size across in x and z about the origin, an open lattice. |
mesh.sphere_points@1 |
map | A sphere of radius about the origin, an open lattice: columns round its middle, rows from the pole below to the pole above. |
mesh.split_faces@1 |
map | Each face’s three corners and its middle, over the split points. |
mesh.split_points@1 |
map | The old points, then each face’s midpoints of its edges ab, bc and ca. |
mesh.torus_points@1 |
map | A torus about up: its ring’s radius ring, its tube’s tube; columns go round the ring and rows round the tube. Wrapped both ways it has no seam in its points, and its coordinates jump from near 1 back to 0 across the last cells; open both ways, with a column and a row more, its seams lie twice over and its coordinates run 0 to 1 whole. |
Methods
Section titled “Methods”| Function | Brief |
|---|---|
iso_cells(l: IsoLattice) -> IVec3 |
|
iso_point_cell(l: IsoLattice, i: Int) -> IVec3 |
|
iso_point(l: IsoLattice, c: IVec3) -> Int |
|
iso_corner(k: Int) -> IVec3 |
|
iso_axis(a: Int) -> IVec3 |
|
iso_along(c: IVec3, a: Int) -> Int |
|
iso_place(l: IsoLattice, c: IVec3) -> Vec3 |
|
iso_inside(samples: Rows<Float>, l: IsoLattice, c: IVec3) -> Bool |
|
iso_slope(samples: Rows<Float>, l: IsoLattice, c: IVec3) -> Vec3 |
The field’s slope at lattice point c: central differences, one-sided at the lattice’s sides. |
iso_quadric_point(q: IsoQuadric, cell: Vec3, spacing: Float) -> Vec3 |
|
mesh_lattice_uv(i: Int, columns: Int, rows: Int, wrap_columns: Bool, wrap_rows: Bool) -> Vec2 |
Point i’s coordinates on the lattice, each 0 to 1. |
mesh_lattice_face(t: Int, columns: Int, rows: Int, wrap_columns: Bool, wrap_rows: Bool) -> Face |
Face t: of cell t / 2, the corner and its two neighbors along, then the corner, the far corner and the neighbor down. |
mesh_midpoint(a: MeshPoint, b: MeshPoint) -> MeshPoint |
Types and structs
Section titled “Types and structs”| Name | Syntax |
|---|---|
IsoLattice |
struct IsoLattice { points: IVec3; origin: Vec3; spacing: Float; level: Float; } |
IsoQuadric |
struct IsoQuadric { ax: Vec3; ay: Vec3; az: Vec3; b: Vec3; mean: Vec4; } |
MeshPoint |
struct MeshPoint { position: Vec3; normal: Vec3; uv: Vec2; } |
Graph presets
Section titled “Graph presets”| Name | Interface | Description |
|---|---|---|
iso |
input samples: Rows<Float>param lattice: IsoLattice = IsoLattice { points: ivec3(2, 2, 2), origin: vec3(0.0, 0.0, 0.0), spacing: 1.0, level: 0.0 }output points <- points.resultoutput faces <- faces.resultoutput point_count <- cells.countoutput quad_count <- edges.count |
The surface where a field crosses a level, as a mesh: samples on a lattice (IsoLattice: points along x, y and z, origin, spacing, level), x fastest; one point a cell the surface crosses and two faces an edge it crosses, closed where the surface stays inside the lattice. Place it with node shape: graph “mesh.entpkg/graphs/iso.esn” { samples <- field.result; lattice = IsoLattice { points: ivec3(64, 64, 64), origin: vec3(-1.0, -1.0, -1.0), spacing: 0.03175, level: 0.0 }; } and draw shape.points with shape.faces; shape.point_count and shape.quad_count say how many of each (faces, two a quad). |
subdivision |
input points: Rows<MeshPoint>input faces: Rows<Face>output points <- split.resultoutput faces <- quartered.result |
Kernel descriptions
Section titled “Kernel descriptions”mesh.iso_crossed_cells@1
Section titled “mesh.iso_crossed_cells@1”One flag a cell: whether the surface crosses it; none for a point on the lattice’s far sides, which has no cell.
| Mode | map |
| Requires | field.read, field.write |
| Inputs | samples: Rows<Float> |
| Params | lattice: IsoLattice = [[2, 2, 2], [0.0, 0.0, 0.0], 1.0, 0.0] |
| Outputs | result: Rows<Int> |
| Source | packages/mesh.entpkg/kernels/iso.ent |
mesh.iso_crossed_edges@1
Section titled “mesh.iso_crossed_edges@1”One flag an edge of the lattice, edge 3 * point + axis from a point to the next along the axis: whether the surface crosses it with the four cells round it inside the lattice.
| Mode | map |
| Requires | field.read, field.write |
| Inputs | samples: Rows<Float> |
| Params | lattice: IsoLattice = [[2, 2, 2], [0.0, 0.0, 0.0], 1.0, 0.0] |
| Outputs | result: Rows<Int> |
| Source | packages/mesh.entpkg/kernels/iso.ent |
mesh.iso_faces@1
Section titled “mesh.iso_faces@1”Two faces a crossed edge, from the crossed edges gathered: the quad of the four cells round it, turned to face out of the inside.
| Mode | map |
| Requires | field.read, field.write |
| Inputs | edges: Rows<Int>, slots: Rows<Int>, samples: Rows<Float>, total: Rows<Int> |
| Params | lattice: IsoLattice = [[2, 2, 2], [0.0, 0.0, 0.0], 1.0, 0.0] |
| Outputs | result: Rows<Face> |
| Source | packages/mesh.entpkg/kernels/iso.ent |
mesh.iso_points@1
Section titled “mesh.iso_points@1”The point of each crossed cell, where the planes of its edges’ crossings meet (iso_quadric_point), its normal the field’s slope there, its uv zero.
| Mode | map |
| Requires | field.read, field.write |
| Inputs | kept: Rows<Int>, samples: Rows<Float>, total: Rows<Int> |
| Params | lattice: IsoLattice = [[2, 2, 2], [0.0, 0.0, 0.0], 1.0, 0.0] |
| Outputs | result: Rows<MeshPoint> |
| Source | packages/mesh.entpkg/kernels/iso.ent |
mesh.iso_slots@1
Section titled “mesh.iso_slots@1”Each crossed cell’s point among the points, from the crossed cells gathered (parallel.entpkg’s compaction), into a row of -1 a cell.
| Mode | scatter into input 1 with max |
| Requires | field.read, field.write |
| Inputs | kept: Rows<Int>, blank: Rows<Int> |
| Params | — |
| Outputs | result: Rows<Int> |
| Source | packages/mesh.entpkg/kernels/iso.ent |
mesh.lattice_faces@1
Section titled “mesh.lattice_faces@1”The faces of a lattice.
| Mode | map |
| Requires | field.write |
| Inputs | — |
| Params | columns: Int = 32, rows: Int = 16, wrap_columns: Bool = False, wrap_rows: Bool = False |
| Outputs | result: Rows<Face> |
| Source | packages/mesh.entpkg/kernels/lattice.ent |
mesh.plane_points@1
Section titled “mesh.plane_points@1”A flat sheet facing up, size across in x and z about the origin, an open lattice.
| Mode | map |
| Requires | field.write |
| Inputs | — |
| Params | size: Vec2 = [2.0, 2.0], columns: Int = 16, rows: Int = 16 |
| Outputs | result: Rows<MeshPoint> |
| Source | packages/mesh.entpkg/kernels/lattice.ent |
mesh.sphere_points@1
Section titled “mesh.sphere_points@1”A sphere of radius about the origin, an open lattice: columns round its middle, rows from the pole below to the pole above.
| Mode | map |
| Requires | field.write |
| Inputs | — |
| Params | radius: Float = 1.0, columns: Int = 33, rows: Int = 17 |
| Outputs | result: Rows<MeshPoint> |
| Source | packages/mesh.entpkg/kernels/lattice.ent |
mesh.split_faces@1
Section titled “mesh.split_faces@1”Each face’s three corners and its middle, over the split points.
| Mode | map |
| Requires | field.read, field.write |
| Inputs | points: Rows<MeshPoint>, faces: Rows<Face> |
| Params | — |
| Outputs | result: Rows<Face> |
| Source | packages/mesh.entpkg/kernels/subdivision.ent |
mesh.split_points@1
Section titled “mesh.split_points@1”The old points, then each face’s midpoints of its edges ab, bc and ca.
| Mode | map |
| Requires | field.read, field.write |
| Inputs | points: Rows<MeshPoint>, faces: Rows<Face> |
| Params | — |
| Outputs | result: Rows<MeshPoint> |
| Source | packages/mesh.entpkg/kernels/subdivision.ent |
mesh.torus_points@1
Section titled “mesh.torus_points@1”A torus about up: its ring’s radius ring, its tube’s tube; columns go round the ring and rows round the tube. Wrapped both ways it has no seam in its points, and its coordinates jump from near 1 back to 0 across the last cells; open both ways, with a column and a row more, its seams lie twice over and its coordinates run 0 to 1 whole.
| Mode | map |
| Requires | field.write |
| Inputs | — |
| Params | ring: Float = 1.0, tube: Float = 0.4, columns: Int = 48, rows: Int = 24, wrap_columns: Bool = True, wrap_rows: Bool = True |
| Outputs | result: Rows<MeshPoint> |
| Source | packages/mesh.entpkg/kernels/lattice.ent |
iso.replay, lattice.replay

