Assimp 不返回纹理数据
Assimp doens't return texture data
im使用Assimp加载3D模型。我的模型具有嵌入式纹理("我猜"(。但是我有两个问题:
- 我找不到真正获取纹理文件路径的方法...
- pcdata doens似乎没有任何东西。
我什至无法打印纹理的宽度或高度。
打印texturefile
我得到了常规格式*0 *1
等。
但是当我尝试打印scene->mTextures[atoi(texturefile.C_Str())]->mFileName
时,我什么也没得到...纹理pcdata。
这是代码:
uint32_t textureCount = scene->mMaterials[i]->GetTextureCount(aiTextureType_DIFFUSE);
for (uint32_t c = 0; c < textureCount ; c++) {
scene->mMaterials[i]->GetTexture(aiTextureType_DIFFUSE, c, &texturefile);
std::cout << "n textureFile : " << texturefile.C_Str() << std::endl;
std::cout <<"nTextura : "<< scene->mTextures[atoi(texturefile.C_Str())]<<std::endl;
aiTexture *texture = scene->mTextures[atoi(texturefile.C_Str())];
int w = texture->mWidth;
int h = texture->mHeight;
if (texture == NULL) {
std::cout << "n TextureNulln";
}
else {
std::cout << "n textureNotNulln";
}
uint32_t *data = reinterpret_cast<uint32_t* >(texture->pcData);
createTextureImage(data, w, h, materials[i].texturesImages[c]);
//createTextureImageView(materials[i].texturesImagesViews[c], materials[i].texturesImages[c]);
//createTextureSampler(materials[i].texturesSamplers[c]);
// void createTextureImage(uint32_t* pixels,int texWidth,int texHeight,VkImage textureImage) {
}
}
与Lastest Master一起工作时,以下代码应适用于您:
aiMaterial material = scene->mMaterials[index];
aiString texture_file;
material->Get(AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE, 0), texture_file);
if(auto texture = scene->GetEmbeddedTexture(texture_file.C_Str())) {
//returned pointer is not null, read texture from memory
} else {
//regular file, check if it exists and read it
}
在较旧版本中,您必须寻找一个特殊的令牌:
aiMaterial material = scene->mMaterials[index];
aiString texture_file;
material->Get(AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE, 0), texture_file);
if('*' == texture_file.data[0]) {
//embedded texture, get index from string and access scene->mTextures
} else {
//regular file, check if it exists and read it
}
希望有助于理解概念。
相关文章:
- 指向纹理数据的指针-垂直翻转数据
- C++中纹理数据指针的联合
- 将原始 IOS 相机数据上传到纹理
- 向不可变纹理存储提供数据
- 在 DirectX 中跨线程传递纹理的数据竞赛
- 如何将 SFML 纹理用作静态数据成员
- Assimp 不返回纹理数据
- 如何读取纹理数据,以便我可以编辑它
- 为什么我的数据不适合CUDA纹理对象
- OpenGL纹理格式,为OpenGL创建图像/纹理数据
- 创建原始OpenGL纹理数据(C++)
- OpenGL-将新数据添加到纹理中
- OpenGL:从数据阵列生成2D纹理以显示在四边形上
- Cocos2d-x-从精灵或纹理数据编码base64字符串
- 如何将 frontBuffer 数据复制到纹理 DirectX 9
- OpenGL ES 2 如何渲染到纹理并提取用于 GPGPU 测试的数据
- Opengl 数组纹理,适用于原始数据,但不适用于图像数据
- 在纹理中的 CPU 和 GPU 之间传递数据
- 如何使用OpenGL将体积数据渲染为三维纹理
- 在“顶点着色器”中将纹理数据解释为“顶点”数据