https://github.com/tcoppex/cgltf_vrm
👘 Single-file VRM 1.0 loader written in C99, extending cgltf.
https://github.com/tcoppex/cgltf_vrm
avatar c99 gltf2 vrm vrm-loader
Last synced: 7 months ago
JSON representation
👘 Single-file VRM 1.0 loader written in C99, extending cgltf.
- Host: GitHub
- URL: https://github.com/tcoppex/cgltf_vrm
- Owner: tcoppex
- License: mit
- Created: 2024-11-27T14:40:02.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-11-28T17:55:29.000Z (11 months ago)
- Last Synced: 2025-01-30T08:15:53.016Z (9 months ago)
- Topics: avatar, c99, gltf2, vrm, vrm-loader
- Language: C
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# :kimono: cgltf_vrm
**Single-file C99 VRM 1.0 loader companion to [cgltf](https://github.com/jkuhlmann/cgltf).**

_This library depends on cgltf.h to work (tested against v1.14)._
#### Extensions support
- [x] KHR_materials_unlit (*via cgltf*),
- [x] KHR_texture_transform (*via cgltf*),
- [x] KHR_materials_emissive_strength (*via cgltf*),
- [x] [VRMC_vrm](https://github.com/vrm-c/vrm-specification/tree/master/specification/VRMC_vrm-1.0),
- [x] [VRMC_springBone](https://github.com/vrm-c/vrm-specification/tree/master/specification/VRMC_springBone-1.0),
- [x] [VRMC_node_constraint](https://github.com/vrm-c/vrm-specification/tree/master/specification/VRMC_node_constraint-1.0),
- [x] [VRMC_materials_mtoon](https://github.com/vrm-c/vrm-specification/tree/master/specification/VRMC_materials_mtoon-1.0),
- [ ] [VRMC_VRM_animation](https://github.com/vrm-c/vrm-specification/tree/master/specification/VRMC_vrm_animation-1.0),
- [ ] [VRMC_springBone_extended_collider](https://github.com/vrm-c/vrm-specification/tree/master/specification/VRMC_springBone_extended_collider-1.0)#### Basic usage
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.##### Loading from an existing `cgltf_data` object
```c
#include#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;
}
```### See also
* [VRM specifications](https://github.com/vrm-c/vrm-specification)
* [Unity implementation](https://github.com/vrm-c/UniVRM)
* [ThreeJS implementation](https://github.com/pixiv/three-vrm/tree/dev)
* [Online VRM viewer](https://vrm-viewer.ownverse.world/)