public class MeshPart extends Object
Mesh
, along with the primitive type. The vertices subset is
described by an offset and size. When the mesh is indexed (which is when Mesh.getNumIndices()
> 0), then the
indexOffset
represents the offset in the indices array and numVertices
represents the number of indices. When
the mesh isn't indexed, then the indexOffset
member represents the offset in the vertices array and the
numVertices
member represents the number of vertices.
In other words: Regardless whether the mesh is indexed or not, when primitiveType
is not a strip, then
numVertices
equals the number of primitives multiplied by the number of vertices per primitive. So if the MeshPart
represents 4 triangles (primitiveType
is GL_TRIANGLES), then the numVertices
member is 12 (4 triangles * 3
vertices = 12 vertices total). Likewise, if the part represents 12 lines (primitiveType
is GL_LINES), then the size is
24 (12 lines * 2 vertices = 24 vertices total).
Note that some classes might require the mesh (part) to be indexed.
The Mesh
referenced by the mesh
member must outlive the MeshPart. When the mesh is disposed, the MeshPart is
unusable.Modifier and Type | Field and Description |
---|---|
String |
id
Unique id within model, may be null.
|
int |
indexOffset
The offset in the
mesh to this part. |
Mesh |
mesh
The Mesh the part references, also stored in
Model |
int |
numVertices
The size (in total number of vertices) of this part in the
mesh . |
int |
primitiveType
The primitive type, OpenGL constant e.g:
GL20.GL_TRIANGLES , GL20.GL_POINTS , GL20.GL_LINES ,
GL20.GL_LINE_STRIP , GL20.GL_TRIANGLE_STRIP |
Constructor and Description |
---|
MeshPart()
Construct a new MeshPart, with null values.
|
MeshPart(MeshPart copyFrom)
Construct a new MeshPart which is an exact copy of the provided MeshPart.
|
MeshPart(String id,
Mesh mesh,
int offset,
int size,
int type)
Construct a new MeshPart and set all its values.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(MeshPart other)
Compares this MeshPart to the specified MeshPart and returns true if they both reference the same
Mesh and the
indexOffset , numVertices and primitiveType members are equal. |
boolean |
equals(Object arg0) |
public String id
equals(MeshPart)
public int primitiveType
GL20.GL_TRIANGLES
, GL20.GL_POINTS
, GL20.GL_LINES
,
GL20.GL_LINE_STRIP
, GL20.GL_TRIANGLE_STRIP
public int indexOffset
mesh
to this part. If the mesh is indexed (Mesh.getNumIndices()
> 0), this is the offset
in the indices array, otherwise it is the offset in the vertices array.public int numVertices
mesh
. When the mesh is indexed (
Mesh.getNumIndices()
> 0), this is the number of indices, otherwise it is the number of vertices.public MeshPart()
public MeshPart(String id, Mesh mesh, int offset, int size, int type)
id
- The id of the new part, may be null.mesh
- The mesh which holds all vertices and (optional) indices of this part.offset
- The offset within the mesh to this part.size
- The size (in total number of vertices) of the part.type
- The primitive type of the part (e.g. GL_TRIANGLES, GL_LINE_STRIP, etc.).public MeshPart(MeshPart copyFrom)
copyFrom
- The MeshPart to copy.public boolean equals(MeshPart other)
Mesh
and the
indexOffset
, numVertices
and primitiveType
members are equal. The id
member is ignored.other
- The other MeshPart to compare this MeshPart to.id
member), false otherwise.Copyright © 2014. All rights reserved.