pub struct Obj { /* private fields */ }
Expand description
A struct representing the contents of a parsed OBJ file.
Implementations
sourceimpl Obj
impl Obj
sourcepub fn from_reader<R: Read>(reader: R) -> Result<Self, Error>
pub fn from_reader<R: Read>(reader: R) -> Result<Self, Error>
Read an OBJ from a reader (something implementing std::io::Read
).
sourcepub fn from_lines<I: Iterator<Item = L>, L: AsRef<str>>(
lines: I
) -> Result<Self, Error>
pub fn from_lines<I: Iterator<Item = L>, L: AsRef<str>>(
lines: I
) -> Result<Self, Error>
Read an OBJ from an iterator over its lines.
sourcepub fn write<W: Write>(&self, writer: W) -> Result<(), Error>
pub fn write<W: Write>(&self, writer: W) -> Result<(), Error>
Write this Obj
to a writer (something implementing std::io::Write
) in OBJ format.
sourcepub fn save<P: AsRef<Path>>(&self, path: P) -> Result<(), Error>
pub fn save<P: AsRef<Path>>(&self, path: P) -> Result<(), Error>
Write this Obj
to a file in OBJ format.
sourcepub fn object(&self, name: &str) -> Option<Object<'_>>
pub fn object(&self, name: &str) -> Option<Object<'_>>
Returns a specific Object
by name.
Note that if a name is not specified in the OBJ file, the name defaults to an empty string.
Methods from Deref<Target = Buffers>
sourcepub fn positions(&self) -> &[[f32; 3]]
pub fn positions(&self) -> &[[f32; 3]]
Returns a reference to the position attributes contained within this Obj
.
sourcepub fn uvs(&self) -> &[[f32; 3]]
pub fn uvs(&self) -> &[[f32; 3]]
Returns a reference to the texture coordinate attributes contained within this Obj
.
sourcepub fn normals(&self) -> &[[f32; 3]]
pub fn normals(&self) -> &[[f32; 3]]
Returns a reference to the normal attributes contained within this Obj
.
sourcepub fn add_position(&mut self, position: [f32; 3]) -> usize
pub fn add_position(&mut self, position: [f32; 3]) -> usize
Add a new position attribute to this Obj
, returning its index.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Obj
impl Send for Obj
impl Sync for Obj
impl Unpin for Obj
impl UnwindSafe for Obj
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more