From a9b490fc7a2c49a304a4962dfc0524c5497fa8e4 Mon Sep 17 00:00:00 2001 From: Rob Taglang Date: Sun, 22 Apr 2018 18:45:59 -0400 Subject: [PATCH 1/2] Don't make textures if there is no image backing it --- src/COLLADA2GLTFWriter.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/COLLADA2GLTFWriter.cpp b/src/COLLADA2GLTFWriter.cpp index 2dc16916b..44ec75392 100755 --- a/src/COLLADA2GLTFWriter.cpp +++ b/src/COLLADA2GLTFWriter.cpp @@ -883,10 +883,15 @@ void packColladaColor(COLLADAFW::Color color, float* packArray) { } GLTF::Texture* COLLADA2GLTF::Writer::fromColladaTexture(const COLLADAFW::EffectCommon* effectCommon, COLLADAFW::SamplerID samplerId) { - GLTF::Texture* texture = new GLTF::Texture(); const COLLADAFW::SamplerPointerArray& samplers = effectCommon->getSamplerPointerArray(); COLLADAFW::Sampler* colladaSampler = (COLLADAFW::Sampler*)samplers[samplerId]; - GLTF::Image* image = _images[colladaSampler->getSourceImage()]; + std::map::iterator findImage = _images.find(colladaSampler->getSourceImage()); + if (findImage == _images.end()) { + return NULL; + } + GLTF::Texture* texture = new GLTF::Texture(); + GLTF::Image* image = findImage->second; + texture->source = image; texture->sampler = _asset->globalSampler; return texture; From fccd8a506797b1c28767e69ecc3e24dbe3e2b98a Mon Sep 17 00:00:00 2001 From: Rob Taglang Date: Sun, 22 Apr 2018 19:15:42 -0400 Subject: [PATCH 2/2] Updated CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index c43ff9031..a81a83fb3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Change Log ##### Fixes :wrench: * Upgrade to Draco 1.2.5 [#179](https://github.com/KhronosGroup/COLLADA2GLTF/pull/179) * Fix issue with exporting normal maps [#182](https://github.com/KhronosGroup/COLLADA2GLTF/pull/182) +* Fix issue with COLLADA textures with no backing image [#183](https://github.com/KhronosGroup/COLLADA2GLTF/pull/183) ### v2.1.1 - 2018-04-04