#I don't know how to load a textures from gltf file use gltf-rs crate

13 messages · Page 1 of 1 (latest)

hollow meteor
#

Hello. I'm creating a my game engine and at the moment I'm working for loader a 3d models. I use a gltf-rs crate for loading a model and I don't know how to loading a textures.
Here's the code:

use gltf;

pub struct GltfModel { 
  // some fields
}

impl GltfModel {
  pub fn load_gltf(path: &str) -> Self {
    let (gltf, buffers, images) = gltf::import(path).unwrap();

    for mesh in gltf.meshes() {
      for primitive in gltf.primitive() {
        // reading a vertices, it's work

        // loading textures, how?
      }
    }
  }
}

Please help me and sorry for my English.

novel ibex
#

the texture data is in images

hollow meteor
#

ok, how to get a type of texture(normal, specular and ets)

#

and width, height

novel ibex
#

the width and height is in the Data

#

textures don't have a type; the interpretation of their data is based on how they are used in a Material

#

(the same texture can be used in multiple ways)

hollow meteor
#

Can you please give an example, because the rust-analyzer does not show me the connection, and I did not find it in the documentation

novel ibex
#

sorry, I don't know of any examples

#

and the docs aren't clear on this point, but I assume that the image indices in the gltf document will be the same as the indices into the images vector

hollow meteor
#

Okay, I'll try it

novel ibex
hollow meteor
#

thank you