mirror of
https://github.com/syoyo/tinygltf.git
synced 2026-06-29 18:48:50 +00:00
Compare commits
23 Commits
tinyktx
...
textureinf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f68d5e1f2a | ||
|
|
1c84fc22a5 | ||
|
|
150f243b1b | ||
|
|
0ee273fdfa | ||
|
|
046400b17f | ||
|
|
89fd93f815 | ||
|
|
e940337796 | ||
|
|
1b5f476d95 | ||
|
|
52936a00e0 | ||
|
|
f3ef880029 | ||
|
|
1af7c1d784 | ||
|
|
c0b79afecc | ||
|
|
c49461b7c2 | ||
|
|
051f4be2f1 | ||
|
|
4557b6aa22 | ||
|
|
b2d7d88dbc | ||
|
|
b7ca7c9381 | ||
|
|
0ffedcbe79 | ||
|
|
80faac5238 | ||
|
|
2a9d9deb67 | ||
|
|
8a98d98cd9 | ||
|
|
689edcbef6 | ||
|
|
820ede87db |
@@ -7,6 +7,7 @@ If you are looking for old, C++03 version, please use `devel-picojson` branch.
|
|||||||
|
|
||||||
## Status
|
## Status
|
||||||
|
|
||||||
|
- v2.3.0 Modified Material representation according to glTF 2.0 schema(and introduced TextureInfo class)
|
||||||
- v2.2.0 release(Support loading 16bit PNG. Sparse accessor support)
|
- v2.2.0 release(Support loading 16bit PNG. Sparse accessor support)
|
||||||
- v2.1.0 release(Draco support)
|
- v2.1.0 release(Draco support)
|
||||||
- v2.0.0 release(22 Aug, 2018)!
|
- v2.0.0 release(22 Aug, 2018)!
|
||||||
@@ -54,6 +55,12 @@ If you are looking for old, C++03 version, please use `devel-picojson` branch.
|
|||||||
* Extensions
|
* Extensions
|
||||||
* [x] Draco mesh decoding
|
* [x] Draco mesh decoding
|
||||||
|
|
||||||
|
## Note on extension property
|
||||||
|
|
||||||
|
In extension(`ExtensionMap`), JSON number value is parsed as int or float(number) and stored as `tinygltf::Value` object. If you want a floating point value from `tinygltf::Value`, use `GetNumberAsDouble()` method.
|
||||||
|
|
||||||
|
`IsNumber()` returns true if the underlying value is an int value or a floating point value.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
* [glview](examples/glview) : Simple glTF geometry viewer.
|
* [glview](examples/glview) : Simple glTF geometry viewer.
|
||||||
@@ -76,7 +83,7 @@ If you are looking for old, C++03 version, please use `devel-picojson` branch.
|
|||||||
* [x] Load Draco compressed mesh
|
* [x] Load Draco compressed mesh
|
||||||
* [ ] Save Draco compressed mesh
|
* [ ] Save Draco compressed mesh
|
||||||
* [ ] Open3DGC?
|
* [ ] Open3DGC?
|
||||||
* [ ] Support `extensions` and `extras` property
|
* [x] Support `extensions` and `extras` property
|
||||||
* [ ] HDR image?
|
* [ ] HDR image?
|
||||||
* [ ] OpenEXR extension through TinyEXR.
|
* [ ] OpenEXR extension through TinyEXR.
|
||||||
* [ ] 16bit PNG support in Serialization
|
* [ ] 16bit PNG support in Serialization
|
||||||
|
|||||||
@@ -175,7 +175,10 @@ static std::string PrintIntArray(const std::vector<int> &arr) {
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "[ ";
|
ss << "[ ";
|
||||||
for (size_t i = 0; i < arr.size(); i++) {
|
for (size_t i = 0; i < arr.size(); i++) {
|
||||||
ss << arr[i] << ((i != arr.size() - 1) ? ", " : "");
|
ss << arr[i];
|
||||||
|
if (i != arr.size() - 1) {
|
||||||
|
ss << ", ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ss << " ]";
|
ss << " ]";
|
||||||
|
|
||||||
@@ -190,7 +193,10 @@ static std::string PrintFloatArray(const std::vector<double> &arr) {
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "[ ";
|
ss << "[ ";
|
||||||
for (size_t i = 0; i < arr.size(); i++) {
|
for (size_t i = 0; i < arr.size(); i++) {
|
||||||
ss << arr[i] << ((i != arr.size() - 1) ? ", " : "");
|
ss << arr[i];
|
||||||
|
if (i != arr.size() - 1) {
|
||||||
|
ss << ", ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ss << " ]";
|
ss << " ]";
|
||||||
|
|
||||||
@@ -243,35 +249,36 @@ static std::string PrintValue(const std::string &name,
|
|||||||
if (tag) {
|
if (tag) {
|
||||||
ss << Indent(indent) << name << " : " << value.Get<std::string>();
|
ss << Indent(indent) << name << " : " << value.Get<std::string>();
|
||||||
} else {
|
} else {
|
||||||
ss << " " << value.Get<std::string>() << " ";
|
ss << Indent(indent) << value.Get<std::string>() << " ";
|
||||||
}
|
}
|
||||||
} else if (value.IsBool()) {
|
} else if (value.IsBool()) {
|
||||||
if (tag) {
|
if (tag) {
|
||||||
ss << Indent(indent) << name << " : " << value.Get<bool>();
|
ss << Indent(indent) << name << " : " << value.Get<bool>();
|
||||||
} else {
|
} else {
|
||||||
ss << " " << value.Get<bool>() << " ";
|
ss << Indent(indent) << value.Get<bool>() << " ";
|
||||||
}
|
}
|
||||||
} else if (value.IsNumber()) {
|
} else if (value.IsNumber()) {
|
||||||
if (tag) {
|
if (tag) {
|
||||||
ss << Indent(indent) << name << " : " << value.Get<double>();
|
ss << Indent(indent) << name << " : " << value.Get<double>();
|
||||||
} else {
|
} else {
|
||||||
ss << " " << value.Get<double>() << " ";
|
ss << Indent(indent) << value.Get<double>() << " ";
|
||||||
}
|
}
|
||||||
} else if (value.IsInt()) {
|
} else if (value.IsInt()) {
|
||||||
if (tag) {
|
if (tag) {
|
||||||
ss << Indent(indent) << name << " : " << value.Get<int>();
|
ss << Indent(indent) << name << " : " << value.Get<int>();
|
||||||
} else {
|
} else {
|
||||||
ss << " " << value.Get<int>() << " ";
|
ss << Indent(indent) << value.Get<int>() << " ";
|
||||||
}
|
}
|
||||||
} else if (value.IsArray()) {
|
} else if (value.IsArray()) {
|
||||||
ss << Indent(indent) << name << " [ ";
|
// TODO(syoyo): Better pretty printing of array item
|
||||||
|
ss << Indent(indent) << name << " [ \n";
|
||||||
for (size_t i = 0; i < value.Size(); i++) {
|
for (size_t i = 0; i < value.Size(); i++) {
|
||||||
ss << PrintValue("", value.Get(int(i)), indent + 1, /* tag */ false);
|
ss << PrintValue("", value.Get(int(i)), indent + 1, /* tag */ false);
|
||||||
if (i != (value.ArrayLen() - 1)) {
|
if (i != (value.ArrayLen() - 1)) {
|
||||||
ss << ", ";
|
ss << ", \n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ss << Indent(indent) << "] ";
|
ss << "\n" << Indent(indent) << "] ";
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo { binary }
|
// @todo { binary }
|
||||||
@@ -339,6 +346,54 @@ static void DumpExtensions(const tinygltf::ExtensionMap &extension,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void DumpTextureInfo(const tinygltf::TextureInfo &texinfo,
|
||||||
|
const int indent) {
|
||||||
|
std::cout << Indent(indent) << "index : " << texinfo.index << "\n";
|
||||||
|
std::cout << Indent(indent) << "texCoord : TEXCOORD_" << texinfo.texCoord
|
||||||
|
<< "\n";
|
||||||
|
DumpExtensions(texinfo.extensions, indent + 1);
|
||||||
|
std::cout << PrintValue("extras", texinfo.extras, indent + 1) << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DumpNormalTextureInfo(const tinygltf::NormalTextureInfo &texinfo,
|
||||||
|
const int indent) {
|
||||||
|
std::cout << Indent(indent) << "index : " << texinfo.index << "\n";
|
||||||
|
std::cout << Indent(indent) << "texCoord : TEXCOORD_" << texinfo.texCoord
|
||||||
|
<< "\n";
|
||||||
|
std::cout << Indent(indent) << "scale : " << texinfo.scale << "\n";
|
||||||
|
DumpExtensions(texinfo.extensions, indent + 1);
|
||||||
|
std::cout << PrintValue("extras", texinfo.extras, indent + 1) << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DumpOcclusionTextureInfo(
|
||||||
|
const tinygltf::OcclusionTextureInfo &texinfo, const int indent) {
|
||||||
|
std::cout << Indent(indent) << "index : " << texinfo.index << "\n";
|
||||||
|
std::cout << Indent(indent) << "texCoord : TEXCOORD_" << texinfo.texCoord
|
||||||
|
<< "\n";
|
||||||
|
std::cout << Indent(indent) << "strength : " << texinfo.strength << "\n";
|
||||||
|
DumpExtensions(texinfo.extensions, indent + 1);
|
||||||
|
std::cout << PrintValue("extras", texinfo.extras, indent + 1) << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DumpPbrMetallicRoughness(const tinygltf::PbrMetallicRoughness &pbr,
|
||||||
|
const int indent) {
|
||||||
|
std::cout << Indent(indent)
|
||||||
|
<< "baseColorFactor : " << PrintFloatArray(pbr.baseColorFactor)
|
||||||
|
<< "\n";
|
||||||
|
std::cout << Indent(indent) << "baseColorTexture :\n";
|
||||||
|
DumpTextureInfo(pbr.baseColorTexture, indent + 1);
|
||||||
|
|
||||||
|
std::cout << Indent(indent) << "metallicFactor : " << pbr.metallicFactor
|
||||||
|
<< "\n";
|
||||||
|
std::cout << Indent(indent) << "roughnessFactor : " << pbr.roughnessFactor
|
||||||
|
<< "\n";
|
||||||
|
|
||||||
|
std::cout << Indent(indent) << "metallicRoughnessTexture :\n";
|
||||||
|
DumpTextureInfo(pbr.metallicRoughnessTexture, indent + 1);
|
||||||
|
DumpExtensions(pbr.extensions, indent + 1);
|
||||||
|
std::cout << PrintValue("extras", pbr.extras, indent + 1) << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
static void Dump(const tinygltf::Model &model) {
|
static void Dump(const tinygltf::Model &model) {
|
||||||
std::cout << "=== Dump glTF ===" << std::endl;
|
std::cout << "=== Dump glTF ===" << std::endl;
|
||||||
std::cout << "asset.copyright : " << model.asset.copyright
|
std::cout << "asset.copyright : " << model.asset.copyright
|
||||||
@@ -509,16 +564,44 @@ static void Dump(const tinygltf::Model &model) {
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
for (size_t i = 0; i < model.materials.size(); i++) {
|
for (size_t i = 0; i < model.materials.size(); i++) {
|
||||||
const tinygltf::Material &material = model.materials[i];
|
const tinygltf::Material &material = model.materials[i];
|
||||||
std::cout << Indent(1) << "name : " << material.name << std::endl;
|
std::cout << Indent(1) << "name : " << material.name
|
||||||
std::cout << Indent(1) << "values(items=" << material.values.size() << ")"
|
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
|
std::cout << Indent(1) << "alphaMode : " << material.alphaMode
|
||||||
|
<< std::endl;
|
||||||
|
std::cout << Indent(1)
|
||||||
|
<< "alphaCutoff : " << material.alphaCutoff
|
||||||
|
<< std::endl;
|
||||||
|
std::cout << Indent(1) << "doubleSided : "
|
||||||
|
<< (material.doubleSided ? "true" : "false") << std::endl;
|
||||||
|
std::cout << Indent(1) << "emissiveFactor : "
|
||||||
|
<< PrintFloatArray(material.emissiveFactor) << std::endl;
|
||||||
|
|
||||||
|
std::cout << Indent(1) << "pbrMetallicRoughness :\n";
|
||||||
|
DumpPbrMetallicRoughness(material.pbrMetallicRoughness, 2);
|
||||||
|
|
||||||
|
std::cout << Indent(1) << "normalTexture :\n";
|
||||||
|
DumpNormalTextureInfo(material.normalTexture, 2);
|
||||||
|
|
||||||
|
std::cout << Indent(1) << "occlusionTexture :\n";
|
||||||
|
DumpOcclusionTextureInfo(material.occlusionTexture, 2);
|
||||||
|
|
||||||
|
std::cout << Indent(1) << "emissiveTexture :\n";
|
||||||
|
DumpTextureInfo(material.emissiveTexture, 2);
|
||||||
|
|
||||||
|
std::cout << Indent(1) << "---- legacy material parameter ----\n";
|
||||||
|
std::cout << Indent(1) << "values(items=" << material.values.size() << ")"
|
||||||
|
<< std::endl;
|
||||||
tinygltf::ParameterMap::const_iterator p(material.values.begin());
|
tinygltf::ParameterMap::const_iterator p(material.values.begin());
|
||||||
tinygltf::ParameterMap::const_iterator pEnd(material.values.end());
|
tinygltf::ParameterMap::const_iterator pEnd(material.values.end());
|
||||||
for (; p != pEnd; p++) {
|
for (; p != pEnd; p++) {
|
||||||
std::cout << Indent(2) << p->first << ": "
|
std::cout << Indent(2) << p->first << ": "
|
||||||
<< PrintParameterValue(p->second) << std::endl;
|
<< PrintParameterValue(p->second) << std::endl;
|
||||||
}
|
}
|
||||||
|
std::cout << Indent(1) << "-------------------------------------\n";
|
||||||
|
|
||||||
|
DumpExtensions(material.extensions, 1);
|
||||||
|
std::cout << PrintValue("extras", material.extras, 2) << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
224
models/Cube-texture-ext/Cube-textransform.gltf
Normal file
224
models/Cube-texture-ext/Cube-textransform.gltf
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
{
|
||||||
|
"accessors": [
|
||||||
|
{
|
||||||
|
"bufferView": 0,
|
||||||
|
"byteOffset": 0,
|
||||||
|
"componentType": 5123,
|
||||||
|
"count": 36,
|
||||||
|
"max": [
|
||||||
|
35
|
||||||
|
],
|
||||||
|
"min": [
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"type": "SCALAR"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView": 1,
|
||||||
|
"byteOffset": 0,
|
||||||
|
"componentType": 5126,
|
||||||
|
"count": 36,
|
||||||
|
"max": [
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1.000001
|
||||||
|
],
|
||||||
|
"min": [
|
||||||
|
-1,
|
||||||
|
-1,
|
||||||
|
-1
|
||||||
|
],
|
||||||
|
"type": "VEC3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView": 2,
|
||||||
|
"byteOffset": 0,
|
||||||
|
"componentType": 5126,
|
||||||
|
"count": 36,
|
||||||
|
"max": [
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"min": [
|
||||||
|
-1,
|
||||||
|
-1,
|
||||||
|
-1
|
||||||
|
],
|
||||||
|
"type": "VEC3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView": 3,
|
||||||
|
"byteOffset": 0,
|
||||||
|
"componentType": 5126,
|
||||||
|
"count": 36,
|
||||||
|
"max": [
|
||||||
|
1,
|
||||||
|
-0,
|
||||||
|
-0,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"min": [
|
||||||
|
0,
|
||||||
|
-0,
|
||||||
|
-1,
|
||||||
|
-1
|
||||||
|
],
|
||||||
|
"type": "VEC4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView": 4,
|
||||||
|
"byteOffset": 0,
|
||||||
|
"componentType": 5126,
|
||||||
|
"count": 36,
|
||||||
|
"max": [
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"min": [
|
||||||
|
-1,
|
||||||
|
-1
|
||||||
|
],
|
||||||
|
"type": "VEC2"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"asset": {
|
||||||
|
"generator": "VKTS glTF 2.0 exporter",
|
||||||
|
"version": "2.0"
|
||||||
|
},
|
||||||
|
"bufferViews": [
|
||||||
|
{
|
||||||
|
"buffer": 0,
|
||||||
|
"byteLength": 72,
|
||||||
|
"byteOffset": 0,
|
||||||
|
"target": 34963
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buffer": 0,
|
||||||
|
"byteLength": 432,
|
||||||
|
"byteOffset": 72,
|
||||||
|
"target": 34962
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buffer": 0,
|
||||||
|
"byteLength": 432,
|
||||||
|
"byteOffset": 504,
|
||||||
|
"target": 34962
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buffer": 0,
|
||||||
|
"byteLength": 576,
|
||||||
|
"byteOffset": 936,
|
||||||
|
"target": 34962
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buffer": 0,
|
||||||
|
"byteLength": 288,
|
||||||
|
"byteOffset": 1512,
|
||||||
|
"target": 34962
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"buffers": [
|
||||||
|
{
|
||||||
|
"byteLength": 1800,
|
||||||
|
"uri": "Cube.bin"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"images": [
|
||||||
|
{
|
||||||
|
"0comment": "Use Cube_MetallicRoughness.png to reduce scene filesize",
|
||||||
|
"uri": "Cube_MetallicRoughness.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"uri": "Cube_MetallicRoughness.png"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"materials": [
|
||||||
|
{
|
||||||
|
"emissiveTexture": {
|
||||||
|
"index": 0,
|
||||||
|
"extensions": {
|
||||||
|
"KHR_texture_transform": {
|
||||||
|
"offset": [
|
||||||
|
0,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"scale": [
|
||||||
|
1,
|
||||||
|
-1
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Cube",
|
||||||
|
"pbrMetallicRoughness": {
|
||||||
|
"baseColorTexture": {
|
||||||
|
"index": 0
|
||||||
|
},
|
||||||
|
"metallicRoughnessTexture": {
|
||||||
|
"index": 1,
|
||||||
|
"extensions": {
|
||||||
|
"KHR_texture_transform": {
|
||||||
|
"offset": [
|
||||||
|
0,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"rotation": 1.57079632679,
|
||||||
|
"scale": [
|
||||||
|
0.5,
|
||||||
|
0.5
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"meshes": [
|
||||||
|
{
|
||||||
|
"name": "Cube",
|
||||||
|
"primitives": [
|
||||||
|
{
|
||||||
|
"attributes": {
|
||||||
|
"NORMAL": 2,
|
||||||
|
"POSITION": 1,
|
||||||
|
"TANGENT": 3,
|
||||||
|
"TEXCOORD_0": 4
|
||||||
|
},
|
||||||
|
"indices": 0,
|
||||||
|
"material": 0,
|
||||||
|
"mode": 4
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nodes": [
|
||||||
|
{
|
||||||
|
"mesh": 0,
|
||||||
|
"name": "Cube"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"samplers": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"scene": 0,
|
||||||
|
"scenes": [
|
||||||
|
{
|
||||||
|
"nodes": [
|
||||||
|
0
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"textures": [
|
||||||
|
{
|
||||||
|
"sampler": 0,
|
||||||
|
"source": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sampler": 0,
|
||||||
|
"source": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
BIN
models/Cube-texture-ext/Cube.bin
Normal file
BIN
models/Cube-texture-ext/Cube.bin
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
BIN
models/Cube-texture-ext/Cube_MetallicRoughness.png
Normal file
BIN
models/Cube-texture-ext/Cube_MetallicRoughness.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 319 B |
6
models/Cube-texture-ext/README.md
Normal file
6
models/Cube-texture-ext/README.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
Added KHR_texture_transform property to Cube scene.
|
||||||
|
|
||||||
|
License: Donated by Norbert Nopper for glTF testing.
|
||||||
|
|
||||||
|
https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/Cube
|
||||||
|
|
||||||
@@ -279,3 +279,39 @@ TEST_CASE("parse-integer-array", "[bounds-checking]") {
|
|||||||
REQUIRE_THAT(err, Catch::Contains("not an integer type"));
|
REQUIRE_THAT(err, Catch::Contains("not an integer type"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("pbr-khr-texture-transform", "[material]") {
|
||||||
|
tinygltf::Model model;
|
||||||
|
tinygltf::TinyGLTF ctx;
|
||||||
|
std::string err;
|
||||||
|
std::string warn;
|
||||||
|
|
||||||
|
// Loading is expected to fail, but not crash.
|
||||||
|
bool ret = ctx.LoadASCIIFromFile(
|
||||||
|
&model, &err, &warn,
|
||||||
|
"../models/Cube-texture-ext/Cube-textransform.gltf");
|
||||||
|
REQUIRE(ret == true);
|
||||||
|
|
||||||
|
REQUIRE(model.materials.size() == 2);
|
||||||
|
REQUIRE(model.materials[0].emissiveTexture.extensions.count("KHR_texture_transform") == 1);
|
||||||
|
REQUIRE(model.materials[0].emissiveTexture.extensions["KHR_texture_transform"].IsObject());
|
||||||
|
|
||||||
|
tinygltf::Value::Object &texform = model.materials[0].emissiveTexture.extensions["KHR_texture_transform"].Get<tinygltf::Value::Object>();
|
||||||
|
|
||||||
|
REQUIRE(texform.count("scale"));
|
||||||
|
|
||||||
|
REQUIRE(texform["scale"].IsArray());
|
||||||
|
|
||||||
|
// Note: It looks json.hpp parse integer JSON number as integer, not floating point.
|
||||||
|
// IsNumber return true either value is int or floating point.
|
||||||
|
REQUIRE(texform["scale"].Get(0).IsNumber());
|
||||||
|
REQUIRE(texform["scale"].Get(1).IsNumber());
|
||||||
|
|
||||||
|
double scale[2];
|
||||||
|
scale[0] = texform["scale"].Get(0).GetNumberAsDouble();
|
||||||
|
scale[1] = texform["scale"].Get(1).GetNumberAsDouble();
|
||||||
|
|
||||||
|
REQUIRE(scale[0] == Approx(1.0));
|
||||||
|
REQUIRE(scale[1] == Approx(-1.0));
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
1058
tiny_gltf.h
1058
tiny_gltf.h
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user