Package com.irurueta.geometry.io
Class DataChunk
java.lang.Object
com.irurueta.geometry.io.DataChunk
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
FieldsModifier and TypeFieldDescriptionprivate intIndicates 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 intConstant defining default number of color components for RGBprivate int[]Array containing indices of vertices to build the triangles forming the 3D shape on this chunk.private MaterialMaterial of this chunk.private floatX maximum coordinate of the bounding box containing all the data of this data chunk.private floatY maximum coordinate of the bounding box containing all the data of this data chunk.private floatZ maximum coordinate of the bounding box containing all the data of this data chunk.static final intConstant defining minimum number of color components, which is 1 for grayscale.private floatX minimum coordinate of the bounding box containing all the data of this data chunk.private floatY minimum coordinate of the bounding box containing all the data of this data chunk.private floatZ 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 -
Method Summary
Modifier and TypeMethodDescriptionintReturns 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.floatgetMaxX()Returns X maximum coordinate of the bounding box containing all the data of this data chunk.floatgetMaxY()Returns Y maximum coordinate of the bounding box containing all the data of this data chunk.floatgetMaxZ()Returns Z maximum coordinate of the bounding box containing all the data of this data chunk.floatgetMinX()Returns X minimum coordinate of the bounding box containing all the data of this data chunk.floatgetMinY()Returns Y minimum coordinate of the bounding box containing all the data of this data chunk.floatgetMinZ()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.booleanIndicates if array containing the color for each vertex has been provided and is available for retrieval.booleanIndicates if array containing the indices of vertices to build the triangles has been provided and is available for retrieval.booleanReturns boolean indicating whether a material has been provided for this chunk.booleanIndicates if array containing normal coordinates for each vertex has been provided and is available for retrieval.booleanIndicates if array containing texture coordinates in a texture image has been provided and is available for retrieval.booleanIndicates if array containing 3D coordinates has been provided and is available for retrieval.voidsetColorComponents(int colorComponents) Sets number of color components stored in the array.voidsetColorData(short[] colors) Sets array containing the color for each vertex in the chunk of data.voidsetIndicesData(int[] indices) Sets array that contains indices of vertices to build the triangles forming the 3D shape on this chunk.voidsetMaterial(Material material) Sets material of this chunk.voidsetMaxX(float maxX) Sets X maximum coordinate of the bounding box containing all the data of this data chunk.voidsetMaxY(float maxY) Sets Y maximum coordinate of the bounding box containing all the data of this data chunk.voidsetMaxZ(float maxZ) Sets Z maximum coordinate of the bounding box containing all the data of this data chunk.voidsetMinX(float minX) Sets X minimum coordinate of the bounding box containing all the data of this data chunk.voidsetMinY(float minY) Sets Y minimum coordinate of the bounding box containing all the data of this data chunk.voidsetMinZ(float minZ) Sets Z minimum coordinate of the bounding box containing all the data of this data chunk.voidsetNormalsData(float[] normals) Sets array containing normal coordinates for each vertex.voidsetTextureCoordinatesData(float[] textureCoords) Sets array containing texture coordinates in a texture image for a given 3D point.voidsetVerticesCoordinatesData(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.
-
Field Details
-
MIN_COLOR_COMPONENTS
public static final int MIN_COLOR_COMPONENTSConstant defining minimum number of color components, which is 1 for grayscale.- See Also:
-
DEFAULT_COLOR_COMPONENTS
public static final int DEFAULT_COLOR_COMPONENTSConstant defining default number of color components for RGB- See Also:
-
coords
private float[] coordsArray 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[] colorsArray 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[] indicesArray 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[] textureCoordsArray 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[] normalsArray 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 colorComponentsIndicates 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 minXX minimum coordinate of the bounding box containing all the data of this data chunk. -
minY
private float minYY minimum coordinate of the bounding box containing all the data of this data chunk. -
minZ
private float minZZ minimum coordinate of the bounding box containing all the data of this data chunk. -
maxX
private float maxXX maximum coordinate of the bounding box containing all the data of this data chunk. -
maxY
private float maxYY maximum coordinate of the bounding box containing all the data of this data chunk. -
maxZ
private float maxZZ maximum coordinate of the bounding box containing all the data of this data chunk. -
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
Returns material of this chunk. This will be used to define ambient colors, textures, etc. for this chunk.- Returns:
- Materials of this chunk.
-
setMaterial
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.
-