Sweet Home 3D 3.4

com.eteks.sweethome3d.j3d
Class OBJWriter

java.lang.Object
  extended by java.io.Writer
      extended by java.io.FilterWriter
          extended by com.eteks.sweethome3d.j3d.OBJWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable

public class OBJWriter
extends java.io.FilterWriter

An output stream that writes Java 3D nodes at OBJ + MTL format.

Once you wrote nodes, call close method to create the MTL file and the texture images in the same directory 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.

Author:
Emmanuel Puybaret

Field Summary
 
Fields inherited from class java.io.FilterWriter
out
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
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.
 
Method Summary
 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(Node node)
          Writes all the 3D shapes children of node at OBJ format.
 void writeNode(Node node, java.lang.String nodeName)
          Writes all the 3D shapes children of node at OBJ format.
static void writeNodeInZIPFile(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.
 
Methods inherited from class java.io.FilterWriter
flush
 
Methods inherited from class java.io.Writer
append, append, append, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OBJWriter

public OBJWriter(java.io.File objFile)
          throws java.io.FileNotFoundException,
                 java.io.IOException
Create an OBJ writer for the given file, with no header and default precision.

Throws:
java.io.FileNotFoundException
java.io.IOException

OBJWriter

public OBJWriter(java.io.File objFile,
                 java.lang.String header,
                 int maximumFractionDigits)
          throws java.io.FileNotFoundException,
                 java.io.IOException
Create an OBJ writer for the given file.

Parameters:
objFile - the file into which 3D nodes will be written at OBJ format
header - a header written as a comment at start of the OBJ file and its MTL counterpart
maximumFractionDigits - 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.
Throws:
java.io.FileNotFoundException
java.io.IOException

OBJWriter

public OBJWriter(java.lang.String objFileName)
          throws java.io.FileNotFoundException,
                 java.io.IOException
Create an OBJ writer for the given file name, with no header and default precision.

Throws:
java.io.FileNotFoundException
java.io.IOException

OBJWriter

public OBJWriter(java.lang.String objFileName,
                 java.lang.String header,
                 int maximumFractionDigits)
          throws java.io.FileNotFoundException,
                 java.io.IOException
Create an OBJ writer for the given file name.

Parameters:
objFileName - the name of the file into which 3D nodes will be written at OBJ format
header - a header written as a comment at start of the OBJ file and its MTL counterpart
maximumFractionDigits - 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.
Throws:
java.io.FileNotFoundException
java.io.IOException

OBJWriter

public OBJWriter(java.io.OutputStream out)
          throws java.io.IOException
Create an OBJ writer that will writes in out stream, with no header and default precision.

Throws:
java.io.IOException

OBJWriter

public OBJWriter(java.io.OutputStream out,
                 java.lang.String header,
                 int maximumFractionDigits)
          throws java.io.IOException
Create an OBJ writer that will writes in out stream.

Parameters:
out - the stream into which 3D nodes will be written at OBJ format
header - a header written as a comment at start of the stream
maximumFractionDigits - 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.
Throws:
java.io.IOException

OBJWriter

public OBJWriter(java.io.Writer out)
          throws java.io.IOException
Create an OBJ writer that will writes in out stream, with no header and default precision.

Throws:
java.io.IOException

OBJWriter

public OBJWriter(java.io.Writer out,
                 java.lang.String header,
                 int maximumFractionDigits)
          throws java.io.IOException
Create an OBJ writer that will writes in out stream.

Parameters:
out - the stream into which 3D nodes will be written at OBJ format
header - a header written as a comment at start of the stream
maximumFractionDigits - 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.
Throws:
java.io.IOException
Method Detail

write

public void write(int c)
           throws java.io.IOException
Write a single character in a comment at OBJ format.

Overrides:
write in class java.io.FilterWriter
Throws:
java.io.IOException

write

public void write(char[] cbuf,
                  int off,
                  int len)
           throws java.io.IOException
Write a portion of an array of characters in a comment at OBJ format.

Overrides:
write in class java.io.FilterWriter
Throws:
java.io.IOException

write

public void write(java.lang.String str,
                  int off,
                  int len)
           throws java.io.IOException
Write a portion of a string in a comment at OBJ format.

Overrides:
write in class java.io.FilterWriter
Throws:
java.io.IOException

write

public void write(java.lang.String str)
           throws java.io.IOException
Write a string in a comment at OBJ format.

Overrides:
write in class java.io.Writer
Throws:
java.io.IOException

writeNode

public void writeNode(Node node)
               throws java.io.IOException,
                      java.io.InterruptedIOException
Writes all the 3D shapes children of 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.

Parameters:
node - a Java 3D node
Throws:
java.io.IOException - if the operation failed
java.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.

writeNode

public void writeNode(Node node,
                      java.lang.String nodeName)
               throws java.io.IOException,
                      java.io.InterruptedIOException
Writes all the 3D shapes children of 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.

Parameters:
node - a Java 3D node
nodeName - 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.
Throws:
java.io.IOException - if the operation failed
java.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.

close

public void close()
           throws java.io.IOException,
                  java.io.InterruptedIOException
Closes this writer and writes MTL file and its texture images, if this writer was created from a file.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.FilterWriter
Throws:
java.io.IOException - if this writer couldn't be closed or couldn't write MTL and texture files couldn't be written
java.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.

writeNodeInZIPFile

public static void writeNodeInZIPFile(Node node,
                                      java.io.File zipFile,
                                      int compressionLevel,
                                      java.lang.String entryName,
                                      java.lang.String header)
                               throws java.io.IOException
Writes node in an entry at OBJ format of the given zip file along with its MTL file and texture images.

Throws:
java.io.IOException

Sweet Home 3D 3.4

? Copyrights 2006-2011 eTeks - All rights reserved
Distributed under GNU General Public License