public final class ObjWriter extends AbstractTextFormatWriter
Modifier and Type | Class and Description |
---|---|
class |
ObjWriter.MeshBuffer
Class used to produce OBJ mesh content from sequences of facets.
|
Constructor and Description |
---|
ObjWriter(Writer writer)
Create a new instance that writes output with the given writer.
|
Modifier and Type | Method and Description |
---|---|
int |
getVertexCount()
Get the number of vertices written to the output.
|
int |
getVertexNormalCount()
Get the number of vertex normals written to the output.
|
ObjWriter.MeshBuffer |
meshBuffer()
Create a new
ObjWriter.MeshBuffer instance with an unlimited batch size, meaning that
no vertex definitions are duplicated in the mesh output. |
ObjWriter.MeshBuffer |
meshBuffer(int batchSize)
Create a new
ObjWriter.MeshBuffer instance with the given batch size. |
void |
writeBoundaries(BoundarySource3D src)
Write the boundaries present in the given boundary source using a
ObjWriter.MeshBuffer
with an unlimited size. |
void |
writeBoundaries(BoundarySource3D src,
int batchSize)
Write the boundaries present in the given boundary source using a
ObjWriter.MeshBuffer with
the given batchSize . |
void |
writeComment(String comment)
Write an OBJ comment with the given value.
|
void |
writeFace(int... vertexIndices)
Write a face with the given 0-based vertex indices.
|
void |
writeFace(int[] vertexIndices,
int normalIndex)
Write a face with the given 0-based vertex indices and 0-based normal index.
|
void |
writeFace(int[] vertexIndices,
int[] normalIndices)
Write a face with the given vertex and normal indices.
|
void |
writeGroupName(String groupName)
Write a group name to the output.
|
void |
writeMesh(Mesh<?> mesh)
Write a mesh to the output.
|
void |
writeObjectName(String objectName)
Write an object name to the output.
|
int |
writeVertex(Vector3D vertex)
Write a vertex and return the 0-based index of the vertex in the output.
|
int |
writeVertexNormal(Vector3D normal)
Write a vertex normal and return the 0-based index of the normal in the output.
|
close, getDoubleFormat, getLineSeparator, getWriter, setDoubleFormat, setLineSeparator, write, write, write, write, writeNewLine
public int getVertexCount()
public int getVertexNormalCount()
public void writeComment(String comment)
comment
- comment to writeUncheckedIOException
- if an I/O error occurspublic void writeObjectName(String objectName)
objectName
- the name to writeUncheckedIOException
- if an I/O error occurspublic void writeGroupName(String groupName)
groupName
- the name to writeUncheckedIOException
- if an I/O error occurspublic int writeVertex(Vector3D vertex)
vertex
- vertex to writeUncheckedIOException
- if an I/O error occurspublic int writeVertexNormal(Vector3D normal)
normal
- normal to writeUncheckedIOException
- if an I/O error occurspublic void writeFace(int... vertexIndices)
vertexIndices
- 0-based vertex indices for the faceIllegalArgumentException
- if fewer than 3 vertex indices are givenIndexOutOfBoundsException
- if any vertex index is computed to be outside of
the bounds of the elements written so farUncheckedIOException
- if an I/O error occurspublic void writeFace(int[] vertexIndices, int normalIndex)
vertexIndices
- 0-based vertex indicesnormalIndex
- 0-based normal indexIndexOutOfBoundsException
- if any vertex or normal index is computed to be outside of
the bounds of the elements written so farUncheckedIOException
- if an I/O error occurspublic void writeFace(int[] vertexIndices, int[] normalIndices)
normalIndices
argument may be null, but if present, must contain the
same number of indices as vertexIndices
.vertexIndices
- 0-based vertex indices; may not be nullnormalIndices
- 0-based normal indices; may be null but if present must contain
the same number of indices as vertexIndices
IllegalArgumentException
- if fewer than 3 vertex indices are given or normalIndices
is not null but has a different length than vertexIndices
IndexOutOfBoundsException
- if any vertex or normal index is computed to be outside of
the bounds of the elements written so farUncheckedIOException
- if an I/O error occurspublic void writeBoundaries(BoundarySource3D src)
ObjWriter.MeshBuffer
with an unlimited size.src
- boundary source containing the boundaries to write to the outputIllegalArgumentException
- if any boundary in the argument is infiniteUncheckedIOException
- if an I/O error occursmeshBuffer(int)
,
writeMesh(Mesh)
public void writeBoundaries(BoundarySource3D src, int batchSize)
ObjWriter.MeshBuffer
with
the given batchSize
.src
- boundary source containing the boundaries to write to the outputbatchSize
- batch size to use for the mesh buffer; pass -1
to use a buffer
of unlimited sizeIllegalArgumentException
- if any boundary in the argument is infiniteUncheckedIOException
- if an I/O error occursmeshBuffer(int)
,
writeMesh(Mesh)
public void writeMesh(Mesh<?> mesh)
mesh
- the mesh to writeUncheckedIOException
- if an I/O error occurspublic ObjWriter.MeshBuffer meshBuffer()
ObjWriter.MeshBuffer
instance with an unlimited batch size, meaning that
no vertex definitions are duplicated in the mesh output. This produces the most compact
mesh but at the most of higher memory usage during writing.public ObjWriter.MeshBuffer meshBuffer(int batchSize)
ObjWriter.MeshBuffer
instance with the given batch size. The batch size determines
how many faces will be stored in the buffer before being flushed. Faces stored in the buffer
share duplicate vertices, reducing the number of vertices required in the file. The batchSize
is therefore a trade-off between higher memory usage (high batch size) and a higher probability of duplicate
vertices present in the output (low batch size). A batch size of -1
indicates an unlimited
batch size.batchSize
- number of faces to store in the buffer before automatically flushing to the
outputCopyright © 2016–2021 The Apache Software Foundation. All rights reserved.