Package com.aspose.threed
Class TriMesh
- java.lang.Object
-
- com.aspose.threed.A3DObject
-
- com.aspose.threed.SceneObject
-
- com.aspose.threed.Entity
-
- com.aspose.threed.TriMesh
-
- All Implemented Interfaces:
INamedObject
,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.
-
-
Field Summary
-
Fields inherited from class com.aspose.threed.A3DObject
name, properties
-
-
Constructor Summary
Constructors Constructor Description TriMesh(java.lang.String name, VertexDeclaration declaration)
Initialize an instance ofTriMesh
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Vertex
beginVertex()
Begin adding vertexstatic TriMesh
copyFrom(TriMesh input, VertexDeclaration vd)
Copy theTriMesh
from input with new vertex layoutvoid
endVertex()
End adding vertexstatic TriMesh
fromMesh(Mesh mesh)
Create a TriMesh from given mesh object, the vertex declaration are based on the input mesh's structure.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.static TriMesh
fromMesh(VertexDeclaration declaration, Mesh mesh)
Create a TriMesh from given mesh object with given vertex layout.static TriMesh
fromRawData(VertexDeclaration vd, byte[] vertices, int[] indices, boolean generateVertexMapping)
Create TriMesh from raw dataint
getCapacity()
The capacity of pre-allocated vertices.int
getIndicesCount()
The count of indices in thisTriMesh
int[]
getIntIndices()
Convert the indices to 32bit integer arrayshort[]
getShortIndices()
Convert the indices to 16bit integer arrayint
getUnmergedVerticesCount()
The count of unmerged vertices that passed in bybeginVertex()
andendVertex()
.VertexDeclaration
getVertexDeclaration()
The vertex layout of theTriMesh
.int
getVerticesCount()
The count of vertices in thisTriMesh
int
getVerticesSizeInBytes()
The total size of all vertices in bytesvoid
indicesToArray(int[][] result)
Deprecated.void
indicesToArray(short[][] result)
Deprecated.java.util.Iterator<Vertex>
iterator()
Get the enumerator to enumerateVertex
void
loadVerticesFromBytes(byte[] verticesInBytes)
Load vertices from bytes, the length of bytes must be an integer multiple of vertex size.double
readDouble(int idx, VertexField field)
Read the double fieldfloat
readFloat(int idx, VertexField field)
Read the float fieldFVector2
readFVector2(int idx, VertexField field)
Read the vector2 fieldFVector3
readFVector3(int idx, VertexField field)
Read the vector3 fieldFVector4
readFVector4(int idx, VertexField field)
Read the vector4 fieldVector2
readVector2(int idx, VertexField field)
Read the vector2 fieldVector3
readVector3(int idx, VertexField field)
Read the vector3 fieldVector4
readVector4(int idx, VertexField field)
Read the vector4 fieldjava.lang.String
toString()
Gets the string representation ofTriMesh
byte[]
verticesToArray()
Convert the vertices data to byte arrayvoid
write16bIndicesTo(com.aspose.threed.Stream stream)
Write the indices data as 16bit integer to the streamvoid
write32bIndicesTo(com.aspose.threed.Stream stream)
Write the indices data as 32bit integer to the streamvoid
writeVerticesTo(com.aspose.threed.Stream stream)
Write vertices data to the specified stream-
Methods inherited from class com.aspose.threed.Entity
getBoundingBox, getEntityRendererKey, getExcluded, getParentNode, getParentNodes, setExcluded, setParentNode
-
Methods inherited from class com.aspose.threed.SceneObject
getScene
-
Methods inherited from class com.aspose.threed.A3DObject
findProperty, getName, getProperties, getProperty, removeProperty, removeProperty, setName, setProperty
-
-
-
-
Constructor Detail
-
TriMesh
public TriMesh(java.lang.String name, VertexDeclaration declaration)
Initialize an instance ofTriMesh
- Parameters:
name
- The name of this TriMeshdeclaration
- The vertex's declaration
-
-
Method Detail
-
getVertexDeclaration
public VertexDeclaration getVertexDeclaration()
The vertex layout of theTriMesh
.
-
getVerticesCount
public int getVerticesCount()
The count of vertices in thisTriMesh
-
getIndicesCount
public int getIndicesCount()
The count of indices in thisTriMesh
-
getUnmergedVerticesCount
public int getUnmergedVerticesCount()
The count of unmerged vertices that passed in bybeginVertex()
andendVertex()
.
-
getCapacity
public int getCapacity()
The capacity of pre-allocated 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 theTriMesh
from input with new vertex layout- Parameters:
input
- The input TriMesh for copyingvd
- The new vertex declaration 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.
-
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.
-
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
@Deprecated public void indicesToArray(short[][] result)
Deprecated.Convert the indices to 16bit integer array- Parameters:
result
-
-
getShortIndices
public short[] getShortIndices()
Convert the indices to 16bit integer array
-
getIntIndices
public int[] getIntIndices()
Convert the indices to 32bit integer array
-
indicesToArray
@Deprecated public void indicesToArray(int[][] result)
Deprecated.Convert the indices to 32bit integer array- Parameters:
result
-
-
toString
public java.lang.String toString()
Gets the string representation ofTriMesh
- Overrides:
toString
in classjava.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 sizeindices
- The triangle indicesgenerateVertexMapping
- GenerateVertex
for each vertex, which is not necessary for just serialization/deserialization.- Returns:
- The
TriMesh
instance that encapsulated the input byte array.
-
loadVerticesFromBytes
public void loadVerticesFromBytes(byte[] verticesInBytes)
Load vertices from bytes, the length of bytes must be an integer multiple of vertex size.- Parameters:
verticesInBytes
-- Throws:
java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
-
readVector4
public Vector4 readVector4(int idx, VertexField field)
Read the vector4 field- Parameters:
idx
- The index of vertex to readfield
- The field with a Vector4/FVector4 data type
-
readFVector4
public FVector4 readFVector4(int idx, VertexField field)
Read the vector4 field- Parameters:
idx
- The index of vertex to readfield
- The field with a Vector4/FVector4 data type
-
readVector3
public Vector3 readVector3(int idx, VertexField field)
Read the vector3 field- Parameters:
idx
- The index of vertex to readfield
- The field with a Vector3/FVector3 data type
-
readFVector3
public FVector3 readFVector3(int idx, VertexField field)
Read the vector3 field- Parameters:
idx
- The index of vertex to readfield
- The field with a Vector3/FVector3 data type
-
readVector2
public Vector2 readVector2(int idx, VertexField field)
Read the vector2 field- Parameters:
idx
- The index of vertex to readfield
- The field with a Vector2/FVector2 data type
-
readFVector2
public FVector2 readFVector2(int idx, VertexField field)
Read the vector2 field- Parameters:
idx
- The index of vertex to readfield
- The field with a Vector2/FVector2 data type
-
readDouble
public double readDouble(int idx, VertexField field)
Read the double field- Parameters:
idx
- The index of vertex to readfield
- The field with a float/double compatible data type
-
readFloat
public float readFloat(int idx, VertexField field)
Read the float field- Parameters:
idx
- The index of vertex to readfield
- The field with a float/double compatible data type
-
-