【发布时间】:2020-09-17 21:23:08
【问题描述】:
今天我发现了一个带有嵌入纹理的 3mf 文件(我的意思是嵌入的 .png 纹理存在于 3mf zip 中)。
由于我目前正在学习 Assimp 库,因此我尝试加载它并且它运行良好,网格已正确加载,但是根本没有加载 png 纹理。
Assimp 是否能够加载 3mf 文件的嵌入纹理?
为了在这里问我的问题之前做一些研究,我做了这样的事情来记录assimp加载了什么样的材料属性(加载我的3mf文件时):
/** Loading material **/
aiString Path;
for (unsigned int i = 0 ; i < pScene->mNumMaterials ; i++) {
const aiMaterial* pMaterial = pScene->mMaterials[i];
if (pMaterial->GetTextureCount(aiTextureType_DIFFUSE) > 0){
if (pMaterial->GetTexture(aiTextureType_DIFFUSE, 0, &Path, NULL, NULL, NULL, NULL, NULL) == AI_SUCCESS) {
String FullPath =AppendFileName(GetFileFolder(Filename), String(Path.data));
InsertTexture(FullPath,i);
}
} /*
multiple else if to handle all different texture type
*/
}else{
//If no texture type have match the current aiMaterial object then I log it to find what goes wrong
for(int e = 0; e < pMaterial->mNumProperties; e++){
aiMaterialProperty* aiMp = pMaterial->mProperties[e];
LOG("Property number " + AsString(e) +" :");
LOG("mKey : " + String((*aiMp).mKey.data));
LOG("mSemantic : " + AsString((*aiMp).mSemantic));
LOG("mIndex : " + AsString((*aiMp).mIndex));
LOG("mDataLength : " + AsString((*aiMp).mDataLength));
LOG("aiPropertyTypeInfo : " + AsString((int) (*aiMp).mType));
String str = String((*aiMp).mData);
LOG("mData count : " + AsString(str.GetCount()));
LOG("---------------------------------");
}
}
}
/*************************/
如您所见,我正在打印材质以更深入地观察它,但是由于我对 assimp 的了解非常低,这对我没有多大帮助!
在这里你可以找到3mf文件aiMaterial属性的LOG:
在翻译 mKey / aiPropertyTypeInfo 之后,这两个属性似乎与纹理无关,它仅用于描述我的对象的材质/光线的计算方式。有人可以确认我吗?
【问题讨论】: