Class DataChunk

java.lang.Object
com.irurueta.geometry.io.DataChunk

public class DataChunk extends Object
Class containing a piece of 3D data loaded from a file. This class is used along with a LoaderIterator so that very large 3D files can be read in a step-by-step process returning consecutive DataChunk's of the file.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
    Indicates number of color components stored in the array.
    private short[]
    Array containing the color for each vertex in the chunk of data.
    private float[]
    Array containing 3D coordinates for all points in a chunk in consecutive order, that is, array will contain values x0, y0, z0, x1, y1, z1, ...
    static final int
    Constant defining default number of color components for RGB
    private int[]
    Array containing indices of vertices to build the triangles forming the 3D shape on this chunk.
    private Material
    Material of this chunk.
    private float
    X maximum coordinate of the bounding box containing all the data of this data chunk.
    private float
    Y maximum coordinate of the bounding box containing all the data of this data chunk.
    private float
    Z maximum coordinate of the bounding box containing all the data of this data chunk.
    static final int
    Constant defining minimum number of color components, which is 1 for grayscale.
    private float
    X minimum coordinate of the bounding box containing all the data of this data chunk.
    private float
    Y minimum coordinate of the bounding box containing all the data of this data chunk.
    private float
    Z minimum coordinate of the bounding box containing all the data of this data chunk.
    private float[]
    Array containing normal coordinates for each vertex.
    private float[]
    Array containing texture coordinates in a texture image for a given 3D point.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns number of color components stored in the array.
    short[]
    Returns array containing the color for each vertex in the chunk of data.
    int[]
    Returns array containing indices of vertices to build the triangles forming the 3D shape on this chunk.
    Returns material of this chunk.
    float
    Returns X maximum coordinate of the bounding box containing all the data of this data chunk.
    float
    Returns Y maximum coordinate of the bounding box containing all the data of this data chunk.
    float
    Returns Z maximum coordinate of the bounding box containing all the data of this data chunk.
    float
    Returns X minimum coordinate of the bounding box containing all the data of this data chunk.
    float
    Returns Y minimum coordinate of the bounding box containing all the data of this data chunk.
    float
    Returns Z minimum coordinate of the bounding box containing all the data of this data chunk.
    float[]
    Returns array containing normal coordinates for each vertex.
    float[]
    Returns array containing texture coordinates in a texture image for a given 3D point.
    float[]
    Returns array containing 3D coordinates for all points in a chunk in consecutive order, that is, array will contain values x0, y0, z0, x1, y1, z1... and so on.
    boolean
    Indicates if array containing the color for each vertex has been provided and is available for retrieval.
    boolean
    Indicates if array containing the indices of vertices to build the triangles has been provided and is available for retrieval.
    boolean
    Returns boolean indicating whether a material has been provided for this chunk.
    boolean
    Indicates if array containing normal coordinates for each vertex has been provided and is available for retrieval.
    boolean
    Indicates if array containing texture coordinates in a texture image has been provided and is available for retrieval.
    boolean
    Indicates if array containing 3D coordinates has been provided and is available for retrieval.
    void
    setColorComponents(int colorComponents)
    Sets number of color components stored in the array.
    void
    setColorData(short[] colors)
    Sets array containing the color for each vertex in the chunk of data.
    void
    setIndicesData(int[] indices)
    Sets array that contains indices of vertices to build the triangles forming the 3D shape on this chunk.
    void
    Sets material of this chunk.
    void
    setMaxX(float maxX)
    Sets X maximum coordinate of the bounding box containing all the data of this data chunk.
    void
    setMaxY(float maxY)
    Sets Y maximum coordinate of the bounding box containing all the data of this data chunk.
    void
    setMaxZ(float maxZ)
    Sets Z maximum coordinate of the bounding box containing all the data of this data chunk.
    void
    setMinX(float minX)
    Sets X minimum coordinate of the bounding box containing all the data of this data chunk.
    void
    setMinY(float minY)
    Sets Y minimum coordinate of the bounding box containing all the data of this data chunk.
    void
    setMinZ(float minZ)
    Sets Z minimum coordinate of the bounding box containing all the data of this data chunk.
    void
    setNormalsData(float[] normals)
    Sets array containing normal coordinates for each vertex.
    void
    setTextureCoordinatesData(float[] textureCoords)
    Sets array containing texture coordinates in a texture image for a given 3D point.
    void
    Sets array containing 3D coordinates for all points in a chunk in consecutive order, that is, array will contain values x0, y0, z0, x1, y1, z1, ... and so on.

    Methods inherited from class java.lang.Object

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

    • MIN_COLOR_COMPONENTS

      public static final int MIN_COLOR_COMPONENTS
      Constant defining minimum number of color components, which is 1 for grayscale.
      See Also:
    • DEFAULT_COLOR_COMPONENTS

      public static final int DEFAULT_COLOR_COMPONENTS
      Constant defining default number of color components for RGB
      See Also:
    • coords

      private float[] coords
      Array containing 3D coordinates for all points in a chunk in consecutive order, that is, array will contain values x0, y0, z0, x1, y1, z1, ... and so on.
    • colors

      private short[] colors
      Array containing the color for each vertex in the chunk of data. Values will be stored consecutively as r0, g0, b0, r1, g1, b1, ... and so on. If transparency is provided, then array will be stored as r0, g0, b0, a0, r1, g1, b1, a1...
      See Also:
    • indices

      private int[] indices
      Array containing indices of vertices to build the triangles forming the 3D shape on this chunk. Indices will be stored consecutively in sets of 3, indicating the 3 vertices of each triangle, that is: p1a, p2a, p3a, p1b, p2b, p3b, etc... The indices will be used to pick appropriate point coordinates, texture coordinates, normals or colors from their corresponding arrays.
    • textureCoords

      private float[] textureCoords
      Array containing texture coordinates in a texture image for a given 3D point. All texture coordinates are stored consecutively in the array as: x0, y0, x1, y1, etc. Usually coordinates are stored in a normalized form having values between 0.0 and 1.0. Usually larger values indicate that the image will repeat when exceeding its borders, and negative values indicate that the image will be reversed.
    • normals

      private float[] normals
      Array containing normal coordinates for each vertex. Normal coordinates are useful to draw correct lighting. All normal coordinates are stored consecutively in the array as: x0, y0, z0, x1, y1, z1, etc.
    • colorComponents

      private int colorComponents
      Indicates number of color components stored in the array. Usually for RGB it will be 3. When transparency is available, it will be 4.
    • minX

      private float minX
      X minimum coordinate of the bounding box containing all the data of this data chunk.
    • minY

      private float minY
      Y minimum coordinate of the bounding box containing all the data of this data chunk.
    • minZ

      private float minZ
      Z minimum coordinate of the bounding box containing all the data of this data chunk.
    • maxX

      private float maxX
      X maximum coordinate of the bounding box containing all the data of this data chunk.
    • maxY

      private float maxY
      Y maximum coordinate of the bounding box containing all the data of this data chunk.
    • maxZ

      private float maxZ
      Z maximum coordinate of the bounding box containing all the data of this data chunk.
    • material

      private Material material
      Material of this chunk. This will be used to define ambient colors, textures etc. for this chunk.
  • Constructor Details

    • DataChunk

      public DataChunk()
      Default Constructor
  • Method Details

    • setVerticesCoordinatesData

      public void setVerticesCoordinatesData(float[] coords)
      Sets array containing 3D coordinates for all points in a chunk in consecutive order, that is, array will contain values x0, y0, z0, x1, y1, z1, ... and so on.
      Parameters:
      coords - Array containing 3D coordinates for all points in a chunk.
    • getVerticesCoordinatesData

      public float[] getVerticesCoordinatesData()
      Returns array containing 3D coordinates for all points in a chunk in consecutive order, that is, array will contain values x0, y0, z0, x1, y1, z1... and so on.
      Returns:
      Array containing 3D coordinates for all points in a chunk.
    • isVerticesCoordinatesDataAvailable

      public boolean isVerticesCoordinatesDataAvailable()
      Indicates if array containing 3D coordinates has been provided and is available for retrieval.
      Returns:
      True if available, false otherwise.
    • setColorData

      public void setColorData(short[] colors)
      Sets array containing the color for each vertex in the chunk of data. Values will be stored consecutively as r0, g0, b0, r1, g1, b1, ... and so on. If transparency is provided, then array will be stored as r0, g0, b0, a0, r1, g1, b1, a1...
      Parameters:
      colors - Array containing the color for each vertex to be set
      See Also:
    • getColorData

      public short[] getColorData()
      Returns array containing the color for each vertex in the chunk of data. Array usually contains data stored consecutively as r0, g0, b0, r1, g1, b1... and so on. If transparency is used, then array will be stored as r0, g0, b0, a0, r1, g1, b1, a1... There will be as many values per vertex as the number of color components
      Returns:
      array containing the color for each vertex in the chunk of data.
    • isColorDataAvailable

      public boolean isColorDataAvailable()
      Indicates if array containing the color for each vertex has been provided and is available for retrieval.
      Returns:
      True if available, false otherwise.
    • setIndicesData

      public void setIndicesData(int[] indices)
      Sets array that contains indices of vertices to build the triangles forming the 3D shape on this chunk. Indices need to be stored consecutively in sets of 3, indicating the 3 vertices of each triangle, that is: p1a, p2a, p3a, p1b, p2b, p3b, etc. Provided indices will be used to pick appropriate point coordinates, texture coordinates, normals or colors from their corresponding arrays
      Parameters:
      indices - indices of vertices to build triangles.
    • getIndicesData

      public int[] getIndicesData()
      Returns array containing indices of vertices to build the triangles forming the 3D shape on this chunk. Indices will be stored consecutively in sets of 3, indicating the 3 vertices of each triangle, that is: p1a, p2a, p3a, p1b, p2b, p3b, etc. Provided indices will be used to pick appropriate point coordinates, texture coordinates, normals or colors from their corresponding arrays.
      Returns:
      Array containing indices of vertices to build the triangles.
    • isIndicesDataAvailable

      public boolean isIndicesDataAvailable()
      Indicates if array containing the indices of vertices to build the triangles has been provided and is available for retrieval.
      Returns:
      True if available, false otherwise.
    • setTextureCoordinatesData

      public void setTextureCoordinatesData(float[] textureCoords)
      Sets array containing texture coordinates in a texture image for a given 3D point. All texture coordinates are stored consecutively in the array as: x0, y0, x1, y1, etc. Usually coordinates are stored in a normalized form having values between 0.0 and 1.0. Usually larger values indicate that the image will repeat when exceeding its borders, and negative values indicate that the image will be reversed.
      Parameters:
      textureCoords - Array containing texture coordinates in a texture image.
    • getTextureCoordinatesData

      public float[] getTextureCoordinatesData()
      Returns array containing texture coordinates in a texture image for a given 3D point. All texture coordinates are stored consecutively in the array as: x0, y0, x1, y1, etc. Usually coordinates are stored in a normalized form having values between 0.0 and 1.0. Usually larger values indicate that the image will repeat when exceeding its borders, and negative values indicate that the image will be reversed.
      Returns:
      Array containing texture coordinates in a texture image.
    • isTextureCoordinatesDataAvailable

      public boolean isTextureCoordinatesDataAvailable()
      Indicates if array containing texture coordinates in a texture image has been provided and is available for retrieval.
      Returns:
      True if available, false otherwise.
    • setNormalsData

      public void setNormalsData(float[] normals)
      Sets array containing normal coordinates for each vertex. Normal coordinates are useful to draw correct lighting. All normal coordinates are stored consecutively in the array as: x0, y0, z0, x1, y1, z1, etc.
      Parameters:
      normals - Array containing normal coordinates for each vertex.
    • getNormalsData

      public float[] getNormalsData()
      Returns array containing normal coordinates for each vertex. Normal coordinates are useful to draw correct lighting. All normal coordinates are stored consecutively in the array as: x0, y0, z0, x1, y1, z1, etc.
      Returns:
      Array containing normal coordinates for each vertex.
    • isNormalsDataAvailable

      public boolean isNormalsDataAvailable()
      Indicates if array containing normal coordinates for each vertex has been provided and is available for retrieval.
      Returns:
      True if available, false otherwise.
    • getColorComponents

      public int getColorComponents()
      Returns number of color components stored in the array. Usually for RGB it will be 3. When transparency is available, it will be 4. For gray-scale it will be 1.
      Returns:
      Number of color components.
    • setColorComponents

      public void setColorComponents(int colorComponents)
      Sets number of color components stored in the array. Usually for RGB it will be 3. When transparency is available, it will be 4. For gray-scale it will be 1.
      Parameters:
      colorComponents - Number of color components stored in the array.
      Throws:
      IllegalArgumentException - Raised if provided color components is negative.
    • getMinX

      public float getMinX()
      Returns X minimum coordinate of the bounding box containing all the data of this data chunk.
      Returns:
      X minimum coordinate of the bounding box.
    • setMinX

      public void setMinX(float minX)
      Sets X minimum coordinate of the bounding box containing all the data of this data chunk.
      Parameters:
      minX - X minimum coordinate of the bounding box.
    • getMinY

      public float getMinY()
      Returns Y minimum coordinate of the bounding box containing all the data of this data chunk.
      Returns:
      Y minimum coordinate of the bounding box.
    • setMinY

      public void setMinY(float minY)
      Sets Y minimum coordinate of the bounding box containing all the data of this data chunk.
      Parameters:
      minY - Y minimum coordinate of the bounding box.
    • getMinZ

      public float getMinZ()
      Returns Z minimum coordinate of the bounding box containing all the data of this data chunk.
      Returns:
      Z minimum coordinate of the bounding box.
    • setMinZ

      public void setMinZ(float minZ)
      Sets Z minimum coordinate of the bounding box containing all the data of this data chunk.
      Parameters:
      minZ - Z minimum coordinate of the bounding box.
    • getMaxX

      public float getMaxX()
      Returns X maximum coordinate of the bounding box containing all the data of this data chunk.
      Returns:
      X maximum coordinate of the bounding box.
    • setMaxX

      public void setMaxX(float maxX)
      Sets X maximum coordinate of the bounding box containing all the data of this data chunk.
      Parameters:
      maxX - X maximum coordinate of the bounding box.
    • getMaxY

      public float getMaxY()
      Returns Y maximum coordinate of the bounding box containing all the data of this data chunk.
      Returns:
      Y maximum coordinate of the bounding box.
    • setMaxY

      public void setMaxY(float maxY)
      Sets Y maximum coordinate of the bounding box containing all the data of this data chunk.
      Parameters:
      maxY - Y maximum coordinate of the bounding box.
    • getMaxZ

      public float getMaxZ()
      Returns Z maximum coordinate of the bounding box containing all the data of this data chunk.
      Returns:
      Z maximum coordinate of the bounding box.
    • setMaxZ

      public void setMaxZ(float maxZ)
      Sets Z maximum coordinate of the bounding box containing all the data of this data chunk.
      Parameters:
      maxZ - Z maximum coordinate of the bounding box.
    • getMaterial

      public Material getMaterial()
      Returns material of this chunk. This will be used to define ambient colors, textures, etc. for this chunk.
      Returns:
      Materials of this chunk.
    • setMaterial

      public void setMaterial(Material material)
      Sets material of this chunk. This will be used to define ambient colors, textures, etc. for this chunk.
      Parameters:
      material - Material of this chunk.
    • isMaterialAvailable

      public boolean isMaterialAvailable()
      Returns boolean indicating whether a material has been provided for this chunk.
      Returns:
      True if material is available, false otherwise.