diff --git a/src/osgPlugins/obj/ReaderWriterOBJ.cpp b/src/osgPlugins/obj/ReaderWriterOBJ.cpp index b51ec9295..346ac9329 100644 --- a/src/osgPlugins/obj/ReaderWriterOBJ.cpp +++ b/src/osgPlugins/obj/ReaderWriterOBJ.cpp @@ -225,7 +225,7 @@ osg::Drawable* ReaderWriterOBJ::makeDrawable(GLMmodel* obj, IndexVec tcount(obj->numtexcoords+1,0); bool needNormals = obj->normals && obj->normals>0; - bool needTexcoords = obj->texcoords && obj->numtexcoords>0; + bool needTexcoords = obj->texcoords && obj->numtexcoords>0 && grp->hastexcoords; // first count the number of vertices used in this group. for (i = 0; i < ntris; i++) diff --git a/src/osgPlugins/obj/glm.cpp b/src/osgPlugins/obj/glm.cpp index 005c3c437..c72610da9 100644 --- a/src/osgPlugins/obj/glm.cpp +++ b/src/osgPlugins/obj/glm.cpp @@ -206,6 +206,7 @@ _glmAddGroup(GLMmodel* model, char* name) group->material = 0; group->numtriangles = 0; group->triangles = NULL; + group->hastexcoords = false; group->next = model->groups; model->groups = group; model->numgroups++; @@ -764,6 +765,7 @@ _glmSecondPass(GLMmodel* model, FILE* file) T(numtriangles).tindices[2] = t; T(numtriangles).nindices[2] = n; group->triangles[group->numtriangles++] = numtriangles; + group->hastexcoords = true; numtriangles++; while(fscanf(file, "%d/%d/%d", &v, &t, &n) > 0) { T(numtriangles).vindices[0] = T(numtriangles-1).vindices[0]; @@ -789,6 +791,7 @@ _glmSecondPass(GLMmodel* model, FILE* file) T(numtriangles).vindices[2] = v; T(numtriangles).tindices[2] = t; group->triangles[group->numtriangles++] = numtriangles; + group->hastexcoords = true; numtriangles++; while(fscanf(file, "%d/%d", &v, &t) > 0) { T(numtriangles).vindices[0] = T(numtriangles-1).vindices[0]; diff --git a/src/osgPlugins/obj/glm.h b/src/osgPlugins/obj/glm.h index ffaa499bf..478acaf5d 100644 --- a/src/osgPlugins/obj/glm.h +++ b/src/osgPlugins/obj/glm.h @@ -84,6 +84,7 @@ struct GLMgroup { GLuint numtriangles; /* number of triangles in this group */ GLuint* triangles; /* array of triangle indices */ GLuint material; /* index to material for group */ + bool hastexcoords; /* set to true if triangles have texture coords */ struct GLMgroup* next; /* pointer to next group in model */ void init() @@ -92,6 +93,7 @@ struct GLMgroup { numtriangles = 0; triangles = NULL; material = 0; + hastexcoords = false; next = NULL; } };