Mesh

Inheritance: java.lang.Object, com.aspose.threed.A3DObject, com.aspose.threed.SceneObject, com.aspose.threed.Entity, com.aspose.threed.Geometry

All Implemented Interfaces: java.lang.Iterable, com.aspose.threed.IMeshConvertible

public class Mesh extends Geometry implements Iterable<int[]>, IMeshConvertible

A mesh is made of many n-sided polygons. Example: To add a polygon in mesh:

Mesh mesh = new Mesh();
  int[] indices = new int[] {0, 1, 2};
  mesh.createPolygon(indices);

Travel through all polygons in mesh:

Mesh mesh = new Mesh();
  for(int[] polygon : mesh)
  {
      //deal with polygon
  }

Constructors

ConstructorDescription
Mesh()Initializes a new instance of the Mesh class.
Mesh(String name)Initializes a new instance of the Mesh class.

Methods

MethodDescription
getDeformers2()Gets all deformers with specified deformer types
addElement(VertexElement element)Adds an existing vertex element to current geometry
clone()
createElement(VertexElementType type)Creates a vertex element with specified type and add it to the geometry.
createElement(VertexElementType type, MappingMode mappingMode, ReferenceMode referenceMode)Creates a vertex element with specified type and add it to the geometry.
createElementUV(TextureMapping uvMapping)Creates a VertexElementUV with given texture mapping type.
createElementUV(TextureMapping uvMapping, MappingMode mappingMode, ReferenceMode referenceMode)Creates a VertexElementUV with given texture mapping type.
createPolygon(int v1, int v2, int v3)Create a polygon with 3 vertices(triangle)
createPolygon(int v1, int v2, int v3, int v4)Create a polygon with 4 vertices(quad)
createPolygon(int[] indices)Creates a new polygon with all vertices defined in indices.
createPolygon(int[] indices, int offset, int length)Creates a new polygon with all vertices defined in indices.
difference(Mesh a, Mesh b)Calculate the difference of two meshes
doBoolean(BooleanOperation op, Mesh a, Matrix4 transformA, Mesh b, Matrix4 transformB)Perform Boolean operation on two meshes
equals(Object arg0)
findProperty(String propertyName)Finds the property.
getBoundingBox()Gets the bounding box of current entity in its object space coordinate system.
getCastShadows()Gets whether this geometry can cast shadow
getClass()
getControlPoints()Gets all control points
getDeformers()Gets all deformers associated with this geometry.
getEdges()Gets edges of the Mesh.
getElement(VertexElementType type)Gets a vertex element with specified type
getEntityRendererKey()Gets the key of the entity renderer registered in the renderer
getExcluded()Gets whether to exclude this entity during exporting.
getName()Gets the name.
getParentNode()Gets the first parent node, if set the first parent node, this entity will be detached from other parent nodes.
getParentNodes()Gets all parent nodes, an entity can be attached to multiple parent nodes for geometry instancing
getPolygonCount()Gets the count of polygons
getPolygonSize(int index)Gets the vertex count of the specified polygon.
getPolygons()Gets the polygons definition of the mesh
getProperties()Gets the collection of all properties.
getProperty(String property)Get the value of specified property
getReceiveShadows()Gets whether this geometry can receive shadow.
getScene()Gets the scene that this object belongs to
getVertexElementOfUV(TextureMapping textureMapping)Gets a VertexElementUV instance with given texture mapping type
getVertexElements()Gets all vertex elements
getVisible()Gets if the geometry is visible
hashCode()
intersect(Mesh a, Mesh b)Calculate the intersection of two meshes
iterator()Gets the enumerator for each inner polygons.
notify()
notifyAll()
optimize(boolean vertexElements)Optimize the mesh’s memory usage by eliminating duplicated control points
removeProperty(Property property)Removes a dynamic property.
removeProperty(String property)Remove the specified property identified by name
setCastShadows(boolean value)Sets whether this geometry can cast shadow
setExcluded(boolean value)Sets whether to exclude this entity during exporting.
setName(String value)Sets the name.
setParentNode(Node value)Sets the first parent node, if set the first parent node, this entity will be detached from other parent nodes.
setProperty(String property, Object value)Sets the value of specified property
setReceiveShadows(boolean value)Sets whether this geometry can receive shadow.
setVisible(boolean value)Sets if the geometry is visible
toMesh()Gets the Mesh instance from current entity.
toString()
triangulate()Return triangulated mesh
union(Mesh a, Mesh b)Calculate the union of two meshes
wait()
wait(long arg0)
wait(long arg0, int arg1)

Mesh()

public Mesh()

Initializes a new instance of the Mesh class.

Mesh(String name)

public Mesh(String name)

Initializes a new instance of the Mesh class.

Parameters:

ParameterTypeDescription
namejava.lang.StringName.

getDeformers2()

public Collection<T> <T>getDeformers2()

Gets all deformers with specified deformer types

Returns: java.util.Collection - Deformer collection

addElement(VertexElement element)

public void addElement(VertexElement element)

Adds an existing vertex element to current geometry

Parameters:

ParameterTypeDescription
elementVertexElementThe vertex element to add

clone()

public Mesh clone()

Returns: Mesh

createElement(VertexElementType type)

public VertexElement createElement(VertexElementType type)

Creates a vertex element with specified type and add it to the geometry.

Parameters:

ParameterTypeDescription
typeVertexElementTypeVertex element type

Returns: VertexElement - Created element. Remarks: If type is VertexElementType.UV, a VertexElementUV with texture mapping type to TextureMapping.DIFFUSE will be created.

createElement(VertexElementType type, MappingMode mappingMode, ReferenceMode referenceMode)

public VertexElement createElement(VertexElementType type, MappingMode mappingMode, ReferenceMode referenceMode)

Creates a vertex element with specified type and add it to the geometry.

Parameters:

ParameterTypeDescription
typeVertexElementTypeVertex element type
mappingModeMappingModeDefault mapping mode
referenceModeReferenceModeDefault reference mode

Returns: VertexElement - Created element. Remarks: If type is VertexElementType.UV, a VertexElementUV with texture mapping type to TextureMapping.DIFFUSE will be created.

createElementUV(TextureMapping uvMapping)

public VertexElementUV createElementUV(TextureMapping uvMapping)

Creates a VertexElementUV with given texture mapping type.

Parameters:

ParameterTypeDescription
uvMappingTextureMappingWhich texture mapping type to create

Returns: VertexElementUV - Created element uv

createElementUV(TextureMapping uvMapping, MappingMode mappingMode, ReferenceMode referenceMode)

public VertexElementUV createElementUV(TextureMapping uvMapping, MappingMode mappingMode, ReferenceMode referenceMode)

Creates a VertexElementUV with given texture mapping type.

Parameters:

ParameterTypeDescription
uvMappingTextureMappingWhich texture mapping type to create
mappingModeMappingModeDefault mapping mode
referenceModeReferenceModeDefault reference mode

Returns: VertexElementUV - Created element uv

createPolygon(int v1, int v2, int v3)

public void createPolygon(int v1, int v2, int v3)

Create a polygon with 3 vertices(triangle)

Parameters:

ParameterTypeDescription
v1intIndex of the first vertex
v2intIndex of the second vertex
v3intIndex of the third vertex

createPolygon(int v1, int v2, int v3, int v4)

public void createPolygon(int v1, int v2, int v3, int v4)

Create a polygon with 4 vertices(quad)

Parameters:

ParameterTypeDescription
v1intIndex of the first vertex
v2intIndex of the second vertex
v3intIndex of the third vertex
v4intIndex of the fourth vertex

createPolygon(int[] indices)

public void createPolygon(int[] indices)

Creates a new polygon with all vertices defined in indices. To create polygon vertex by vertex, please use PolygonBuilder.

Parameters:

ParameterTypeDescription
indicesint[]Array of the polygon indices, each index points to a control point that forms the polygon. Example:
int[] indices = new int[] {0, 1, 2};
  mesh.createPolygon(indices);
``` |

### createPolygon(int[] indices, int offset, int length) {#createPolygon-int---int-int-}

public void createPolygon(int[] indices, int offset, int length)



Creates a new polygon with all vertices defined in `indices`. To create polygon vertex by vertex, please use [PolygonBuilder](../../com.aspose.threed/polygonbuilder).

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| indices | int[] | Array of the polygon indices, each index points to a control point that forms the polygon. |
| offset | int | The offset of the first polygon index |
| length | int | The length of the indices **Example:**

int[] indices = new int[] {0, 1, 2}; mesh.createPolygon(indices);


### difference(Mesh a, Mesh b) {#difference-com.aspose.threed.Mesh-com.aspose.threed.Mesh-}

public static Mesh difference(Mesh a, Mesh b)



Calculate the difference of two meshes

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| a | [Mesh](../../com.aspose.threed/mesh) | First mesh |
| b | [Mesh](../../com.aspose.threed/mesh) | Second mesh |

**Returns:**
[Mesh](../../com.aspose.threed/mesh) - Result mesh
### doBoolean(BooleanOperation op, Mesh a, Matrix4 transformA, Mesh b, Matrix4 transformB) {#doBoolean-com.aspose.threed.BooleanOperation-com.aspose.threed.Mesh-com.aspose.threed.Matrix4-com.aspose.threed.Mesh-com.aspose.threed.Matrix4-}

public static Mesh doBoolean(BooleanOperation op, Mesh a, Matrix4 transformA, Mesh b, Matrix4 transformB)



Perform Boolean operation on two meshes

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| op | [BooleanOperation](../../com.aspose.threed/booleanoperation) | The Boolean operation type. |
| a | [Mesh](../../com.aspose.threed/mesh) | First mesh to operate. |
| transformA | [Matrix4](../../com.aspose.threed/matrix4) | Transformation matrix of the first mesh |
| b | [Mesh](../../com.aspose.threed/mesh) | Second mesh to operate |
| transformB | [Matrix4](../../com.aspose.threed/matrix4) | Transformation matrix of the second mesh |

**Returns:**
[Mesh](../../com.aspose.threed/mesh) - The result mesh
### equals(Object arg0) {#equals-java.lang.Object-}

public boolean equals(Object arg0)





**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| arg0 | java.lang.Object |  |

**Returns:**
boolean
### findProperty(String propertyName) {#findProperty-java.lang.String-}

public Property findProperty(String propertyName)



Finds the property. It can be a dynamic property (Created by CreateDynamicProperty/SetProperty) or native property(Identified by its name)

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| propertyName | java.lang.String | Property name. |

**Returns:**
[Property](../../com.aspose.threed/property) - The property.
### getBoundingBox() {#getBoundingBox--}

public BoundingBox getBoundingBox()



Gets the bounding box of current entity in its object space coordinate system. **Example:** The following code shows how to calculate the bounding box of a shape

Entity entity = new Sphere(); entity.setRadius(10); var bbox = entity.getBoundingBox(); System.out.printf(“The bounding box of the entity is %s ~ %s”, bbox.getMinimum(), bbox.getMaximum());


**Returns:**
[BoundingBox](../../com.aspose.threed/boundingbox)
### getCastShadows() {#getCastShadows--}

public boolean getCastShadows()



Gets whether this geometry can cast shadow

**Returns:**
boolean
### getClass() {#getClass--}

public final native Class getClass()





**Returns:**
java.lang.Class<?>
### getControlPoints() {#getControlPoints--}

public List getControlPoints()



Gets all control points

**Returns:**
java.util.List<com.aspose.threed.Vector4>
### getDeformers() {#getDeformers--}

public List getDeformers()



Gets all deformers associated with this geometry.

**Returns:**
java.util.List<com.aspose.threed.Deformer>
### getEdges() {#getEdges--}

public List getEdges()



Gets edges of the Mesh. Edge is optional in mesh, so it can be empty.

**Returns:**
java.util.List<java.lang.Integer>
### getElement(VertexElementType type) {#getElement-com.aspose.threed.VertexElementType-}

public VertexElement getElement(VertexElementType type)



Gets a vertex element with specified type

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| type | [VertexElementType](../../com.aspose.threed/vertexelementtype) | which vertex element type to find |

**Returns:**
[VertexElement](../../com.aspose.threed/vertexelement) - [VertexElement](../../com.aspose.threed/vertexelement) instance if found, otherwise null will be returned.
### getEntityRendererKey() {#getEntityRendererKey--}

public EntityRendererKey getEntityRendererKey()



Gets the key of the entity renderer registered in the renderer

**Returns:**
[EntityRendererKey](../../com.aspose.threed/entityrendererkey)
### getExcluded() {#getExcluded--}

public boolean getExcluded()



Gets whether to exclude this entity during exporting.

**Returns:**
boolean
### getName() {#getName--}

public String getName()



Gets the name.

**Returns:**
java.lang.String
### getParentNode() {#getParentNode--}

public Node getParentNode()



Gets the first parent node, if set the first parent node, this entity will be detached from other parent nodes.

**Returns:**
[Node](../../com.aspose.threed/node)
### getParentNodes() {#getParentNodes--}

public ArrayList getParentNodes()



Gets all parent nodes, an entity can be attached to multiple parent nodes for geometry instancing

**Returns:**
java.util.ArrayList<com.aspose.threed.Node>
### getPolygonCount() {#getPolygonCount--}

public int getPolygonCount()



Gets the count of polygons

**Returns:**
int
### getPolygonSize(int index) {#getPolygonSize-int-}

public int getPolygonSize(int index)



Gets the vertex count of the specified polygon.

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| index | int | Index. |

**Returns:**
int - The polygon size.
### getPolygons() {#getPolygons--}

public List<int[]> getPolygons()



Gets the polygons definition of the mesh

**Returns:**
java.util.List<int[]>
### getProperties() {#getProperties--}

public PropertyCollection getProperties()



Gets the collection of all properties.

**Returns:**
[PropertyCollection](../../com.aspose.threed/propertycollection)
### getProperty(String property) {#getProperty-java.lang.String-}

public Object getProperty(String property)



Get the value of specified property

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| property | java.lang.String | Property name |

**Returns:**
java.lang.Object - The value of the found property
### getReceiveShadows() {#getReceiveShadows--}

public boolean getReceiveShadows()



Gets whether this geometry can receive shadow.

**Returns:**
boolean
### getScene() {#getScene--}

public Scene getScene()



Gets the scene that this object belongs to

**Returns:**
[Scene](../../com.aspose.threed/scene)
### getVertexElementOfUV(TextureMapping textureMapping) {#getVertexElementOfUV-com.aspose.threed.TextureMapping-}

public VertexElementUV getVertexElementOfUV(TextureMapping textureMapping)



Gets a [VertexElementUV](../../com.aspose.threed/vertexelementuv) instance with given texture mapping type

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| textureMapping | [TextureMapping](../../com.aspose.threed/texturemapping) |  |

**Returns:**
[VertexElementUV](../../com.aspose.threed/vertexelementuv) - VertexElementUV with the texture mapping type
### getVertexElements() {#getVertexElements--}

public List getVertexElements()



Gets all vertex elements

**Returns:**
java.util.List<com.aspose.threed.VertexElement>
### getVisible() {#getVisible--}

public boolean getVisible()



Gets if the geometry is visible

**Returns:**
boolean
### hashCode() {#hashCode--}

public native int hashCode()





**Returns:**
int
### intersect(Mesh a, Mesh b) {#intersect-com.aspose.threed.Mesh-com.aspose.threed.Mesh-}

public static Mesh intersect(Mesh a, Mesh b)



Calculate the intersection of two meshes

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| a | [Mesh](../../com.aspose.threed/mesh) | First mesh |
| b | [Mesh](../../com.aspose.threed/mesh) | Second mesh |

**Returns:**
[Mesh](../../com.aspose.threed/mesh) - Result mesh
### iterator() {#iterator--}

public Iterator<int[]> iterator()



Gets the enumerator for each inner polygons.

**Returns:**
java.util.Iterator<int[]> - The enumerator.
### notify() {#notify--}

public final native void notify()





### notifyAll() {#notifyAll--}

public final native void notifyAll()





### optimize(boolean vertexElements) {#optimize-boolean-}

public Mesh optimize(boolean vertexElements)



Optimize the mesh's memory usage by eliminating duplicated control points

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| vertexElements | boolean | Optimize duplicated vertex element data |

**Returns:**
[Mesh](../../com.aspose.threed/mesh) - New mesh instance with compact memory usage **Example:** The following code shows how to eliminate duplicated control points from an unoptimized mesh:

//Sphere.ToMesh generates 117 control points Mesh mesh = (new Sphere()).toMesh(); //After optimized, there’re only 86 control points, polygon indices are also remapped. Mesh optimized = mesh.optimize(true);

### removeProperty(Property property) {#removeProperty-com.aspose.threed.Property-}

public boolean removeProperty(Property property)



Removes a dynamic property.

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| property | [Property](../../com.aspose.threed/property) | Which property to remove |

**Returns:**
boolean - true if the property is successfully removed
### removeProperty(String property) {#removeProperty-java.lang.String-}

public boolean removeProperty(String property)



Remove the specified property identified by name

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| property | java.lang.String |  |

**Returns:**
boolean
### setCastShadows(boolean value) {#setCastShadows-boolean-}

public void setCastShadows(boolean value)



Sets whether this geometry can cast shadow

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| value | boolean | New value |

### setExcluded(boolean value) {#setExcluded-boolean-}

public void setExcluded(boolean value)



Sets whether to exclude this entity during exporting.

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| value | boolean | New value |

### setName(String value) {#setName-java.lang.String-}

public void setName(String value)



Sets the name.

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| value | java.lang.String | New value |

### setParentNode(Node value) {#setParentNode-com.aspose.threed.Node-}

public void setParentNode(Node value)



Sets the first parent node, if set the first parent node, this entity will be detached from other parent nodes.

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| value | [Node](../../com.aspose.threed/node) | New value |

### setProperty(String property, Object value) {#setProperty-java.lang.String-java.lang.Object-}

public void setProperty(String property, Object value)



Sets the value of specified property

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| property | java.lang.String | Property name |
| value | java.lang.Object | The value of the property |

### setReceiveShadows(boolean value) {#setReceiveShadows-boolean-}

public void setReceiveShadows(boolean value)



Sets whether this geometry can receive shadow.

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| value | boolean | New value |

### setVisible(boolean value) {#setVisible-boolean-}

public void setVisible(boolean value)



Sets if the geometry is visible

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| value | boolean | New value |

### toMesh() {#toMesh--}

public Mesh toMesh()



Gets the Mesh instance from current entity.

**Returns:**
[Mesh](../../com.aspose.threed/mesh)
### toString() {#toString--}

public String toString()





**Returns:**
java.lang.String
### triangulate() {#triangulate--}

public Mesh triangulate()



Return triangulated mesh

**Returns:**
[Mesh](../../com.aspose.threed/mesh) - Current mesh if current mesh is already triangulated, otherwise a new triangulated mesh will be calculated and returned **Example:** The following code shows how to triangulate a mesh:

//The plane mesh has only one polygon with 4 control points var mesh = (new Plane()).ToMesh(); //After triangulated, the new mesh’s rectangle will become 2 triangles. var triangulated = mesh.Triangulate();

### union(Mesh a, Mesh b) {#union-com.aspose.threed.Mesh-com.aspose.threed.Mesh-}

public static Mesh union(Mesh a, Mesh b)



Calculate the union of two meshes

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| a | [Mesh](../../com.aspose.threed/mesh) | First mesh |
| b | [Mesh](../../com.aspose.threed/mesh) | Second mesh |

**Returns:**
[Mesh](../../com.aspose.threed/mesh) - Result mesh
### wait() {#wait--}

public final void wait()





### wait(long arg0) {#wait-long-}

public final void wait(long arg0)





**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| arg0 | long |  |

### wait(long arg0, int arg1) {#wait-long-int-}

public final void wait(long arg0, int arg1)





**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| arg0 | long |  |
| arg1 | int |  |