Class MeshWriter

java.lang.Object
com.irurueta.geometry.io.MeshWriter
Direct Known Subclasses:
MeshWriterBinary, MeshWriterJson

public abstract class MeshWriter extends Object
Abstract class that defines the interface for writers. A MeshWriter will be able to transcode a given 3D file into another format.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private class 
    Internal class implementing listeners for different specific loaders.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    Indicates if texture validation will be ignored or not.
    (package private) final MeshWriter.Listeners
    Internal class implementing specific listeners for some specific loader implementations.
    Listener to be notified when transcoding process starts, stops or when progress changes.
    protected final Loader
    Loader to load a file to be trans-coded.
    protected boolean
    Indicates if mesh writer is locked because a file is being processed.
    protected final OutputStream
    Stream where trans-coded data will be written to.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    MeshWriter(Loader loader, OutputStream stream)
    Constructor.
    protected
    MeshWriter(Loader loader, OutputStream stream, MeshWriterListener listener)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns listener to be notified when transcoding process starts, stops or when progress changes.
    Returns stream where trans-coded data will be written to.
    boolean
    Boolean indicating whether this mesh writer is locked because a file is being processed.
    boolean
    Indicates if this mesh writer is ready because a file and a loader have been provided.
    protected abstract void
    processTextureFile(Texture texture, File textureFile)
    Abstract method to processes texture file.
    void
    Sets listener to be notified when transcoding process starts, stops or when progress changes.
    abstract void
    Abstract method to process input file and write it into output stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • loader

      protected final Loader loader
      Loader to load a file to be trans-coded.
    • stream

      protected final OutputStream stream
      Stream where trans-coded data will be written to.
    • listener

      protected MeshWriterListener listener
      Listener to be notified when transcoding process starts, stops or when progress changes.
    • locked

      protected boolean locked
      Indicates if mesh writer is locked because a file is being processed.
    • ignoreTextureValidation

      protected boolean ignoreTextureValidation
      Indicates if texture validation will be ignored or not. If not ignored, it will be ensured that textures are valid image files.
    • internalListeners

      final MeshWriter.Listeners internalListeners
      Internal class implementing specific listeners for some specific loader implementations.
  • Constructor Details

    • MeshWriter

      protected MeshWriter(Loader loader, OutputStream stream)
      Constructor.
      Parameters:
      loader - loader to load a 3D file.
      stream - stream where trans-coded data will be written to.
    • MeshWriter

      protected MeshWriter(Loader loader, OutputStream stream, MeshWriterListener listener)
      Constructor.
      Parameters:
      loader - loader to load a 3D file.
      stream - stream where trans-coded data will be written to.
      listener - listener to be notified of progress changes or when transcoding process starts or finishes.
  • Method Details

    • isLocked

      public boolean isLocked()
      Boolean indicating whether this mesh writer is locked because a file is being processed.
      Returns:
      true if this instance is locked, false otherwise.
    • getStream

      public OutputStream getStream()
      Returns stream where trans-coded data will be written to.
      Returns:
      stream where trans-coded data will be written to.
    • getListener

      public MeshWriterListener getListener()
      Returns listener to be notified when transcoding process starts, stops or when progress changes.
      Returns:
      listener of this mesh writer.
    • setListener

      public void setListener(MeshWriterListener listener) throws LockedException
      Sets listener to be notified when transcoding process starts, stops or when progress changes.
      Parameters:
      listener - listener to be set.
      Throws:
      LockedException - if this instance is locked because this mesh writer is already processing a file.
    • isReady

      public boolean isReady()
      Indicates if this mesh writer is ready because a file and a loader have been provided.
      Returns:
      true if mesh writer is ready, false otherwise.
    • write

      public abstract void write() throws LoaderException, IOException, NotReadyException, LockedException
      Abstract method to process input file and write it into output stream.
      Throws:
      LoaderException - if 3D file loading fails.
      IOException - if an I/O error occurs.
      NotReadyException - if mesh writer is not ready because either a loader has not been provided or an output stream has not been provided.
      LockedException - if this mesh writer is locked processing a file.
    • processTextureFile

      protected abstract void processTextureFile(Texture texture, File textureFile) throws IOException
      Abstract method to processes texture file. Usually this will imply validating that image file is not corrupt and has proper size (power of 2). If not image will be resized.
      Parameters:
      texture - reference to texture.
      textureFile - file where texture is temporarily copied.
      Throws:
      IOException - if an I/O error occurs.