Jump to content
  • Advertisement
Sign in to follow this  

Assimp importing incorrect number of textures?

This topic is 1064 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all,

I've started using Assimp in my project, and I've run into an odd issue.

I've got a simple textured cube I've created in Blender and exported to OBJ/MTL format. Here they are (pretty short):

# Blender v2.75 (sub 0) OBJ File: ''# www.blender.orgmtllib cube.mtlo Cubev 0.500000 -0.500000 -0.500000v 0.500000 -0.500000 0.500000v -0.500000 -0.500000 0.500000v -0.500000 -0.500000 -0.500000v 0.500000 0.500000 -0.499999v 0.499999 0.500000 0.500000v -0.500000 0.500000 0.500000v -0.500000 0.500000 -0.500000vt 0.000000 0.000000vt 1.000000 0.000000vt 1.000000 1.000000vt 0.000000 1.000000vn 0.000000 -1.000000 0.000000vn 0.000000 1.000000 0.000000vn 1.000000 0.000000 0.000000vn -0.000000 0.000000 1.000000vn -1.000000 -0.000000 -0.000000vn 0.000000 0.000000 -1.000000usemtl Material.001s offf 1/1/1 2/2/1 3/3/1f 8/2/2 7/3/2 6/4/2f 5/2/3 6/3/3 2/4/3f 6/2/4 7/3/4 3/4/4f 7/2/5 8/3/5 4/4/5f 1/2/6 4/3/6 8/4/6f 4/4/1 1/1/1 3/3/1f 5/1/2 8/2/2 6/4/2f 1/1/3 5/2/3 2/4/3f 2/1/4 6/2/4 3/4/4f 3/1/5 7/2/5 4/4/5f 5/1/6 1/2/6 8/4/6

# Blender MTL File: 'None'# Material Count: 1newmtl Material.001Ns 96.078431Ka 0.000000 0.000000 0.000000Kd 0.640000 0.640000 0.640000Ks 0.500000 0.500000 0.500000Ni 1.000000d 1.000000illum 2map_Kd crate.png

When I call the ReadFile function on the OBJ file, I am calling with 2 flags: aiProcess_Triangulate and aiProcess_JoinIdenticalVertices. The scene seems to be properly created from this call. I can get the vertices, UVs, normals, and indices correctly and render them just fine. The issue is with the materials. When I call scene->mNumMaterials it returns 2 even though I only have 1 texture used in this mesh. The first loads the texture successfully, but then the second is some "ghost" material (or one that I'm unaware of), and it is throwing my mesh off.

Am I missing some flags that should be present or operating with some false assumptions that are causing me to have issues? If anyone could help me understand more about what's going on here that would be great! Thanks!

UPDATE: Using a workaround (basically just ignoring the first material), I can get it to work perfectly fine, but that still leaves my original question. Every time Assimp creates a scene it seems to generate a material at index 0 that is NULL. In other words, if my OBJ has 2 materials in it, the mesh will have 3, but the first will always be NULL. Does anyone know the reasoning behind this? Edited by trentfaris242

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!