Exports mesh entity to binary GLB file format with full material and submesh support.
Takes meshHandle (entity with mesh data), filename (output .glb path), meshName (mesh name in GLB metadata, defaults to "Mesh_0" if empty).
Returns 1 on success, 0 on failure.
3D Graphics
Parameters & Returns
Parameters
meshHandleInt
filenameString
meshNameString
Returns
Int
Quick Summary
Exports mesh entity to binary GLB file format with full material and submesh support.
Takes meshHandle (entity with mesh data), filename (output .glb path), meshName (mesh name in GLB metadata, defaults to "Mesh_0" if empty).
Returns 1 on success, 0 on failure.
Technical Exegesis...
Exports mesh entity to binary GLB file format with full material and submesh support. Takes meshHandle (entity with mesh data), filename (output .glb path), meshName (mesh name in GLB metadata, defaults to "Mesh_0" if empty). Returns 1 on success, 0 on failure. Validates entity exists and has mesh. Determines if multi-material (surface-based with multiple surfaces) or single-material. For surface-based meshes, exports one primitive per surface preserving material assignments.
Exports mesh entity to binary GLB file format with full material and submesh support. Takes meshHandle (entity with mesh data), filename (output .glb path), meshName (mesh name in GLB metadata, defaults to "Mesh_0" if empty). Returns 1 on success, 0 on failure. Validates entity exists and has mesh. Determines if multi-material (surface-based with multiple surfaces) or single-material. For surface-based meshes, exports one primitive per surface preserving material assignments. For loaded meshes, exports as single primitive. Collects vertex data (position, normal, UV0-UV3, color). Collects index data. Builds glTF JSON structure with nodes, meshes, accessors, bufferViews. Writes materials (baseColorFactor, metallicFactor, roughnessFactor, baseColorTexture references). Encodes to binary GLB format (12-byte header + JSON chunk + BIN chunk). Writes to file. Returns 0 if: invalid handle, no mesh data, file creation fails, GLB encoding fails.
This function exports to glTF 2.0 binary format - industry standard for 3D assets. GLB structure: (1) Header (magic "glTF", version 2, length), (2) JSON chunk (scene graph, materials, accessors), (3) BIN chunk (vertex/index buffers). Multi-material preservation: meshes with multiple materials (from Blender multi-material objects or b3dCreateMesh with multiple AddMeshSurface calls) export with separate primitives, each with material reference. Accessors define buffer layout (position:VEC3/FLOAT, normal:VEC3/FLOAT, UV:VEC2/FLOAT, color:VEC4/FLOAT or VEC4/UBYTE normalized, indices:SCALAR/UINT). Supports up to 4 UV sets (TEXCOORD_0 through TEXCOORD_3) matching textureSlots from b3dLoadMesh. Material export: baseColor (RGB+alpha), metallic/roughness PBR workflow, texture references (embedded or external). Coordinate system: glTF uses +Y up, +Z forward (matches BambooBasic). File size: binary format smaller than text OBJ. Round-trip compatible: b3dLoadMesh -> modify -> b3dSaveMeshGLB -> b3dLoadMesh preserves materials/UVs. Use for: game asset export, 3D model interchange, web 3D (three.js, Babylon.js support GLB). Doesn't export: animations (use b3dSaveAnimMesh), entity transforms (only mesh geometry), physics colliders. MeshName appears as mesh.name in GLB for identification in viewers/importers.