Parse extensions property of Image.

This commit is contained in:
Syoyo Fujita 2018-09-02 15:36:17 +09:00
parent 9ec7109089
commit 3e53feb046
2 changed files with 9 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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) {