[−][src]Struct easy_gltf::Model
Geometry to be rendered with the given material.
Examples
Classic rendering
In most cases you want to use triangles()
, lines()
and points()
to get the geometry of the model.
match model.mode() { Mode::Triangles | Mode::TriangleFan | Mode::TriangleStrip => { let triangles = model.triangles().unwrap(); // Render triangles... }, Mode::Lines | Mode::LineLoop | Mode::LineStrip => { let lines = model.lines().unwrap(); // Render lines... } Mode::Points => { let points = model.points().unwrap(); // Render points... } }
OpenGL style rendering
You will need the vertices and the indices if existing.
let vertices = model. vertices(); let indices = model.indices(); match model.mode() { Mode::Triangles => { if let Some(indices) = indices.as_ref() { // glDrawElements(GL_TRIANGLES, indices.len(), GL_UNSIGNED_INT, 0); } else { // glDrawArrays(GL_TRIANGLES, 0, vertices.len()); } }, // ... }
Implementations
impl Model
[src]
pub fn material(&self) -> Arc<Material>
[src]
Material to apply to the whole model.
pub fn vertices(&self) -> &Vec<Vertex>
[src]
List of raw vertices
of the model. You might have to use the indices
to render the model.
Note: If you're not rendering with OpenGL you probably want to use
triangles()
, lines()
or points()
instead.
pub fn indices(&self) -> Option<&Vec<usize>>
[src]
Potential list of indices
to render the model using raw vertices
.
Note: If you're not rendering with OpenGL you probably want to use
triangles()
, lines()
or points()
instead.
pub fn mode(&self) -> Mode
[src]
The type of primitive to render.
You have to check the mode
to render the model correctly.
Then you can either use:
vertices()
andindices()
to arrange the data yourself (useful for OpenGL).triangles()
orlines()
orpoints()
according to the returned mode.
pub fn triangles(&self) -> Result<Vec<Triangle>, BadMode>
[src]
List of triangles ready to be rendered.
Note: This function will return an error if the mode isn't Triangles
, TriangleFan
or TriangleStrip
.
pub fn lines(&self) -> Result<Vec<Line>, BadMode>
[src]
List of lines ready to be rendered.
Note: This function will return an error if the mode isn't Lines
, LineLoop
or LineStrip
.
pub fn points(&self) -> Result<&Vec<Vertex>, BadMode>
[src]
List of points ready to be renderer.
Note: This function will return an error if the mode isn't Points
.
pub fn has_normals(&self) -> bool
[src]
Indicate if the vertices contains normal information.
Note: If this function return false
all vertices has a normal field
initialized to zero
.
pub fn has_tangents(&self) -> bool
[src]
Indicate if the vertices contains tangents information.
Note: If this function return false
all vertices has a tangent field
initialized to zero
.
pub fn has_tex_coords(&self) -> bool
[src]
Indicate if the vertices contains texture coordinates information.
Note: If this function return false
all vertices has a tex_coord field
initialized to zero
.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Model
impl Send for Model
impl Sync for Model
impl Unpin for Model
impl UnwindSafe for Model
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,