Mesh¶
Namespace Nfty.Model in assembly Nfty.Model.
A triangle mesh: what Riser builds, what the writers serialize, and what the step-6 preview rasterizes. Immutable — every array is copied in and exposed read-only — and every derived value is computed in the constructor, never lazily (mixel's D7), so one mesh may be read from many threads.
Remarks¶
Vertex rule. A vertex is shared only by the two triangles of its own quad: four vertices and six indices per quad, so Mesh.VertexCount is always twice Mesh.TriangleCount for a risen mesh. Vertices that share a position across quads are NOT merged — their normals and UVs differ per face, and a merge keyed on position alone would be wrong. Whether a merge keyed on (position, normal, uv) is worth its complexity is a size question answered by RisePerfTests' measurement, not assumed.
Coordinates follow glTF: +Y up, +Z toward the viewer. Texture coordinates put (0,0) at the image's top-left, so v grows downward with the image row.
Constructors¶
Mesh(float[], float[], float[], uint[], int, int)¶
public Mesh(float[] positions, float[] normals, float[] texCoords, uint[] indices, int textureWidth, int textureHeight);
Builds a mesh, copying every array.
Parameters
positions(float[]) - xyz per vertex.normals(float[]) - One xyz unit normal per vertex.texCoords(float[]) - One uv per vertex.indices(uint[]) - Three vertex indices per triangle, counter-clockwise seen from outside.textureWidth(int) - Width of the image the UVs address.textureHeight(int) - Height of the image the UVs address.
Exceptions
ArgumentException- The arrays disagree about the vertex count, an index names no vertex, or a position is not finite.
Properties¶
Indices¶
Three vertex indices per triangle, counter-clockwise seen from outside.
Max¶
The largest x, y and z over every vertex — glTF's POSITION max.
Min¶
The smallest x, y and z over every vertex — exactly the values glTF's POSITION accessor must carry as min.
Normals¶
One xyz unit normal per vertex, pointing out of the solid.
Positions¶
xyz per vertex, in world units.
TexCoords¶
One uv per vertex; (0,0) is the texture's top-left.
TextureHeight¶
Height of the image the UVs address.
TextureWidth¶
Width of the image the UVs address; a writer refuses a texture of another size.
TriangleCount¶
How many triangles the mesh has.
VertexCount¶
How many vertices the mesh has.