Package com.irurueta.geometry.io
Class MaterialLoaderOBJ
java.lang.Object
com.irurueta.geometry.io.MaterialLoader
com.irurueta.geometry.io.MaterialLoaderOBJ
- All Implemented Interfaces:
Closeable,AutoCloseable
MaterialLoader implementation for OBJ files, which is capable of reading its
associated MTL file.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate MaterialOBJCurrent material being loaded.Set of materials loaded in MTL file.static final shortMaximum allowed color value.private intNumber of textures that have been found in MTL file.Fields inherited from class com.irurueta.geometry.io.MaterialLoader
DEFAULT_FILE_SIZE_LIMIT_TO_KEEP_IN_MEMORY, DEFAULT_TEXTURE_VALIDATION_ENABLED, file, listener, locked, reader, textureValidationEnabled -
Constructor Summary
ConstructorsConstructorDescriptionDefault Constructor.MaterialLoaderOBJ(MaterialLoaderListener listener) Constructor.Constructor.MaterialLoaderOBJ(File f, MaterialLoaderListener listener) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates if any material has been loaded already.booleancontainsMaterial(String name) Indicates if material having provided name has been loaded or not.getMaterialByName(String name) Gets a material by its name, or null if material is not found.Returns material by texture name.Returns set of materials that have been read.booleanisReady()Indicates if material loader is ready to be used because a file has already been provided.load()Starts the loading process of provided file.private voidParses a line in an MTL file.Methods inherited from class com.irurueta.geometry.io.MaterialLoader
close, getFileSizeLimitToKeepInMemory, getListener, hasFile, isLocked, isTextureValidationEnabled, setFile, setFileSizeLimitToKeepInMemory, setListener, setLocked, setTextureValidationEnabled
-
Field Details
-
MAX_COLOR_VALUE
public static final short MAX_COLOR_VALUEMaximum allowed color value.- See Also:
-
materials
Set of materials loaded in MTL file. -
currentMaterial
Current material being loaded. -
textureCounter
private int textureCounterNumber of textures that have been found in MTL file.
-
-
Constructor Details
-
MaterialLoaderOBJ
public MaterialLoaderOBJ()Default Constructor. -
MaterialLoaderOBJ
Constructor.- Parameters:
f- material file to be read.- Throws:
IOException- raised if provided file does not exist or an I/O exception occurs.
-
MaterialLoaderOBJ
Constructor.- Parameters:
listener- material listener to notify start, end and progress events.
-
MaterialLoaderOBJ
Constructor.- Parameters:
f- material file to be read.listener- material listener to notify start, end and progress events.- Throws:
IOException- raised if provided file does not exist or an I/O exception occurs.
-
-
Method Details
-
isReady
public boolean isReady()Indicates if material loader is ready to be used because a file has already been provided.- Specified by:
isReadyin classMaterialLoader- Returns:
- true if material loader is ready, false otherwise.
-
load
Starts the loading process of provided file. This method returns a set containing all the materials that have been loaded.- Specified by:
loadin classMaterialLoader- Returns:
- a set containing all the materials that have been loaded.
- Throws:
LockedException- raised if this instance is already locked.NotReadyException- raised if this instance is not yet ready.IOException- if an I/O error occurs.LoaderException- if file is corrupted or cannot be interpreted.
-
parseLine
Parses a line in an MTL file.- Parameters:
line- line being parsed.- Throws:
LoaderException- if line cannot be interpreted.
-
areMaterialsAvailable
public boolean areMaterialsAvailable()Indicates if any material has been loaded already.- Returns:
- true if materials have been loaded, false otherwise.
-
getMaterials
Returns set of materials that have been read.- Returns:
- set of materials that have been read.
-
getMaterialByName
Gets a material by its name, or null if material is not found.- Parameters:
name- name of material to be found.- Returns:
- a material having provided name or null if none is found.
-
containsMaterial
Indicates if material having provided name has been loaded or not.- Parameters:
name- name to search material by.- Returns:
- true if material having provided name exists, false otherwise.
-
getMaterialByTextureMapName
Returns material by texture name.- Parameters:
name- name of texture.- Returns:
- texture that has been found or null if none has been found.
-