alloy::model::obj

Struct Model

source
pub struct Model {
    pub vertices: Vec<[f32; 4]>,
    pub normals: Vec<[f32; 3]>,
    pub tex_coords: Vec<[f32; 3]>,
    pub vertex_indices: Vec<[u32; 3]>,
    pub tex_coords_indices: Vec<[u32; 3]>,
    pub normal_indices: Vec<[u32; 3]>,
    pub vertex_components: usize,
    pub tex_coord_components: usize,
}
Expand description

A model that is loaded from a .obj file.

This is a raw representation of the obj file without doing any manipulation of the data. In order to be better consumed by the rendering engine, the data should be converted into a more appropriate format first.

This type is largely used in tooling for pipeline processing of models.

Fields§

§vertices: Vec<[f32; 4]>

The vertices of the model.

§normals: Vec<[f32; 3]>

The normals of the model.

§tex_coords: Vec<[f32; 3]>

The texture coordinates of the model.

§vertex_indices: Vec<[u32; 3]>

The indices of the vertices that make up the faces of the model.

§tex_coords_indices: Vec<[u32; 3]>

The indices of the texture coordinates that make up the faces of the model.

§normal_indices: Vec<[u32; 3]>

The indices of the normals that make up the faces of the model.

§vertex_components: usize

The number of components in each vertex.

§tex_coord_components: usize

The number of components in each texture coordinate.

Implementations§

source§

impl Model

source

pub fn new() -> Self

Create a new model.

source

pub fn from_file(file_path: &str) -> Result<Self, Error>

Load a model from a stored .obj file.

§Parameters
  • file_path - The path to the .obj file to load.

Trait Implementations§

source§

impl Debug for Model

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Model

source§

fn default() -> Model

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Model

§

impl RefUnwindSafe for Model

§

impl Send for Model

§

impl Sync for Model

§

impl Unpin for Model

§

impl UnwindSafe for Model

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.