| 153 | } |
| 154 | |
| 155 | int Importer::processTextureReference(const aiMaterial *material, aiTextureType type) |
| 156 | { |
| 157 | if(material->GetTextureCount(type) == 0) { |
| 158 | return -1; |
| 159 | } |
| 160 | |
| 161 | aiString path; |
| 162 | material->GetTexture(type, 0, &path); |
| 163 | if(path.data[0] == '*') { |
| 164 | int textureIndex = QString::fromLocal8Bit(&path.data[1]).toInt(); |
| 165 | if(textureIndex < 0 || textureIndex >= m_scene.textures.size()) { |
| 166 | qWarning() << "Warning: Found invalid embedded texture reference; ignoring."; |
| 167 | return -1; |
| 168 | } |
| 169 | m_scene.textures[textureIndex].refcount++; |
| 170 | return textureIndex; |
| 171 | } |
| 172 | else { |
| 173 | const QString texturePath = QString::fromUtf8(path.C_Str()); |
| 174 | int textureIndex = m_texturesByPath.value(texturePath, -1); |
| 175 | if(textureIndex >= 0) { |
| 176 | m_scene.textures[textureIndex].refcount++; |
| 177 | return textureIndex; |
| 178 | } |
| 179 | else { |
| 180 | TextureComponent textureComponent; |
| 181 | textureComponent.name = texturePath; |
| 182 | textureComponent.refcount = 1; |
| 183 | |
| 184 | int textureIndex = m_scene.textures.size(); |
| 185 | m_scene.textures.append(textureComponent); |
| 186 | m_texturesByPath.insert(texturePath, textureIndex); |
| 187 | return textureIndex; |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | bool Importer::processMeshReference(unsigned int meshIndex, Entity *entity) |
| 193 | { |