Package net.risingworld.api.assets
Class MeshAsset
java.lang.Object
net.risingworld.api.assets.Asset
net.risingworld.api.assets.MeshAsset
Represents a Mesh which can be populated programmatically. You can set the vertex positions (required), indices (required),
normals (optional), tangents (optional), up to 4 uv channels (optional) and vertex colors (optional).
-
Nested Class Summary
Nested classes/interfaces inherited from class net.risingworld.api.assets.Asset
Asset.Source, Asset.Type
-
Field Summary
Fields inherited from class net.risingworld.api.assets.Asset
DEFAULT_EXTENSION
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
addIndex
(int index) Adds a single index.void
addIndices
(int... indices) Adds an arbitrary number of indices.void
addIndices
(ArrayList<Integer> indices) Adds all provided indices.void
void
addNormals
(ArrayList<Vector3f> normals) void
addTangent
(Vector4f tangent) void
addTangents
(ArrayList<Vector4f> tangents) void
addUV
(float u, float v) void
addUV
(int channel, float u, float v) void
void
void
void
addVertex
(float x, float y, float z) void
void
addVertices
(ArrayList<Vector3f> vertices) void
clear()
Clears all mesh data.static MeshAsset
void
ensureCapacity
(int vertexCount, int indexCount) Resizes all internal list to have enough capacity for the given amount of indices and vertices.int
Gets the amount of indices that are currently set (i.e the length of the internal index list).Gets a reference to the internal indices list.int
getUVs
(int channel) int
Gets the amount of vertices that are currently set (i.e the length of the internal vertex list).void
void
setIndices
(ArrayList<Integer> indices) void
setNormals
(ArrayList<Vector3f> normals) void
setTangents
(ArrayList<Vector4f> tangents) void
void
setVertices
(ArrayList<Vector3f> vertices) void
uploadMeshData
(boolean cleanupData) Updates the mesh data, i.e applies all changes that have been done and syncs the new mesh with all playersMethods inherited from class net.risingworld.api.assets.Asset
dispose, equals, getChecksum, getDependency, getExtension, getHandle, getPath, getSource, getType, hashCode, isDisposed
-
Method Details
-
create
-
ensureCapacity
public void ensureCapacity(int vertexCount, int indexCount) Resizes all internal list to have enough capacity for the given amount of indices and vertices. The lists get resized automatically when adding new vertices, so this method is mostly for reasons of performance.- Parameters:
vertexCount
- the capacity you want to set for the vertex buffers.indexCount
- the capacity you want to set for the index buffer.
-
getVertexCount
public int getVertexCount()Gets the amount of vertices that are currently set (i.e the length of the internal vertex list).- Returns:
- the current vertex count.
-
getIndexCount
public int getIndexCount()Gets the amount of indices that are currently set (i.e the length of the internal index list).- Returns:
- the current indices count.
-
getSubMeshCount
public int getSubMeshCount() -
getIndices
Gets a reference to the internal indices list.- Returns:
- the internal indices list.
-
getVertices
-
getNormals
-
getTangents
-
getUVs
-
getColors
-
addVertex
public void addVertex(float x, float y, float z) -
addVertex
-
addNormal
-
addTangent
-
addUV
public void addUV(float u, float v) -
addUV
-
addUV
public void addUV(int channel, float u, float v) -
addUV
-
addColor
-
addIndex
public void addIndex(int index) Adds a single index. Winding order is clockwise- Parameters:
index
- the index you want to add.
-
addIndices
public void addIndices(int... indices) Adds an arbitrary number of indices. Winding order is clockwise- Parameters:
indices
- the indices you want to add.
-
addIndices
Adds all provided indices. Winding order is clockwise- Parameters:
indices
- a list containing all indices you want to add.
-
addVertices
-
addNormals
-
addTangents
-
addUVs
-
setIndices
-
setVertices
-
setNormals
-
setTangents
-
setUVs
-
setColors
-
clear
public void clear()Clears all mesh data. -
uploadMeshData
public void uploadMeshData(boolean cleanupData) Updates the mesh data, i.e applies all changes that have been done and syncs the new mesh with all players- Parameters:
cleanupData
- if true, the existing data will also be cleaned up after syncing the new mesh. Set to false if you want to keep the data.
-