Assimp不返回纹理数据

时间:2019-06-29 19:16:22

标签: c++ assimp

我使用assimp加载3D模型。 我的模型具有嵌入式纹理(“我猜”)。但是我有两个问题:

  1. 我找不到实际获取纹理文件路径的方法...
  2. pcData似乎什么都没有。

我什至无法打印纹理的宽度或高度。

打印<div class="card__image"></div>,我得到的是常用格式texturefile,依此类推。

但是当我尝试打印*0 *1时,什么也没得到……与纹理pcData相同。

代码如下:

scene->mTextures[atoi(texturefile.C_Str())]->mFileName

1 个答案:

答案 0 :(得分:0)

与最新的母版一起使用时,以下代码将为您工作:

parameter<string> SourceDir := '%SourceDataDir%/OV/GTFS_20190318';
container write_to_fss
{
    unit<uint32> trip
    : StorageName     = "=SourceDir + '/trips.csv'"
    , StorageType     = "gdal.vect"
    , StorageReadOnly = "True";

    unit<uint32> name := SubItem_PropValues(trip,'name');
    unit<uint32> fssdomain := trip;

    container to_fss_domain : StorageName = "=SourceDir + '/trip_domain.fss'"
    {
        unit<uint32> domain := fssdomain;
    }

    container to_fss := 
        for_each_nedv(
            name/name
            , 'trip/' + name/name
            , to_fss_domain/domain
            , string
        )
    ,   StorageName = "=SourceDir + '/trip.fss'";
}

container readdomain
:   StorageName = "=SourceDir + '/trip_domain.fss'"
,   StorageReadOnly = "True"
{
    unit<uint32> domain;
}

container trip := 
    for_each_ndv(
        write_to_fss/name/name
        , readdomain/domain
        , string)
,   StorageName     = "=SourceDir + '/trip.fss'"
,   StorageReadOnly = "True"
{
    unit<uint32> domain := readdomain/domain;
}

在旧版本中,您必须寻找特殊的令牌:

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
}

希望有助于理解这一概念。

相关问题