Class MeshAsset

java.lang.Object
net.risingworld.api.assets.Asset
net.risingworld.api.assets.MeshAsset

public class MeshAsset extends Asset
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).
  • Method Details

    • create

      public static MeshAsset create(String name, int initialVertexCount, int initialIndexCount)
    • 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

      public ArrayList<Integer> getIndices()
      Gets a reference to the internal indices list.
      Returns:
      the internal indices list.
    • getVertices

      public ArrayList<Vector3f> getVertices()
    • getNormals

      public ArrayList<Vector3f> getNormals()
    • getTangents

      public ArrayList<Vector4f> getTangents()
    • getUVs

      public ArrayList<Vector2f> getUVs(int channel)
    • getColors

      public ArrayList<ColorRGBA> getColors()
    • addVertex

      public void addVertex(float x, float y, float z)
    • addVertex

      public void addVertex(Vector3f vertex)
    • addNormal

      public void addNormal(Vector3f normal)
    • addTangent

      public void addTangent(Vector4f tangent)
    • addUV

      public void addUV(float u, float v)
    • addUV

      public void addUV(Vector2f uv)
    • addUV

      public void addUV(int channel, float u, float v)
    • addUV

      public void addUV(int channel, Vector2f uv)
    • addColor

      public void addColor(ColorRGBA color)
    • 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

      public void addIndices(ArrayList<Integer> indices)
      Adds all provided indices. Winding order is clockwise
      Parameters:
      indices - a list containing all indices you want to add.
    • addVertices

      public void addVertices(ArrayList<Vector3f> vertices)
    • addNormals

      public void addNormals(ArrayList<Vector3f> normals)
    • addTangents

      public void addTangents(ArrayList<Vector4f> tangents)
    • addUVs

      public void addUVs(int channel, ArrayList<Vector2f> uvs)
    • setIndices

      public void setIndices(ArrayList<Integer> indices)
    • setVertices

      public void setVertices(ArrayList<Vector3f> vertices)
    • setNormals

      public void setNormals(ArrayList<Vector3f> normals)
    • setTangents

      public void setTangents(ArrayList<Vector4f> tangents)
    • setUVs

      public void setUVs(int channel, ArrayList<Vector2f> uvs)
    • setColors

      public void setColors(ArrayList<ColorRGBA> colors)
    • 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.