Assimp, problem with textures

Started by
0 comments, last by Batryxamat 10 years, 11 months ago

I am using assimp to import 3d models in my game engine. For some reason, no matter what model or model format I use, assimp does not report any textures whatsoever. Why is this?

The following is the very simple setup with assimp:


const aiScene* scene = importer.ReadFile(asset, aiProcessPreset_TargetRealtime_Quality);

if (scene->HasMaterials())
{
     for (unsigned int i = 0; i < scene->mNumMaterials; i++)
     {
         const aiMaterial* material = scene->mMaterials;
         aiString texturePath;

         unsigned int numTextures= material->GetTextureCount(aiTextureType_DIFFUSE); // always 0

         if (material->GetTextureCount(aiTextureType_DIFFUSE) > 0 && material->GetTexture(aiTextureType_DIFFUSE, 0, &texturePath) == AI_SUCCESS) 
        {
         // never happens..
         // scene->mNumTextures is always 0 aswell - although that only applies to embedded textures
        }
    }
}
 

I'm using various models that I am positive has textures, for example models from tutorials that are designed for the very specific reason of loading textured models using assimp.

What could be the reason for this?

Advertisement

I recently added assimp to import my game assets using Blender to export. I had a similar problem and found that my materials were not exporting the textures from Blender.

Have you validated with a human readible model file format that the textures are exporting from your modeling tool?

This topic is closed to new replies.

Advertisement