pub struct Obj {
pub data: ObjData,
pub path: PathBuf,
}
Expand description
A struct used to store Obj
data as well as its source directory used to load the referenced
.mtl files.
Fields§
§data: ObjData
The data associated with this Obj
file.
path: PathBuf
The path of the parent directory from which this file was read.
It is not always set since the file may have been read from a String
.
Implementations§
Source§impl Obj
impl Obj
Sourcepub fn load(path: impl AsRef<Path>) -> Result<Obj, ObjError>
pub fn load(path: impl AsRef<Path>) -> Result<Obj, ObjError>
Load an Obj
file from the given path with the default load configuration.
Sourcepub fn load_with_config(
path: impl AsRef<Path>,
config: LoadConfig,
) -> Result<Obj, ObjError>
pub fn load_with_config( path: impl AsRef<Path>, config: LoadConfig, ) -> Result<Obj, ObjError>
Load an Obj
file from the given path using a custom load configuration.
Sourcepub fn load_mtls(&mut self) -> Result<(), MtlLibsLoadError>
pub fn load_mtls(&mut self) -> Result<(), MtlLibsLoadError>
Loads the .mtl files referenced in the .obj file.
If it encounters an error for an .mtl, it appends its error to the returning Vec, and tries the rest.
Sourcepub fn load_mtls_fn<R, F>(&mut self, resolve: F) -> Result<(), MtlLibsLoadError>
pub fn load_mtls_fn<R, F>(&mut self, resolve: F) -> Result<(), MtlLibsLoadError>
Loads the .mtl files referenced in the .obj file with user provided loading logic.
See also load_mtls
.
The provided function must take two arguments:
&Path
- The parent directory of the .obj file&str
- The name of the mtllib as listed in the file.
This function allows loading .mtl files in directories different from the default .obj directory.
It must return:
- Anything that implements
io::BufRead
that yields the contents of the intended .mtl file.