Skip to content
This repository has been archived by the owner on May 2, 2018. It is now read-only.

A bug in ObjImporter #7

Closed
ghost opened this issue May 11, 2014 · 0 comments
Closed

A bug in ObjImporter #7

ghost opened this issue May 11, 2014 · 0 comments

Comments

@ghost
Copy link

ghost commented May 11, 2014

Hi
First of all, you did a great work.

I found a tiny bug in the obj importer (ObjImporter), when trying to import an obj file that has no textures the code will raise IndexOutOfRangeException in line 77. The solution is very simple, just add an if condition to check if the number of textures in the mtl file.

Old code:

// Copy normals.
foreach (int textureIndex in f.TextureIndices)
{
        TextureCoordinate tc = wavefrontObject.Textures[textureIndex];
        mesh.TextureCoordinates.Add(new Point3D(tc.U, tc.V, tc.W));
}

New code (my code):

// Copy normals.
foreach (int textureIndex in f.TextureIndices) 
{
    if (wavefrontObject.Textures.Count > 0) 
    {
          TextureCoordinate tc = wavefrontObject.Textures[textureIndex];
           mesh.TextureCoordinates.Add(new Point3D(tc.U, tc.V, tc.W));
    }
}

Thanks a lot

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants