| @@ -45,75 +45,80 @@ scriptable::ScriptableMaterial& scriptable::ScriptableMaterial::operator=(const · 44 unmodified lines |
| 45 | 45 | defaultFallthrough = material.defaultFallthrough; |
| 46 | 46 | propertyFallthroughs = material.propertyFallthroughs; |
| 47 | 47 | |
| 48 | + key = material.key; |
| 49 | + |
| 48 | 50 | return *this; |
| 49 | 51 | } |
| 50 | 52 | |
| 51 | | −scriptable::ScriptableMaterial::ScriptableMaterial(const graphics::MaterialPointer& material) : |
| 52 | | − name(material->getName().c_str()), |
| 53 | | − model(material->getModel().c_str()), |
| 54 | | − opacity(material->getOpacity()), |
| 55 | | − roughness(material->getRoughness()), |
| 56 | | − metallic(material->getMetallic()), |
| 57 | | − scattering(material->getScattering()), |
| 58 | | − unlit(material->isUnlit()), |
| 59 | | − emissive(material->getEmissive()), |
| 60 | | − albedo(material->getAlbedo()), |
| 61 | | − defaultFallthrough(material->getDefaultFallthrough()), |
| 62 | | − propertyFallthroughs(material->getPropertyFallthroughs()) |
| 63 | | −{ |
| 64 | | − auto map = material->getTextureMap(graphics::Material::MapChannel::EMISSIVE_MAP); |
| 65 | | − if (map && map->getTextureSource()) { |
| 66 | | − emissiveMap = map->getTextureSource()->getUrl().toString(); |
| 67 | | − } |
| 53 | +scriptable::ScriptableMaterial::ScriptableMaterial(const graphics::MaterialPointer& material) { |
| 54 | + if (material) { |
| 55 | + name = material->getName().c_str(); |
| 56 | + model = material->getModel().c_str(); |
| 57 | + opacity = material->getOpacity(); |
| 58 | + roughness = material->getRoughness(); |
| 59 | + metallic = material->getMetallic(); |
| 60 | + scattering = material->getScattering(); |
| 61 | + unlit = material->isUnlit(); |
| 62 | + emissive = material->getEmissive(); |
| 63 | + albedo = material->getAlbedo(); |
| 64 | + defaultFallthrough = material->getDefaultFallthrough(); |
| 65 | + propertyFallthroughs = material->getPropertyFallthroughs(); |
| 66 | + key = material->getKey(); |
| 67 | + |
| 68 | + auto map = material->getTextureMap(graphics::Material::MapChannel::EMISSIVE_MAP); |
| 69 | + if (map && map->getTextureSource()) { |
| 70 | + emissiveMap = map->getTextureSource()->getUrl().toString(); |
| 71 | + } |
| 68 | 72 | |
| 69 | | − map = material->getTextureMap(graphics::Material::MapChannel::ALBEDO_MAP); |
| 70 | | − if (map && map->getTextureSource()) { |
| 71 | | − albedoMap = map->getTextureSource()->getUrl().toString(); |
| 72 | | − if (map->useAlphaChannel()) { |
| 73 | | − opacityMap = albedoMap; |
| 73 | + map = material->getTextureMap(graphics::Material::MapChannel::ALBEDO_MAP); |
| 74 | + if (map && map->getTextureSource()) { |
| 75 | + albedoMap = map->getTextureSource()->getUrl().toString(); |
| 76 | + if (map->useAlphaChannel()) { |
| 77 | + opacityMap = albedoMap; |
| 78 | + } |
| 74 | 79 | } |
| 75 | | − } |
| 76 | 80 | |
| 77 | | − map = material->getTextureMap(graphics::Material::MapChannel::METALLIC_MAP); |
| 78 | | − if (map && map->getTextureSource()) { |
| 79 | | − if (map->getTextureSource()->getType() == image::TextureUsage::Type::METALLIC_TEXTURE) { |
| 80 | | − metallicMap = map->getTextureSource()->getUrl().toString(); |
| 81 | | − } else if (map->getTextureSource()->getType() == image::TextureUsage::Type::SPECULAR_TEXTURE) { |
| 82 | | − specularMap = map->getTextureSource()->getUrl().toString(); |
| 81 | + map = material->getTextureMap(graphics::Material::MapChannel::METALLIC_MAP); |
| 82 | + if (map && map->getTextureSource()) { |
| 83 | + if (map->getTextureSource()->getType() == image::TextureUsage::Type::METALLIC_TEXTURE) { |
| 84 | + metallicMap = map->getTextureSource()->getUrl().toString(); |
| 85 | + } else if (map->getTextureSource()->getType() == image::TextureUsage::Type::SPECULAR_TEXTURE) { |
| 86 | + specularMap = map->getTextureSource()->getUrl().toString(); |
| 87 | + } |
| 83 | 88 | } |
| 84 | | − } |
| 85 | 89 | |
| 86 | | − map = material->getTextureMap(graphics::Material::MapChannel::ROUGHNESS_MAP); |
| 87 | | − if (map && map->getTextureSource()) { |
| 88 | | − if (map->getTextureSource()->getType() == image::TextureUsage::Type::ROUGHNESS_TEXTURE) { |
| 89 | | − roughnessMap = map->getTextureSource()->getUrl().toString(); |
| 90 | | − } else if (map->getTextureSource()->getType() == image::TextureUsage::Type::GLOSS_TEXTURE) { |
| 91 | | − glossMap = map->getTextureSource()->getUrl().toString(); |
| 90 | + map = material->getTextureMap(graphics::Material::MapChannel::ROUGHNESS_MAP); |
| 91 | + if (map && map->getTextureSource()) { |
| 92 | + if (map->getTextureSource()->getType() == image::TextureUsage::Type::ROUGHNESS_TEXTURE) { |
| 93 | + roughnessMap = map->getTextureSource()->getUrl().toString(); |
| 94 | + } else if (map->getTextureSource()->getType() == image::TextureUsage::Type::GLOSS_TEXTURE) { |
| 95 | + glossMap = map->getTextureSource()->getUrl().toString(); |
| 96 | + } |
| 92 | 97 | } |
| 93 | | − } |
| 94 | 98 | |
| 95 | | − map = material->getTextureMap(graphics::Material::MapChannel::NORMAL_MAP); |
| 96 | | − if (map && map->getTextureSource()) { |
| 97 | | − if (map->getTextureSource()->getType() == image::TextureUsage::Type::NORMAL_TEXTURE) { |
| 98 | | − normalMap = map->getTextureSource()->getUrl().toString(); |
| 99 | | − } else if (map->getTextureSource()->getType() == image::TextureUsage::Type::BUMP_TEXTURE) { |
| 100 | | − bumpMap = map->getTextureSource()->getUrl().toString(); |
| 99 | + map = material->getTextureMap(graphics::Material::MapChannel::NORMAL_MAP); |
| 100 | + if (map && map->getTextureSource()) { |
| 101 | + if (map->getTextureSource()->getType() == image::TextureUsage::Type::NORMAL_TEXTURE) { |
| 102 | + normalMap = map->getTextureSource()->getUrl().toString(); |
| 103 | + } else if (map->getTextureSource()->getType() == image::TextureUsage::Type::BUMP_TEXTURE) { |
| 104 | + bumpMap = map->getTextureSource()->getUrl().toString(); |
| 105 | + } |
| 101 | 106 | } |
| 102 | | − } |
| 103 | 107 | |
| 104 | | − map = material->getTextureMap(graphics::Material::MapChannel::OCCLUSION_MAP); |
| 105 | | − if (map && map->getTextureSource()) { |
| 106 | | − occlusionMap = map->getTextureSource()->getUrl().toString(); |
| 107 | | − } |
| 108 | + map = material->getTextureMap(graphics::Material::MapChannel::OCCLUSION_MAP); |
| 109 | + if (map && map->getTextureSource()) { |
| 110 | + occlusionMap = map->getTextureSource()->getUrl().toString(); |
| 111 | + } |
| 108 | 112 | |
| 109 | | − map = material->getTextureMap(graphics::Material::MapChannel::LIGHTMAP_MAP); |
| 110 | | − if (map && map->getTextureSource()) { |
| 111 | | − lightmapMap = map->getTextureSource()->getUrl().toString(); |
| 112 | | − } |
| 113 | + map = material->getTextureMap(graphics::Material::MapChannel::LIGHTMAP_MAP); |
| 114 | + if (map && map->getTextureSource()) { |
| 115 | + lightmapMap = map->getTextureSource()->getUrl().toString(); |
| 116 | + } |
| 113 | 117 | |
| 114 | | − map = material->getTextureMap(graphics::Material::MapChannel::SCATTERING_MAP); |
| 115 | | − if (map && map->getTextureSource()) { |
| 116 | | − scatteringMap = map->getTextureSource()->getUrl().toString(); |
| 118 | + map = material->getTextureMap(graphics::Material::MapChannel::SCATTERING_MAP); |
| 119 | + if (map && map->getTextureSource()) { |
| 120 | + scatteringMap = map->getTextureSource()->getUrl().toString(); |
| 121 | + } |
| 117 | 122 | } |
| 118 | 123 | } |
| 119 | 124 | |