C++ header-only library for simple serialization/deserialization of VRM inspired by fx-gltf and cgltf.
- Supports both VRM 0.x and 1.0 specification
- Full serialization and deserialization capability
- VRMC_springBone extension
- VRMC_node_constraint extension
- VRMC_materials_mtoon extension
- VRMC_materials_hdr_emissiveMultiplier extension
- nlohmann::json
- Any C/C++ libraries that can load JSON data from glTF binary
#define USE_VRMC_VRM_0_0 // Enable VRM 0.x
#include <VRMC/VRM.h> // Single header
std::filesystem::path f{"model.vrm"};
const auto doc = fx::gltf::LoadFromBinary(f);
const auto extensions = doc.extensionsAndExtras["extensions"];
VRMC_VRM_0_0::Vrm vrm;
VRMC_VRM_0_0::from_json(extensions["VRM"], vrm);
if (vrm.meta.allowedUserName == VRMC_VRM_0_0::Meta::AllowedUserName::OnlyAuthor) {
// ...
}
#define USE_VRMC_VRM_1_0 // Enable VRM 1.0
#include <VRMC/VRM.h> // Single header
std::filesystem::path f{"model.vrm"};
const auto doc = fx::gltf::LoadFromBinary(f);
const auto extensions = doc.extensionsAndExtras["extensions"];
VRMC_VRM_1_0::Vrm vrm;
VRMC_VRM_1_0::from_json(extensions["VRMC_vrm"], vrm);
if (vrm.meta.avatarPermission == VRMC_VRM_1_0::Meta::AvatarPermissionType::OnlyAuthor) {
// ...
}
So these tests above are both checking against avatar usage permissions but why there's a difference between them? It is because their JSON specifications are different between 0.x and 1.0. Check out vrm-specification for details if you're interested.
For the examples with cgltf, please refer to unit tests.
- Available to anybody free of charge, under the terms of MIT License (see LICENSE).
You need Cmake and Visual Studio with C++ environment installed. There is a CMakeLists.txt file which has been tested with Cmake on Windows. For instance in order to generate a Visual Studio 10 project, run cmake like this:
> cd tests
> mkdir build; cd build
> cmake -G "Visual Studio 10" ..