Fixes to .obj plugin from gideon.

This commit is contained in:
Robert Osfield 2002-04-25 11:30:21 +00:00
parent 1d8533c8ee
commit 6dbfa3b88d
3 changed files with 6 additions and 1 deletions

View File

@ -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++)

View File

@ -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];

View File

@ -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;
}
};