Struct tobj::Mesh
[−]
[src]
pub struct Mesh { pub positions: Vec<f32>, pub normals: Vec<f32>, pub texcoords: Vec<f32>, pub indices: Vec<u32>, pub material_id: Option<usize>, }
A mesh made up of triangles loaded from some OBJ file
Fields
positions: Vec<f32>
Flattened 3 component floating point vectors, storing positions of vertices in the mesh
normals: Vec<f32>
Flattened 3 component floating point vectors, storing normals of vertices in the mesh. Not all meshes have normals, if no normals are specified this Vec will be empty
texcoords: Vec<f32>
Flattened 2 component floating point vectors, storing texture coordinates of vertices in the mesh. Not all meshes have normals, if no texture coordinates are specified this Vec will be empty
indices: Vec<u32>
Indices for vertices of each triangle. Each face in the mesh is a triangle and the indices specify the position, normal and texture coordinate for each vertex of the face.
Example:
// For some mesh with positions, normals and texcoords load the attributes for vertex k let i = mesh.indices[k]; vec3 pos = vec3 { x: mesh.positions[i * 3], y: mesh.positions[i * 3 + 1], z: mesh.positions[i * 3 + 2] }; vec3 normal = vec3 { x: mesh.normals[i * 3], y: mesh.normals[i * 3 + 1], z: mesh.normals[i * 3 + 2] }; vec2 texcoord = vec2 { u: mesh.texcoords[i * 2], v: mesh.texcoords[i * 2 + 1] };
material_id: Option<usize>
Optional material id associated with this mesh. The material id indexes into the Vec of Materials loaded from the associated MTL file
Methods
impl Mesh
[src]
fn new(pos: Vec<f32>, norm: Vec<f32>, tex: Vec<f32>, indices: Vec<u32>, material_id: Option<usize>) -> Mesh
Create a new mesh specifying the geometry for the mesh
fn empty() -> Mesh
Create a new empty mesh
Trait Implementations
impl Clone for Mesh
[src]
fn clone(&self) -> Mesh
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more