glTF model loader #82
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
There's no way to load models from files.
ResourceRegistryRef::load<Mesh>(path)(engine/src/resources/resource_registry_ref.cpp) is a stub that asserts, so every mesh has to be built by hand as aMeshDataor come fromprimitives.glTF 2.0 is the format to support first. It's an open standard, most tools export it, and its conventions already match the engine's:
MeshData)MeshVertex::uv)Proposal
Add a parser library to
third_party/. Candidates:.gltf,.glband data URIs.Phase 1: geometry
load<Mesh>(path)for.gltfand.glb.POSITION,NORMAL,TEXCOORD_0andCOLOR_0attributes and the indices intoMeshData, then create the mesh through the existing path.(0,0,1)or computed, uv(0,0), color white.u32.MeshHandleor whetherMeshgains submeshes, since each primitive can use a different material.Phase 2: materials and textures (depends on the material system)
pbrMetallicRoughness(base color factor and texture, metallic and roughness factors, metallic-roughness texture),normalTexture,occlusionTextureandemissiveonto material instances.Phase 3: scenes
Sceneas entities with aTransformComponentand a mesh component (node TRS to position, rotation, scale), keeping parent/child relationships if the ECS supports them.Out of scope for now
Animation, skinning, morph targets, cameras and lights, KHR extensions, and Draco or meshopt compression.
Acceptance criteria
resources().load<Mesh>("model.glb")returns a mesh that renders correctly, in both.gltfand.glbform.