From 3e53feb04642aab9a58fce32ef8e2417f8ed608f Mon Sep 17 00:00:00 2001 From: Syoyo Fujita Date: Sun, 2 Sep 2018 15:36:17 +0900 Subject: [PATCH] Parse `extensions` property of Image. --- loader_example.cc | 5 +++++ tiny_gltf.h | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/loader_example.cc b/loader_example.cc index 8ae20bc..7f8a426 100644 --- a/loader_example.cc +++ b/loader_example.cc @@ -1,3 +1,6 @@ +// +// TODO(syoyo): Print extensions and extras for each glTF object. +// #define TINYGLTF_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_WRITE_IMPLEMENTATION @@ -514,6 +517,7 @@ static void Dump(const tinygltf::Model &model) { std::cout << Indent(2) << "width : " << image.width << std::endl; std::cout << Indent(2) << "height : " << image.height << std::endl; std::cout << Indent(2) << "component : " << image.component << std::endl; + DumpExtensions(image.extensions, 1); } } @@ -525,6 +529,7 @@ static void Dump(const tinygltf::Model &model) { << std::endl; std::cout << Indent(1) << "source : " << texture.source << std::endl; + DumpExtensions(texture.extensions, 1); } } diff --git a/tiny_gltf.h b/tiny_gltf.h index 9b6494d..6f2855c 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -456,6 +456,7 @@ struct Image { // "image/bmp", "image/gif"] std::string uri; // (required if no mimeType) Value extras; + ExtensionMap extensions; Image() { bufferView = -1; } }; @@ -2126,6 +2127,7 @@ static bool ParseImage(Image *image, std::string *err, std::string *warn, } ParseStringProperty(&image->name, err, o, "name", false); + ParseExtensionsProperty(&image->extensions, err, o); if (hasBufferView) { double bufferView = -1; @@ -4014,6 +4016,8 @@ static void SerializeGltfImage(Image &image, json &o) { if (image.extras.Type() != NULL_TYPE) { SerializeValue("extras", image.extras, o); } + + SerializeExtensionMap(image.extensions, o); } static void SerializeGltfMaterial(Material &material, json &o) {