not-fl3 / macroquad

Cross-platform game engine in Rust.
Apache License 2.0
3.37k stars 324 forks source link

How can I add glb/gltf loading? #456

Open ianklatzco opened 2 years ago

ianklatzco commented 2 years ago

Rust noob here, trying to load a glb into a 3d macroquad scene derived from examples/first-person-camera.

I see there's a struct Mesh:

//! 3D shapes and models, loading 3d models from files, drawing 3D primitives.
...
pub struct Mesh {
    pub vertices: Vec<Vertex>,
    pub indices: Vec<u16>,
    pub texture: Option<Texture2D>,
}

The comment says "loading 3d models from files", but I don't see any code that actually does that, so I'm looking to write it.

I think I would need to:

Am I missing any steps? Thanks for the lib!

jmmut commented 1 year ago

Did you manage to do this? I want to do exactly the same thing.

I'm having trouble finding the actual vertex list from the Gltf object. I wonder if I have to use gltf::import as Gltf::open seems to load only the indices.

ianklatzco commented 1 year ago

Never succeeded! But I'm still interested: I wanted to use Naia (networking lib)'s Macroquad example to load 3D meshes.

Bevy might be the better choice because it's fuller-featured, but it's much heavier to compile.