Single-file C99 VRM 1.0 loader companion to cgltf.
This library depends on cgltf.h to work (tested against v1.14).
- KHR_materials_unlit (via cgltf),
- KHR_texture_transform (via cgltf),
- KHR_materials_emissive_strength (via cgltf),
- VRMC_vrm,
- VRMC_springBone,
- VRMC_node_constraint,
- VRMC_materials_mtoon,
- VRMC_VRM_animation,
- VRMC_springBone_extended_collider
The main concern is to include the cgltf_vrm
implementation in the same file and after
the cgltf
implementation as it depends on some of its static functions to work.
#include <stdlib.h>
#define CGLTF_IMPLEMENTATION
#include "cgltf.h"
#include "cgltf_vrm.h"
int main(int argc, char **argv[])
{
cgltf_options options{};
cgltf_result result{};
cgltf_data* gltf = NULL;
cgltf_vrm_data vrm;
result = cgltf_parse_file(&options, "avatar.vrm", &gltf);
if (result != cgltf_result_success)
{
return EXIT_FAILURE;
}
result = cgltf_vrm_parse_cgltf_data(&options, gltf, &vrm);
if (result != cgltf_result_success)
{
cgltf_free(gltf);
return EXIT_FAILURE;
}
/* process data here */
cgltf_vrm_free(&vrm);
cgltf_free(gltf);
return EXIT_SUCCESS;
}