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