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
FieldsModifier 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
ConstructorsConstructorDescriptionWETriangleMesh(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()intgetRotatedAroundAxis(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.voidvoidremoveFace(Face f) voidvoidremoveVertices(Collection<Vertex> selection) rotateAroundAxis(Vec3D axis, float theta) rotateX(float theta) rotateY(float theta) rotateZ(float theta) scale(float scale) voidsplitEdge(WingedEdge e, SubdivisionStrategy subDiv) voidsplitEdge(ReadonlyVec3D a, ReadonlyVec3D b, SubdivisionStrategy subDiv) voidvoidsubdivide(float minLength) voidsubdivide(SubdivisionStrategy subDiv) voidsubdivide(SubdivisionStrategy subDiv, float minLength) voidsubdivideFaceEdges(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:Mesh3DAdds the given 3 points as triangle face to the mesh. The assumed vertex order is anti-clockwise.- Specified by:
addFacein interfaceMesh3D- Overrides:
addFacein classTriangleMesh
-
addFace
Description copied from interface:Mesh3DAdds 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:
addFacein interfaceMesh3D- Overrides:
addFacein classTriangleMesh- Returns:
- itself
-
addFace
- Specified by:
addFacein interfaceMesh3D- Overrides:
addFacein classTriangleMesh
-
addFace
- Specified by:
addFacein interfaceMesh3D- Overrides:
addFacein classTriangleMesh
-
addMesh
Adds all faces from the given mesh to this one.- Specified by:
addMeshin interfaceMesh3D- Overrides:
addMeshin classTriangleMesh- Parameters:
m- source mesh instance
-
center
Description copied from interface:Mesh3DCenters the mesh around the given pivot point (the centroid of its AABB). Method also updates & returns the new bounding box.- Specified by:
centerin interfaceMesh3D- Overrides:
centerin classTriangleMesh- Parameters:
origin- new centroid or null (defaults to {0,0,0})
-
clear
Clears all counters, and vertex & face buffers.- Specified by:
clearin interfaceMesh3D- Overrides:
clearin classTriangleMesh
-
copy
Creates a deep clone of the mesh. The new mesh name will have "-copy" as suffix.- Overrides:
copyin classTriangleMesh- Returns:
- new mesh instance
-
flipVertexOrder
Flips the vertex ordering between clockwise and anti-clockwise. WEFace normals are updated automatically too.- Specified by:
flipVertexOrderin interfaceMesh3D- Overrides:
flipVertexOrderin classTriangleMesh- Returns:
- itself
-
flipYAxis
Description copied from interface:Mesh3DFlips 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:
flipYAxisin interfaceMesh3D- Overrides:
flipYAxisin classTriangleMesh- Returns:
- itself
-
getClosestVertexToPoint
- Specified by:
getClosestVertexToPointin interfaceMesh3D- Overrides:
getClosestVertexToPointin classTriangleMesh
-
getEdges
-
getNumEdges
public int getNumEdges() -
getRotatedAroundAxis
- Overrides:
getRotatedAroundAxisin classTriangleMesh
-
getRotatedX
- Overrides:
getRotatedXin classTriangleMesh
-
getRotatedY
- Overrides:
getRotatedYin classTriangleMesh
-
getRotatedZ
- Overrides:
getRotatedZin classTriangleMesh
-
getScaled
- Overrides:
getScaledin classTriangleMesh
-
getScaled
- Overrides:
getScaledin classTriangleMesh
-
getTranslated
- Overrides:
getTranslatedin classTriangleMesh
-
getVertexAtPoint
- Overrides:
getVertexAtPointin classTriangleMesh
-
getVertexForID
- Overrides:
getVertexForIDin classTriangleMesh
-
init
- Specified by:
initin interfaceMesh3D- Overrides:
initin 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:
pointTowardsin 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:
pointTowardsin classTriangleMesh- Parameters:
dir- new target direction to point inforward- current forward axis- Returns:
- itself
-
rebuildIndex
public void rebuildIndex() -
removeFace
- Overrides:
removeFacein classTriangleMesh
-
removeUnusedVertices
public void removeUnusedVertices() -
removeVertices
-
rotateAroundAxis
- Overrides:
rotateAroundAxisin classTriangleMesh
-
rotateX
- Overrides:
rotateXin classTriangleMesh
-
rotateY
- Overrides:
rotateYin classTriangleMesh
-
rotateZ
- Overrides:
rotateZin classTriangleMesh
-
scale
- Overrides:
scalein classTriangleMesh
-
scale
- Overrides:
scalein classTriangleMesh
-
splitEdge
-
splitEdge
-
subdivide
public void subdivide() -
subdivide
public void subdivide(float minLength) -
subdivide
-
subdivide
-
subdivideFaceEdges
-
toString
- Overrides:
toStringin classTriangleMesh
-
transform
Applies the given matrix transform to all mesh vertices and updates all face normals.- Overrides:
transformin 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:
transformin classTriangleMesh- Parameters:
mat-updateNormals-- Returns:
- itself
-
translate
- Overrides:
translatein classTriangleMesh
-