C++ 阿西姆普多恩斯';t返回纹理数据

C++ 阿西姆普多恩斯';t返回纹理数据,c++,assimp,C++,Assimp,Im使用assimp加载三维模型。 我的模型嵌入了纹理(“我猜”)。但我有两个问题: 我找不到实际获取纹理文件路径的方法 pcData似乎什么都没有 我甚至不能打印纹理的宽度或高度 打印texturefile我得到了通常的格式*0*1等等 但是,当我试图打印场景->mTextures[atoi(texturefile.C_Str())]->mFileName时,我什么也没有得到……纹理数据也是一样 代码如下: uint32_t textureCount = scene->mMaterial

Im使用assimp加载三维模型。 我的模型嵌入了纹理(“我猜”)。但我有两个问题:

  • 我找不到实际获取纹理文件路径的方法
  • pcData似乎什么都没有
  • 我甚至不能打印纹理的宽度或高度

    打印
    texturefile
    我得到了通常的格式
    *0*1
    等等

    但是,当我试图打印
    场景->mTextures[atoi(texturefile.C_Str())]->mFileName
    时,我什么也没有得到……纹理数据也是一样

    代码如下:

    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 TextureNull\n";
        }
        else {
            std::cout << "\n textureNotNull\n";
        }
    
        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) {
        }
    }
    
    uint32\u t textureCount=scene->mmaerials[i]->GetTextureCount(aiTextureType\u漫反射);
    对于(uint32_t c=0;c材质[i]->获取纹理(aiTextureType\u漫反射、c和纹理文件);
    
    std::cout当使用最新的主机时,以下代码适用于您:

    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
    }
    
    希望这有助于理解这个概念