public class Mesh extends Geometry implements java.lang.Iterable<int[]>, IMeshConvertible
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
}
name, properties| Constructor and Description |
|---|
Mesh()
Initializes a new instance of the
Mesh class. |
Mesh(java.lang.String name)
Initializes a new instance of the
Mesh class. |
| Modifier and Type | Method and Description |
|---|---|
void |
addControlPoint(double x,
double y,
double z)
Add a new control point to the mesh, this is more efficient.
|
void |
addControlPoint(double x,
double y,
double z,
double w)
Add a new control point to the mesh, this is more efficient.
|
Mesh |
clone() |
void |
createPolygon(int[] indices)
Creates a new polygon with all vertices defined in
indices. |
void |
createPolygon(int[] indices,
int offset,
int length)
Creates a new polygon with all vertices defined in
indices. |
void |
createPolygon(int v1,
int v2,
int v3)
Create a polygon with 3 vertices(triangle)
|
void |
createPolygon(int v1,
int v2,
int v3,
int v4)
Create a polygon with 4 vertices(quad)
|
static Mesh |
difference(Mesh a,
Mesh b)
Calculate the difference of two meshes
|
static Mesh |
doBoolean(BooleanOperation op,
Mesh a,
Matrix4 transformA,
Mesh b,
Matrix4 transformB)
Perform Boolean operation on two meshes
|
java.util.List<java.lang.Integer> |
getEdges()
Gets edges of the Mesh.
|
int |
getPolygonCount()
Gets the count of polygons
|
java.util.List<int[]> |
getPolygons()
Gets the polygons definition of the mesh
|
int |
getPolygonSize(int index)
Gets the vertex count of the specified polygon.
|
static Mesh |
intersect(Mesh a,
Mesh b)
Calculate the intersection of two meshes
|
boolean |
isManifold()
Check if current mesh is a manifold mesh.
|
java.util.Iterator<int[]> |
iterator()
Gets the enumerator for each inner polygons.
|
Mesh |
optimize(boolean vertexElements)
Optimize the mesh's memory usage by eliminating duplicated control points
|
Mesh |
optimize(boolean vertexElements,
float toleranceControlPoint)
Optimize the mesh's memory usage by eliminating duplicated control points
|
Mesh |
optimize(boolean vertexElements,
float toleranceControlPoint,
float toleranceNormal)
Optimize the mesh's memory usage by eliminating duplicated control points
|
Mesh |
optimize(boolean vertexElements,
float toleranceControlPoint,
float toleranceNormal,
float toleranceUV)
Optimize the mesh's memory usage by eliminating duplicated control points
|
Mesh |
optimize2(boolean vertexElements)
Optimize the mesh's memory usage by eliminating duplicated control points
|
Mesh |
toMesh()
Gets the Mesh instance from current entity.
|
Mesh |
triangulate()
Return triangulated mesh
|
static Mesh |
union(Mesh a,
Mesh b)
Calculate the union of two meshes
|
addElement, createElement, createElement, createElementUV, createElementUV, getCastShadows, getControlPoints, getDeformers, getDeformers2, getElement, getReceiveShadows, getVertexElementOfUV, getVertexElements, getVisible, setCastShadows, setReceiveShadows, setVisiblegetBoundingBox, getExcluded, getParentNode, getParentNodes, setExcluded, setParentNodegetScenefindProperty, getName, getProperties, getProperty, removeProperty, removeProperty, setName, setPropertypublic Mesh()
Mesh class.public Mesh(java.lang.String name)
Mesh class.name - Name.public Mesh clone()
clone in class java.lang.Objectpublic java.util.List<java.lang.Integer> getEdges()
public int getPolygonSize(int index)
index - Index.public int getPolygonCount()
Mesh mesh = (new Sphere()).toMesh();
System.out.println("Mesh's polygon count = " + mesh.getPolygonCount());
public java.util.List<int[]> getPolygons()
public void addControlPoint(double x,
double y,
double z)
x - The x component of the control pointy - The y component of the control pointz - The z component of the control pointpublic void addControlPoint(double x,
double y,
double z,
double w)
x - The x component of the control pointy - The y component of the control pointz - The z component of the control pointw - The w component of the control pointpublic void createPolygon(int[] indices,
int offset,
int length)
indices.
To create polygon vertex by vertex, please use PolygonBuilder.indices - Array of the polygon indices, each index points to a control point that forms the polygon.offset - The offset of the first polygon indexlength - The length of the indices
Example:
The following code shows how to create a new polygon with control point's indices.
Mesh mesh = new Mesh();
int[] indices = new int[] {0, 1, 2};
mesh.createPolygon(indices);
public void createPolygon(int[] indices)
indices.
To create polygon vertex by vertex, please use PolygonBuilder.indices - Array of the polygon indices, each index points to a control point that forms the polygon.
Example:
Mesh mesh = new Mesh();
int[] indices = new int[] {0, 1, 2};
mesh.createPolygon(indices);
public void createPolygon(int v1,
int v2,
int v3,
int v4)
v1 - Index of the first vertexv2 - Index of the second vertexv3 - Index of the third vertexv4 - Index of the fourth vertex
Example:
The following code shows how to create a new polygon with control point's indices.
Mesh mesh = new Mesh(); mesh.createPolygon(0, 1, 2, 3);
public void createPolygon(int v1,
int v2,
int v3)
v1 - Index of the first vertexv2 - Index of the second vertexv3 - Index of the third vertex
Example:
The following code shows how to create a new polygon with control point's indices.
Mesh mesh = new Mesh(); mesh.createPolygon(0, 1, 2);
public Mesh toMesh()
toMesh in interface IMeshConvertiblepublic static Mesh doBoolean(BooleanOperation op, Mesh a, Matrix4 transformA, Mesh b, Matrix4 transformB)
op - The Boolean operation type.a - First mesh to operate.transformA - Transformation matrix of the first meshb - Second mesh to operatetransformB - Transformation matrix of the second meshpublic boolean isManifold()
public static Mesh union(Mesh a, Mesh b)
a - First meshb - Second meshpublic static Mesh difference(Mesh a, Mesh b)
a - First meshb - Second meshpublic static Mesh intersect(Mesh a, Mesh b)
a - First meshb - Second meshpublic Mesh optimize(boolean vertexElements)
vertexElements - Optimize duplicated vertex element data//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);
public Mesh triangulate()
//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();
public Mesh optimize(boolean vertexElements, float toleranceControlPoint, float toleranceNormal, float toleranceUV)
vertexElements - Optimize duplicated vertex element datatoleranceControlPoint - The tolerance for control point, default value is 1e-9toleranceNormal - The tolerance for normal/tangent/binormal default value is 1e-9toleranceUV - The tolerance for uv, default value is 1e-9public Mesh optimize(boolean vertexElements, float toleranceControlPoint)
vertexElements - Optimize duplicated vertex element datatoleranceControlPoint - The tolerance for control point, default value is 1e-9public Mesh optimize(boolean vertexElements, float toleranceControlPoint, float toleranceNormal)
vertexElements - Optimize duplicated vertex element datatoleranceControlPoint - The tolerance for control point, default value is 1e-9toleranceNormal - The tolerance for normal/tangent/binormal default value is 1e-9public java.util.Iterator<int[]> iterator()
iterator in interface java.lang.Iterable<int[]>public Mesh optimize2(boolean vertexElements)
vertexElements - Optimize duplicated vertex element data