Sign in to follow this  
KaiserJohan

Assimp, problem with textures

Recommended Posts

KaiserJohan    2317

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[i];
         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?

Edited by KaiserJohan

Share this post


Link to post
Share on other sites
Batryxamat    127

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?

Edited by Batryxamat

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this