------------------------------------------------------------------------------
| 1261 | |
| 1262 | //------------------------------------------------------------------------------ |
| 1263 | bool vtkGLTFDocumentLoaderInternals::LoadTextureInfo( |
| 1264 | const nlohmann::json& root, vtkGLTFDocumentLoader::TextureInfo& textureInfo) |
| 1265 | { |
| 1266 | if (root.empty() || !root.is_object()) |
| 1267 | { |
| 1268 | vtkErrorWithObjectMacro(this->Self, "Invalid textureInfo object"); |
| 1269 | return false; |
| 1270 | } |
| 1271 | textureInfo.Index = -1; |
| 1272 | if (!vtkGLTFUtils::GetIntValue(root, "index", textureInfo.Index)) |
| 1273 | { |
| 1274 | vtkErrorWithObjectMacro(this->Self, "Invalid textureInfo.index value"); |
| 1275 | return false; |
| 1276 | } |
| 1277 | if (textureInfo.Index < 0) |
| 1278 | { |
| 1279 | vtkErrorWithObjectMacro(this->Self, "Invalid textureInfo.index value"); |
| 1280 | return false; |
| 1281 | } |
| 1282 | |
| 1283 | textureInfo.TexCoord = 0; |
| 1284 | vtkGLTFUtils::GetIntValue(root, "texCoord", textureInfo.TexCoord); |
| 1285 | |
| 1286 | auto extRootIt = root.find("extensions"); |
| 1287 | if (extRootIt != root.end()) |
| 1288 | { |
| 1289 | auto texTrRootIt = extRootIt.value().find("KHR_texture_transform"); |
| 1290 | if (texTrRootIt != extRootIt.value().end()) |
| 1291 | { |
| 1292 | vtkGLTFUtils::GetDoubleArray(texTrRootIt.value(), "scale", textureInfo.Scale); |
| 1293 | vtkGLTFUtils::GetDoubleArray(texTrRootIt.value(), "offset", textureInfo.Offset); |
| 1294 | vtkGLTFUtils::GetDoubleValue(texTrRootIt.value(), "rotation", textureInfo.Rotation); |
| 1295 | vtkGLTFUtils::GetIntValue(texTrRootIt.value(), "texCoord", textureInfo.TexCoord); |
| 1296 | } |
| 1297 | } |
| 1298 | |
| 1299 | return true; |
| 1300 | } |
| 1301 | |
| 1302 | //------------------------------------------------------------------------------ |
| 1303 | bool vtkGLTFDocumentLoaderInternals::LoadModelMetaData( |
no test coverage detected