| 200 | } |
| 201 | |
| 202 | vtkSmartPointer<vtkTransform2D> GetTextureTransform(const vtkGLTFDocumentLoader::Material& material) |
| 203 | { |
| 204 | bool hasTransform = false; |
| 205 | double offset[2] = { 0.0, 0.0 }; |
| 206 | double rotation = 0.0; |
| 207 | double scale[2] = { 1.0, 1.0 }; |
| 208 | |
| 209 | auto CheckAndSetTransform = [&](const vtkGLTFDocumentLoader::TextureInfo& texInfo) |
| 210 | { |
| 211 | if (texInfo.Index >= 0) |
| 212 | { |
| 213 | if (!hasTransform) |
| 214 | { |
| 215 | if (texInfo.Offset.size() == 2) |
| 216 | { |
| 217 | offset[0] = texInfo.Offset[0]; |
| 218 | offset[1] = texInfo.Offset[1]; |
| 219 | } |
| 220 | |
| 221 | if (texInfo.Scale.size() == 2) |
| 222 | { |
| 223 | scale[0] = texInfo.Scale[0]; |
| 224 | scale[1] = texInfo.Scale[1]; |
| 225 | } |
| 226 | |
| 227 | rotation = texInfo.Rotation; |
| 228 | hasTransform = true; |
| 229 | } |
| 230 | else |
| 231 | { |
| 232 | constexpr double tolerance = 1e-6; |
| 233 | |
| 234 | if (texInfo.Offset.size() == 2 && |
| 235 | (!vtkMathUtilities::FuzzyCompare(texInfo.Offset[0], offset[0], tolerance) || |
| 236 | !vtkMathUtilities::FuzzyCompare(texInfo.Offset[1], offset[1], tolerance))) |
| 237 | { |
| 238 | vtkWarningWithObjectMacro( |
| 239 | nullptr, "Found different texture transform offset value, this is not supported."); |
| 240 | } |
| 241 | |
| 242 | if (texInfo.Scale.size() == 2 && |
| 243 | (!vtkMathUtilities::FuzzyCompare(texInfo.Scale[0], scale[0], tolerance) || |
| 244 | !vtkMathUtilities::FuzzyCompare(texInfo.Scale[1], scale[1], tolerance))) |
| 245 | { |
| 246 | vtkWarningWithObjectMacro( |
| 247 | nullptr, "Found different texture transform scale value, this is not supported."); |
| 248 | } |
| 249 | |
| 250 | if (!vtkMathUtilities::FuzzyCompare(texInfo.Rotation, rotation, tolerance)) |
| 251 | { |
| 252 | vtkWarningWithObjectMacro( |
| 253 | nullptr, "Found different texture transform rotation value, this is not supported."); |
| 254 | } |
| 255 | } |
| 256 | } |
| 257 | }; |
| 258 | |
| 259 | CheckAndSetTransform(material.PbrMetallicRoughness.BaseColorTexture); |
no test coverage detected