public class BasicWritableObj extends Object implements WritableObj
WritableObj that delegates all calls
to consumer callbacks. null by default,
causing the respective elements to be ignored. The callbacks may be set
individually. For example, in order to print all vertices and faces that
are read from an OBJ file, the following may be used:
BasicWritableObj obj = new BasicWritableObj();
obj.setVertexConsumer(t -> System.out.println(t));
obj.setFaceConsumer(t -> System.out.println(t));
ObjReader.read(inputStream, obj);
| Constructor and Description |
|---|
BasicWritableObj()
Default constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFace(int... v)
Add the specified face with the given vertex indices, but without
texture- or normal indices.
|
void |
addFace(int[] v,
int[] vt,
int[] vn)
Add the specified face.
|
void |
addFace(ObjFace face)
Add the given face.
|
void |
addFaceWithAll(int... v)
Add the specified face with the given vertex, texture coordinate
and normal indices.
|
void |
addFaceWithNormals(int... v)
Add the specified face with the given vertex and normal indices,
but without texture coordinate indices.
|
void |
addFaceWithTexCoords(int... v)
Add the specified face with the given vertex and texture coordinate
indices, but without normal indices.
|
void |
addNormal(float x,
float y,
float z)
Add the given normal
|
void |
addNormal(FloatTuple normal)
Add the given normal
|
void |
addTexCoord(float x)
Add the given texture coordinate
|
void |
addTexCoord(float x,
float y)
Add the given texture coordinate
|
void |
addTexCoord(float x,
float y,
float z)
Add the given texture coordinate
|
void |
addTexCoord(FloatTuple texCoord)
Add the given texture coordinate
|
void |
addVertex(float x,
float y,
float z)
Add the given vertex
|
void |
addVertex(FloatTuple vertex)
Add the given vertex
|
void |
setActiveGroupNames(Collection<? extends String> groupNames)
Set the groups with the given names to be active right now.
|
void |
setActiveMaterialGroupName(String materialGroupName)
Set the material group with the given names to be active right now
Faces that are added subsequently will be added to the active
material group, creating this material group if necessary.
|
void |
setFaceConsumer(java.util.function.Consumer<? super ObjFace> faceConsumer)
Set the face consumer
|
void |
setGroupNamesConsumer(java.util.function.Consumer<? super Collection<? extends String>> groupNamesConsumer)
Set the group names consumer
|
void |
setMaterialGroupNameConsumer(java.util.function.Consumer<? super String> materialGroupNameConsumer)
Set the material group name consumer
|
void |
setMtlFileNames(Collection<? extends String> mtlFileNames)
Set the given MTL file names.
|
void |
setMtlFileNamesConsumer(java.util.function.Consumer<? super Collection<? extends String>> mtlFileNamesConsumer)
Set the MTL file names consumer
|
void |
setNormalConsumer(java.util.function.Consumer<? super FloatTuple> normalConsumer)
Set the normal consumer
|
void |
setTexCoordConsumer(java.util.function.Consumer<? super FloatTuple> texCoordConsumer)
Set the texture coordinate consumer
|
void |
setVertexConsumer(java.util.function.Consumer<? super FloatTuple> vertexConsumer)
Set the vertex consumer
|
public void setVertexConsumer(java.util.function.Consumer<? super FloatTuple> vertexConsumer)
vertexConsumer - The consumerpublic void setTexCoordConsumer(java.util.function.Consumer<? super FloatTuple> texCoordConsumer)
texCoordConsumer - The consumerpublic void setNormalConsumer(java.util.function.Consumer<? super FloatTuple> normalConsumer)
normalConsumer - The consumerpublic void setFaceConsumer(java.util.function.Consumer<? super ObjFace> faceConsumer)
faceConsumer - The consumerpublic void setGroupNamesConsumer(java.util.function.Consumer<? super Collection<? extends String>> groupNamesConsumer)
groupNamesConsumer - The consumerpublic void setMaterialGroupNameConsumer(java.util.function.Consumer<? super String> materialGroupNameConsumer)
materialGroupNameConsumer - The consumerpublic void setMtlFileNamesConsumer(java.util.function.Consumer<? super Collection<? extends String>> mtlFileNamesConsumer)
mtlFileNamesConsumer - The consumerpublic final void addVertex(FloatTuple vertex)
WritableObjaddVertex in interface WritableObjvertex - The vertex to add.public final void addVertex(float x,
float y,
float z)
WritableObjaddVertex in interface WritableObjx - The x-coordinatey - The y-coordinatez - The z-coordinatepublic final void addTexCoord(FloatTuple texCoord)
WritableObjaddTexCoord in interface WritableObjtexCoord - The texture coordinate to add.public final void addTexCoord(float x)
WritableObjaddTexCoord in interface WritableObjx - The x-coordinatepublic final void addTexCoord(float x,
float y)
WritableObjaddTexCoord in interface WritableObjx - The x-coordinatey - The y-coordinatepublic final void addTexCoord(float x,
float y,
float z)
WritableObjaddTexCoord in interface WritableObjx - The x-coordinatey - The y-coordinatez - The z-coordinatepublic final void addNormal(FloatTuple normal)
WritableObjaddNormal in interface WritableObjnormal - The normal to add.public final void addNormal(float x,
float y,
float z)
WritableObjaddNormal in interface WritableObjx - The x-coordinatey - The y-coordinatez - The z-coordinatepublic final void setActiveGroupNames(Collection<? extends String> groupNames)
WritableObjnull,
then this call will have no effect. If the given collection is empty,
then the default group (named "default") will be activated.setActiveGroupNames in interface WritableObjgroupNames - The group namespublic final void setActiveMaterialGroupName(String materialGroupName)
WritableObjnull, then this call will have no
effect.setActiveMaterialGroupName in interface WritableObjmaterialGroupName - The material group namepublic final void addFace(ObjFace face)
WritableObjaddFace in interface WritableObjface - The face to add.public final void addFace(int... v)
WritableObjaddFace in interface WritableObjv - The vertex indicespublic final void addFaceWithTexCoords(int... v)
WritableObjaddFaceWithTexCoords in interface WritableObjv - The vertex- and texture coordinate indicespublic final void addFaceWithNormals(int... v)
WritableObjaddFaceWithNormals in interface WritableObjv - The vertex- and normal indicespublic final void addFaceWithAll(int... v)
WritableObjaddFaceWithAll in interface WritableObjv - The vertex- texture coordinate and normal indicespublic final void addFace(int[] v,
int[] vt,
int[] vn)
WritableObjaddFace in interface WritableObjv - The vertex indicesvt - The texture coordinate indices. May be null.vn - The normal indices. May be nullpublic final void setMtlFileNames(Collection<? extends String> mtlFileNames)
WritableObjsetMtlFileNames in interface WritableObjmtlFileNames - The names of the MTL fileCopyright © 2018. All rights reserved.