public class OBJWriter
extends java.io.FilterWriter
Once you wrote nodes, call close
method to create the MTL file
and the texture images in the same folder as OBJ file. This feature applies
only to constructor that takes a file as parameter.
Note: this class is compatible with Java 3D 1.3.
Constructor and Description |
---|
OBJWriter(java.io.File objFile)
Create an OBJ writer for the given file, with no header and default precision.
|
OBJWriter(java.io.File objFile,
java.lang.String header,
int maximumFractionDigits)
Create an OBJ writer for the given file.
|
OBJWriter(java.io.OutputStream out)
Create an OBJ writer that will writes in
out stream,
with no header and default precision. |
OBJWriter(java.io.OutputStream out,
java.lang.String header,
int maximumFractionDigits)
Create an OBJ writer that will writes in
out stream. |
OBJWriter(java.lang.String objFileName)
Create an OBJ writer for the given file name, with no header and default precision.
|
OBJWriter(java.lang.String objFileName,
java.lang.String header,
int maximumFractionDigits)
Create an OBJ writer for the given file name.
|
OBJWriter(java.io.Writer out)
Create an OBJ writer that will writes in
out stream,
with no header and default precision. |
OBJWriter(java.io.Writer out,
java.lang.String header,
int maximumFractionDigits)
Create an OBJ writer that will writes in
out stream. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this writer and writes MTL file and its texture images,
if this writer was created from a file.
|
void |
write(char[] cbuf,
int off,
int len)
Write a portion of an array of characters in a comment at OBJ format.
|
void |
write(int c)
Write a single character in a comment at OBJ format.
|
void |
write(java.lang.String str)
Write a string in a comment at OBJ format.
|
void |
write(java.lang.String str,
int off,
int len)
Write a portion of a string in a comment at OBJ format.
|
void |
writeNode(javax.media.j3d.Node node)
Writes all the 3D shapes children of
node at OBJ format. |
void |
writeNode(javax.media.j3d.Node node,
java.lang.String nodeName)
Writes all the 3D shapes children of
node at OBJ format. |
static void |
writeNodeInZIPFile(javax.media.j3d.Node node,
java.io.File zipFile,
int compressionLevel,
java.lang.String entryName,
java.lang.String header)
Writes
node in an entry at OBJ format of the given zip file
along with its MTL file and texture images. |
static void |
writeNodeInZIPFile(javax.media.j3d.Node node,
java.util.Map<java.lang.String,javax.media.j3d.Appearance> materialAppearances,
java.io.File zipFile,
int compressionLevel,
java.lang.String entryName,
java.lang.String header)
Writes
node in an entry at OBJ format of the given zip file
along with its MTL file and texture images. |
public OBJWriter(java.io.File objFile) throws java.io.FileNotFoundException, java.io.IOException
java.io.FileNotFoundException
java.io.IOException
public OBJWriter(java.io.File objFile, java.lang.String header, int maximumFractionDigits) throws java.io.FileNotFoundException, java.io.IOException
objFile
- the file into which 3D nodes will be written at OBJ formatheader
- a header written as a comment at start of the OBJ file and its MTL counterpartmaximumFractionDigits
- the maximum digits count used in fraction part of numbers,
or -1 for default value. Using -1 may cause writing nodes to be twice faster.java.io.FileNotFoundException
java.io.IOException
public OBJWriter(java.lang.String objFileName) throws java.io.FileNotFoundException, java.io.IOException
java.io.FileNotFoundException
java.io.IOException
public OBJWriter(java.lang.String objFileName, java.lang.String header, int maximumFractionDigits) throws java.io.FileNotFoundException, java.io.IOException
objFileName
- the name of the file into which 3D nodes will be written at OBJ formatheader
- a header written as a comment at start of the OBJ file and its MTL counterpartmaximumFractionDigits
- the maximum digits count used in fraction part of numbers,
or -1 for default value. Using -1 may cause writing nodes to be twice faster.java.io.FileNotFoundException
java.io.IOException
public OBJWriter(java.io.OutputStream out) throws java.io.IOException
out
stream,
with no header and default precision.java.io.IOException
public OBJWriter(java.io.OutputStream out, java.lang.String header, int maximumFractionDigits) throws java.io.IOException
out
stream.out
- the stream into which 3D nodes will be written at OBJ formatheader
- a header written as a comment at start of the streammaximumFractionDigits
- the maximum digits count used in fraction part of numbers,
or -1 for default value. Using -1 may cause writing nodes to be twice faster.java.io.IOException
public OBJWriter(java.io.Writer out) throws java.io.IOException
out
stream,
with no header and default precision.java.io.IOException
public OBJWriter(java.io.Writer out, java.lang.String header, int maximumFractionDigits) throws java.io.IOException
out
stream.out
- the stream into which 3D nodes will be written at OBJ formatheader
- a header written as a comment at start of the streammaximumFractionDigits
- the maximum digits count used in fraction part of numbers,
or -1 for default value. Using -1 may cause writing nodes to be twice faster.java.io.IOException
public void write(int c) throws java.io.IOException
write
in class java.io.FilterWriter
java.io.IOException
public void write(char[] cbuf, int off, int len) throws java.io.IOException
write
in class java.io.FilterWriter
java.io.IOException
public void write(java.lang.String str, int off, int len) throws java.io.IOException
write
in class java.io.FilterWriter
java.io.IOException
public void write(java.lang.String str) throws java.io.IOException
write
in class java.io.Writer
java.io.IOException
public void writeNode(javax.media.j3d.Node node) throws java.io.IOException, java.io.InterruptedIOException
node
at OBJ format.
If there are transformation groups on the path from node
to its shapes,
they'll be applied to the coordinates written on output.
The node
shouldn't be alive or if it's alive it should have the
capabilities to read its children, the geometries and the appearance of its shapes.
Only geometries which are instances of GeometryArray
will be written.node
- a Java 3D nodejava.io.IOException
- if the operation failedjava.io.InterruptedIOException
- if the current thread was interrupted during this operation.
The interrupted status of the current thread is cleared when this exception is thrown.public void writeNode(javax.media.j3d.Node node, java.lang.String nodeName) throws java.io.IOException, java.io.InterruptedIOException
node
at OBJ format.
If there are transformation groups on the path from node
to its shapes,
they'll be applied to the coordinates written on output.
The node
shouldn't be alive or if it's alive, it should have the
capabilities to read its children, the geometries and the appearance of its shapes.
Only geometries which are instances of GeometryArray
will be written.node
- a Java 3D nodenodeName
- the name of the node. This is useful to distinguish the objects
names in output. If this name is null
or isn't built
with A-Z, a-z, 0-9 and underscores, it will be ignored.java.io.IOException
- if the operation failedjava.io.InterruptedIOException
- if the current thread was interrupted during this operation
The interrupted status of the current thread is cleared when this exception is thrown.public void close() throws java.io.IOException, java.io.InterruptedIOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.FilterWriter
java.io.IOException
- if this writer couldn't be closed
or couldn't write MTL and texture files couldn't be writtenjava.io.InterruptedIOException
- if the current thread was interrupted during this operation
The interrupted status of the current thread is cleared when this exception is thrown.public static void writeNodeInZIPFile(javax.media.j3d.Node node, java.io.File zipFile, int compressionLevel, java.lang.String entryName, java.lang.String header) throws java.io.IOException
node
in an entry at OBJ format of the given zip file
along with its MTL file and texture images.java.io.IOException
public static void writeNodeInZIPFile(javax.media.j3d.Node node, java.util.Map<java.lang.String,javax.media.j3d.Appearance> materialAppearances, java.io.File zipFile, int compressionLevel, java.lang.String entryName, java.lang.String header) throws java.io.IOException
node
in an entry at OBJ format of the given zip file
along with its MTL file and texture images.
Once saved, materialAppearances
will contain the appearances matching
each material saved in the MTL file. Material names used as keys maybe be different
of the appearance names to respect MTL specifications.java.io.IOException
© Copyright 2024 Space Mushrooms
Distributed under GNU General Public License