Package toxi.geom.mesh
Class WETriangleMesh
java.lang.Object
toxi.geom.mesh.TriangleMesh
toxi.geom.mesh.WETriangleMesh
- All Implemented Interfaces:
Intersector3D
,Mesh3D
A class to dynamically build, manipulate & export triangle meshes. Meshes are
build face by face. The class automatically re-uses existing vertices and can
create smooth vertex normals. Vertices and faces are directly accessible for
speed & convenience.
-
Field Summary
Modifier and TypeFieldDescriptionWEVertex buffer & lookup index when adding new facesFields inherited from class toxi.geom.mesh.TriangleMesh
DEFAULT_NUM_FACES, DEFAULT_NUM_VERTICES, DEFAULT_STRIDE, faces, name, vertices
-
Constructor Summary
ConstructorDescriptionWETriangleMesh
(String name) Creates a new mesh instance with initial default buffer sizes.WETriangleMesh
(String name, int numV, int numF) Creates a new mesh instance with the given initial buffer sizes. -
Method Summary
Modifier and TypeMethodDescriptionAdds the given 3 points as triangle face to the mesh.Adds the given 3 points as triangle face to the mesh and assigns the given texture coordinates to each vertex.Adds all faces from the given mesh to this one.center
(ReadonlyVec3D origin) Centers the mesh around the given pivot point (the centroid of its AABB).clear()
Clears all counters, and vertex & face buffers.copy()
Creates a deep clone of the mesh.Flips the vertex ordering between clockwise and anti-clockwise.Flips all vertices along the Y axis and reverses the vertex ordering of all faces to compensate and keep the direction of normals intact.getEdges()
int
getRotatedAroundAxis
(Vec3D axis, float theta) getRotatedX
(float theta) getRotatedY
(float theta) getRotatedZ
(float theta) getScaled
(float scale) getTranslated
(Vec3D trans) getVertexForID
(int id) Rotates the mesh in such a way so that its "forward" axis is aligned with the given direction.pointTowards
(ReadonlyVec3D dir, ReadonlyVec3D forward) Rotates the mesh in such a way so that its "forward" axis is aligned with the given direction.void
void
removeFace
(Face f) void
void
removeVertices
(Collection<Vertex> selection) rotateAroundAxis
(Vec3D axis, float theta) rotateX
(float theta) rotateY
(float theta) rotateZ
(float theta) scale
(float scale) void
splitEdge
(WingedEdge e, SubdivisionStrategy subDiv) void
splitEdge
(ReadonlyVec3D a, ReadonlyVec3D b, SubdivisionStrategy subDiv) void
void
subdivide
(float minLength) void
subdivide
(SubdivisionStrategy subDiv) void
subdivide
(SubdivisionStrategy subDiv, float minLength) void
subdivideFaceEdges
(List<WEFace> faces, SubdivisionStrategy subDiv, float minLength) toString()
Applies the given matrix transform to all mesh vertices and updates all face normals.Applies the given matrix transform to all mesh vertices.Methods inherited from class toxi.geom.mesh.TriangleMesh
computeCentroid, computeFaceNormals, computeVertexNormals, faceOutwards, getBoundingBox, getBoundingSphere, getFaceNormalsAsArray, getFaceNormalsAsArray, getFaces, getFacesAsArray, getIntersectionData, getMeshAsVertexArray, getMeshAsVertexArray, getNormalsForUniqueVerticesAsArray, getNumFaces, getNumVertices, getUniqueVerticesAsArray, getVertexNormalsAsArray, getVertexNormalsAsArray, getVertices, intersectsRay, perforateFace, saveAsOBJ, saveAsOBJ, saveAsOBJ, saveAsOBJ, saveAsOBJ, saveAsSTL, saveAsSTL, saveAsSTL, saveAsSTL, saveAsSTL, saveAsSTL, scale, setName, toWEMesh, translate, updateVertex
-
Field Details
-
edges
WEVertex buffer & lookup index when adding new faces
-
-
Constructor Details
-
WETriangleMesh
public WETriangleMesh() -
WETriangleMesh
Creates a new mesh instance with initial default buffer sizes.- Parameters:
name
- mesh name
-
WETriangleMesh
Creates a new mesh instance with the given initial buffer sizes. These numbers are no limits and the mesh can be smaller or grow later on. They're only used to initialise the underlying collections.- Parameters:
name
- mesh namenumV
- initial vertex buffer sizenumF
- initial face list size
-
-
Method Details
-
addFace
Description copied from interface:Mesh3D
Adds the given 3 points as triangle face to the mesh. The assumed vertex order is anti-clockwise.- Specified by:
addFace
in interfaceMesh3D
- Overrides:
addFace
in classTriangleMesh
-
addFace
Description copied from interface:Mesh3D
Adds the given 3 points as triangle face to the mesh and assigns the given texture coordinates to each vertex. The assumed vertex order is anti-clockwise.- Specified by:
addFace
in interfaceMesh3D
- Overrides:
addFace
in classTriangleMesh
- Returns:
- itself
-
addFace
- Specified by:
addFace
in interfaceMesh3D
- Overrides:
addFace
in classTriangleMesh
-
addFace
- Specified by:
addFace
in interfaceMesh3D
- Overrides:
addFace
in classTriangleMesh
-
addMesh
Adds all faces from the given mesh to this one.- Specified by:
addMesh
in interfaceMesh3D
- Overrides:
addMesh
in classTriangleMesh
- Parameters:
m
- source mesh instance
-
center
Description copied from interface:Mesh3D
Centers the mesh around the given pivot point (the centroid of its AABB). Method also updates & returns the new bounding box.- Specified by:
center
in interfaceMesh3D
- Overrides:
center
in classTriangleMesh
- Parameters:
origin
- new centroid or null (defaults to {0,0,0})
-
clear
Clears all counters, and vertex & face buffers.- Specified by:
clear
in interfaceMesh3D
- Overrides:
clear
in classTriangleMesh
-
copy
Creates a deep clone of the mesh. The new mesh name will have "-copy" as suffix.- Overrides:
copy
in classTriangleMesh
- Returns:
- new mesh instance
-
flipVertexOrder
Flips the vertex ordering between clockwise and anti-clockwise. WEFace normals are updated automatically too.- Specified by:
flipVertexOrder
in interfaceMesh3D
- Overrides:
flipVertexOrder
in classTriangleMesh
- Returns:
- itself
-
flipYAxis
Description copied from interface:Mesh3D
Flips all vertices along the Y axis and reverses the vertex ordering of all faces to compensate and keep the direction of normals intact.- Specified by:
flipYAxis
in interfaceMesh3D
- Overrides:
flipYAxis
in classTriangleMesh
- Returns:
- itself
-
getClosestVertexToPoint
- Specified by:
getClosestVertexToPoint
in interfaceMesh3D
- Overrides:
getClosestVertexToPoint
in classTriangleMesh
-
getEdges
-
getNumEdges
public int getNumEdges() -
getRotatedAroundAxis
- Overrides:
getRotatedAroundAxis
in classTriangleMesh
-
getRotatedX
- Overrides:
getRotatedX
in classTriangleMesh
-
getRotatedY
- Overrides:
getRotatedY
in classTriangleMesh
-
getRotatedZ
- Overrides:
getRotatedZ
in classTriangleMesh
-
getScaled
- Overrides:
getScaled
in classTriangleMesh
-
getScaled
- Overrides:
getScaled
in classTriangleMesh
-
getTranslated
- Overrides:
getTranslated
in classTriangleMesh
-
getVertexAtPoint
- Overrides:
getVertexAtPoint
in classTriangleMesh
-
getVertexForID
- Overrides:
getVertexForID
in classTriangleMesh
-
init
- Specified by:
init
in interfaceMesh3D
- Overrides:
init
in classTriangleMesh
-
pointTowards
Rotates the mesh in such a way so that its "forward" axis is aligned with the given direction. This version uses the positive Z-axis as default forward direction.- Overrides:
pointTowards
in classTriangleMesh
- Parameters:
dir
- new target direction to point in- Returns:
- itself
-
pointTowards
Rotates the mesh in such a way so that its "forward" axis is aligned with the given direction. This version allows to specify the forward direction.- Overrides:
pointTowards
in classTriangleMesh
- Parameters:
dir
- new target direction to point inforward
- current forward axis- Returns:
- itself
-
rebuildIndex
public void rebuildIndex() -
removeFace
- Overrides:
removeFace
in classTriangleMesh
-
removeUnusedVertices
public void removeUnusedVertices() -
removeVertices
-
rotateAroundAxis
- Overrides:
rotateAroundAxis
in classTriangleMesh
-
rotateX
- Overrides:
rotateX
in classTriangleMesh
-
rotateY
- Overrides:
rotateY
in classTriangleMesh
-
rotateZ
- Overrides:
rotateZ
in classTriangleMesh
-
scale
- Overrides:
scale
in classTriangleMesh
-
scale
- Overrides:
scale
in classTriangleMesh
-
splitEdge
-
splitEdge
-
subdivide
public void subdivide() -
subdivide
public void subdivide(float minLength) -
subdivide
-
subdivide
-
subdivideFaceEdges
-
toString
- Overrides:
toString
in classTriangleMesh
-
transform
Applies the given matrix transform to all mesh vertices and updates all face normals.- Overrides:
transform
in classTriangleMesh
- Parameters:
mat
-- Returns:
- itself
-
transform
Applies the given matrix transform to all mesh vertices. If the updateNormals flag is true, all face normals are updated automatically, however vertex normals still need a manual update.- Overrides:
transform
in classTriangleMesh
- Parameters:
mat
-updateNormals
-- Returns:
- itself
-
translate
- Overrides:
translate
in classTriangleMesh
-