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 TypeMethodDescriptionvoidvoidaddIndex(int index) Adds a single index.voidaddIndices(int... indices) Adds an arbitrary number of indices.voidaddIndices(ArrayList<Integer> indices) Adds all provided indices.voidvoidaddNormals(ArrayList<Vector3f> normals) voidaddTangent(Vector4f tangent) voidaddTangents(ArrayList<Vector4f> tangents) voidaddUV(float u, float v) voidaddUV(int channel, float u, float v) voidvoidvoidvoidaddVertex(float x, float y, float z) voidvoidaddVertices(ArrayList<Vector3f> vertices) voidclear()Clears all mesh data.static MeshAssetvoidensureCapacity(int vertexCount, int indexCount) Resizes all internal list to have enough capacity for the given amount of indices and vertices.intGets 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.intgetUVs(int channel) intGets the amount of vertices that are currently set (i.e the length of the internal vertex list).voidvoidsetIndices(ArrayList<Integer> indices) voidsetNormals(ArrayList<Vector3f> normals) voidsetTangents(ArrayList<Vector4f> tangents) voidvoidsetVertices(ArrayList<Vector3f> vertices) voiduploadMeshData(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.
-