Class MeshWriterJson

java.lang.Object
com.irurueta.geometry.io.MeshWriter
com.irurueta.geometry.io.MeshWriterJson

public class MeshWriterJson extends MeshWriter
  • Field Details

    • DEFAULT_EMBED_TEXTURES

      public static final boolean DEFAULT_EMBED_TEXTURES
      Indicates if textures must be embedded into resulting file.
      See Also:
    • DEFAULT_USE_REMOTE_TEXTURE_URL

      public static final boolean DEFAULT_USE_REMOTE_TEXTURE_URL
      Indicates if by default a URL indicating where the texture can be located should be included into resulting file.
      See Also:
    • DEFAULT_USE_REMOTE_TEXTURE_ID

      public static final boolean DEFAULT_USE_REMOTE_TEXTURE_ID
      Indicates if by default an identifier for the texture should be included into resulting file so that texture image can be fetched by some other mean.
      See Also:
    • charset

      private Charset charset
      Indicates charset to use in resulting JSON file. By default, this will be UTF-8.
    • writer

      private BufferedWriter writer
      Writer to write resulting JSON into output stream.
    • textureCounter

      private int textureCounter
      Counter for the number of textures that have been read.
    • embedTexturesEnabled

      private boolean embedTexturesEnabled
      Indicates if textures will be embedded into resulting JSON stream of data. When embedding textures their stream of bytes is written using BASE64 to the output stream.
    • remoteTextureUrlEnabled

      private boolean remoteTextureUrlEnabled
      Indicates if a URL indicating where the texture can be located should be included into resulting file.
    • remoteTextureIdEnabled

      private boolean remoteTextureIdEnabled
      Indicates if an identifier for the texture should be included into resulting file so that texture image can be fetched by some other mean.
  • Constructor Details

    • MeshWriterJson

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

      public MeshWriterJson(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

    • getCharset

      public Charset getCharset()
      Returns charset to use in resulting JSON file. By default, this will be UTF-8.
      Returns:
      charset to use in resulting JSON file.
    • setCharset

      public void setCharset(Charset charset) throws LockedException
      Sets charset to use in resulting JSON file. By default, this will be UTF-8.
      Parameters:
      charset - charset to use in resulting JSON file.
      Throws:
      LockedException - if this mesh writer is locked processing a file.
    • isDefaultCharsetBeingUsed

      public boolean isDefaultCharsetBeingUsed()
      Indicates if default charset will be used or not.
      Returns:
      true if default charset (UTF-8) will be used, false otherwise.
    • isEmbedTexturesEnabled

      public boolean isEmbedTexturesEnabled()
      Indicates if textures are embedded into resulting JSON or not. When embedding textures their stream of bytes is written using BASE64 to the output stream.
      Returns:
      true if textures are embedded into resulting JSON, false otherwise.
    • setEmbedTexturedEnabled

      public void setEmbedTexturedEnabled(boolean embedTexturesEnabled) throws LockedException
      Specified whether textures are embedded into resulting JSON or not. When embedding textures their stream of bytes is written using BASE64 to the output stream.
      Parameters:
      embedTexturesEnabled - true if textures will be embedded into resulting JSON, false.
      Throws:
      LockedException - if this mesh writer is locked processing a file.
    • isRemoteTextureUrlEnabled

      public boolean isRemoteTextureUrlEnabled()
      Indicates if a URL indicating where the texture can be located should be included into resulting file.
      Returns:
      true if a URL indicating where the texture can be located will be included into resulting file, false otherwise.
    • setRemoteTextureUrlEnabled

      public void setRemoteTextureUrlEnabled(boolean remoteTextureUrlEnabled) throws LockedException
      Specifies whether a URL indicating where the texture can be located should be included into resulting file.
      Parameters:
      remoteTextureUrlEnabled - true if a URL indicating where the texture can be located will be included into resulting file, false otherwise.
      Throws:
      LockedException - if this mesh writer is locked processing a file.
    • isRemoteTextureIdEnabled

      public boolean isRemoteTextureIdEnabled()
      Indicates if an identifier for the texture should be included into resulting file so that texture image can be fetched by some other mean.
      Returns:
      true if an identifier for the texture should be included into. resulting file so that texture image can be fetched by some other mean.
    • setRemoteTextureIdEnabled

      public void setRemoteTextureIdEnabled(boolean remoteTextureIdEnabled) throws LockedException
      Specifies whether an identifier for the texture should be included into resulting file so that texture image can be fetched by some other mean.
      Parameters:
      remoteTextureIdEnabled - true if identifier for the texture should be included into resulting file.
      Throws:
      LockedException - if this mesh writer is locked processing file.
    • write

      Processes input file provided to loader and writes it trans-coded into output stream.
      Specified by:
      write in class MeshWriter
      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 void processTextureFile(Texture texture, File textureFile) throws IOException
      Processes texture file. By reading provided texture file that has been created in a temporal location and embedding it into resulting output stream.
      Specified by:
      processTextureFile in class MeshWriter
      Parameters:
      texture - reference to texture that uses texture image
      textureFile - file containing texture image. File will usually be created in a temporal location.
      Throws:
      IOException - if an I/O error occurs
    • writeMaterial

      private void writeMaterial(Material material) throws IOException
      Writes material into output JSON file.
      Parameters:
      material - material to be written.
      Throws:
      IOException - if an I/O error occurs.