Class MeshData
VertexAttribute plus a triangle
index list. Upload it once with Graphics3D.upload(...) to get a
GpuMesh. VertexAttribute.POSITION is required. All attributes
must have the same vertex count.
Geometry that changes every frame uploads once with
MeshUsage.DYNAMIC and is rewritten through GpuMesh.update(limn.render3d.MeshData). Such
a producer sizes its arrays to the worst case, rewrites them in place, and calls
counts(int, int) to say how much of them is live this frame, so a frame costs no
allocation at all. The arrays are held by reference, never copied, which is what
makes writing into them afterwards work.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbounds()Object-space bounds over the live prefix ofVertexAttribute.POSITION.counts(int vertexCount, int indexCount) Narrows this mesh to a live prefix: the firstvertexCountvertices of every attribute array and the firstindexCountentries of the index list.float[]get(VertexAttribute attribute) The backing array forattribute: the whole capacity, not the live prefix.booleanhas(VertexAttribute attribute) Whether one attribute is present, what a shader checks before binding it.intLive indices: what an upload draws.int[]indices()The backing index array: the whole capacity, not the live prefix.indices(int[] triangleIndices) Sets the triangle index buffer; three consecutive indices are one triangle.Which vertex attributes this mesh actually carries.put(VertexAttribute attribute, float[] data) Adds/replaces an attribute; its length must bevertexCount × components.intVertices the backing arrays hold; equalsvertexCount()unless narrowed.intLive vertices: what an upload reads, and whatbounds()measures.
-
Constructor Details
-
MeshData
public MeshData()
-
-
Method Details
-
put
Adds/replaces an attribute; its length must bevertexCount × components. -
indices
Sets the triangle index buffer; three consecutive indices are one triangle. -
counts
Narrows this mesh to a live prefix: the firstvertexCountvertices of every attribute array and the firstindexCountentries of the index list. Everything past the prefix is capacity, and is ignored byvertexCount(),indexCount(),bounds()and by an upload.This is how a per-frame producer avoids reallocating: size the arrays once to the worst case, write this frame's data into the front of them, and declare how much is live.
put(limn.render3d.VertexAttribute, float[])andindicesreset the prefix to the whole array (they are describing new backing storage), so callcountslast.Leaving stale data past the prefix is not merely wasteful, it is wrong if anything reads it: last frame's vertex sitting at a far-away position would inflate
bounds(), and nothing about the picture would look off while picking and shadow fitting quietly used the bigger box. Hence the prefix.- Throws:
IllegalArgumentException- if either count is negative or exceeds capacity
-
presentAttributes
Which vertex attributes this mesh actually carries. -
has
Whether one attribute is present, what a shader checks before binding it. -
get
The backing array forattribute: the whole capacity, not the live prefix. -
vertexCount
public int vertexCount()Live vertices: what an upload reads, and whatbounds()measures. -
vertexCapacity
public int vertexCapacity()Vertices the backing arrays hold; equalsvertexCount()unless narrowed. -
indices
public int[] indices()The backing index array: the whole capacity, not the live prefix. -
indexCount
public int indexCount()Live indices: what an upload draws. -
bounds
Object-space bounds over the live prefix ofVertexAttribute.POSITION.
-