com.aspose.threed

Interfaces

Classes

Enums

Exceptions

com.aspose.threed

Class TriMesh

  • All Implemented Interfaces:
    java.lang.Iterable<Vertex>


    public class TriMesh
    extends Entity
    implements java.lang.Iterable<Vertex>
    A TriMesh contains raw data that can be used by GPU directly. This class is a utility to help to construct a mesh that only contains per-vertex data.
    • Constructor Detail

      • TriMesh

        protected TriMesh(java.lang.String name)
        Initialize a TriMesh
      • TriMesh

        public TriMesh(java.lang.String name,
                       VertexDeclaration declaration)
        Initialize an instance of TriMesh
        Parameters:
        name - The name of this TriMesh
        declaration - The vertex's declaration
    • Method Detail

      • getVerticesCount

        public int getVerticesCount()
        The count of vertices in this TriMesh
      • getIndicesCount

        public int getIndicesCount()
        The count of indices in this TriMesh
      • getUnmergedVerticesCount

        public int getUnmergedVerticesCount()
        The count of unmerged vertices that passed in by beginVertex() and endVertex().
      • getCapacity

        public int getCapacity()
        The capacity of preallocated vertices.
      • getVerticesSizeInBytes

        public int getVerticesSizeInBytes()
        The total size of all vertices in bytes
      • fromMesh

        public static TriMesh fromMesh(VertexDeclaration declaration,
                                       Mesh mesh)
        Create a TriMesh from given mesh object with given vertex layout.
        Parameters:
        declaration -
        mesh -
      • copyFrom

        public static TriMesh copyFrom(TriMesh input,
                                       VertexDeclaration vd)
        Copy the TriMesh from input with new vertex layout
        Parameters:
        input - The input TriMesh for copying
        vd - The new vertex delcaration of the output TriMesh
        Returns:
        A new TriMesh instance with new vertex declaration.
      • fromMesh

        public static TriMesh fromMesh(Mesh mesh,
                                       boolean useFloat)
        Create a TriMesh from given mesh object, the vertex declaration are based on the input mesh's structure.
        Parameters:
        mesh -
        useFloat - Use float type instead of double type for each vertex element component.
        Returns:
        The TriMesh generated from given Mesh
      • fromMesh

        public static TriMesh fromMesh(Mesh mesh)
        Create a TriMesh from given mesh object, the vertex declaration are based on the input mesh's structure.
        Parameters:
        mesh -
        Returns:
        The TriMesh generated from given Mesh
      • beginVertex

        public Vertex beginVertex()
        Begin adding vertex
        Returns:
        The reference of internal vertex object in type Vertex
      • endVertex

        public void endVertex()
        End adding vertex
      • writeVerticesTo

        public void writeVerticesTo(com.aspose.threed.Stream stream)
                             throws java.io.IOException
        Write vertices data to the specified stream
        Parameters:
        stream - The stream that the vertices data will be written to
        Throws:
        java.io.IOException
      • write16bIndicesTo

        public void write16bIndicesTo(com.aspose.threed.Stream stream)
                               throws java.io.IOException
        Write the indices data as 16bit integer to the stream
        Parameters:
        stream -
        Throws:
        java.io.IOException
      • write32bIndicesTo

        public void write32bIndicesTo(com.aspose.threed.Stream stream)
                               throws java.io.IOException
        Write the indices data as 32bit integer to the stream
        Parameters:
        stream -
        Throws:
        java.io.IOException
      • verticesToArray

        public byte[] verticesToArray()
        Convert the vertices data to byte array
      • indicesToArray

        public void indicesToArray(short[][] result)
        Convert the indices to 16bit integer array
        Parameters:
        result -
      • indicesToArray

        public void indicesToArray(int[][] result)
        Convert the indices to 32bit integer array
        Parameters:
        result -
      • toString

        public java.lang.String toString()
        Gets the string representation of TriMesh
        Overrides:
        toString in class java.lang.Object
      • fromRawData

        public static TriMesh fromRawData(VertexDeclaration vd,
                                          byte[] vertices,
                                          int[] indices,
                                          boolean generateVertexMapping)
        Create TriMesh from raw data
        Parameters:
        vd - Vertex declaration, must contains at least one field.
        vertices - The input vertex data, the minimum length of the vertices must be greater or equal to vertex declaration's size
        indices - The triangle indices
        generateVertexMapping - Generate Vertex for each vertex, which is not necessary for just serialization/deserialization.
        Returns:
        The TriMesh instance that encapsulated the input byte array.
      • iterator

        public java.util.Iterator<Vertex> iterator()
        Get the enumerator to enumerate Vertex
        Specified by:
        iterator in interface java.lang.Iterable<Vertex>