started implementing tristrip; implemented camera frustum

This commit is contained in:
aap
2017-03-16 01:10:01 +01:00
parent c2780d56e9
commit 4941711964
12 changed files with 842 additions and 58 deletions

View File

@@ -431,9 +431,26 @@ Geometry::generateTriangles(int8 *adc)
}
}
static void
dumpMesh(Mesh *m)
{
for(int32 i = 0; i < m->numIndices-2; i++)
// if(i % 2)
// printf("%3d %3d %3d\n",
// m->indices[i+1],
// m->indices[i],
// m->indices[i+2]);
// else
printf("%d %d %d\n",
m->indices[i],
m->indices[i+1],
m->indices[i+2]);
}
void
Geometry::buildMeshes(void)
{
//dumpMesh(this->meshHeader->mesh);
delete this->meshHeader;
Triangle *tri;
@@ -467,9 +484,8 @@ Geometry::buildMeshes(void)
h->mesh[tri->matId].numIndices = idx;
tri++;
}
}else{
assert(0 && "can't tristrip\n");
}
}else
this->buildTristrips();
}
/* The idea is that even in meshes where winding is not preserved
@@ -508,9 +524,11 @@ Geometry::correctTristripWinding(void)
/* Entering strip now,
* make sure winding is correct */
inStrip = 1;
if(newmesh->numIndices % 2)
newmesh->indices[newmesh->numIndices++] =
if(newmesh->numIndices % 2){
newmesh->indices[newmesh->numIndices] =
newmesh->indices[newmesh->numIndices-1];
newmesh->numIndices++;
}
}
newmesh->indices[newmesh->numIndices++] = mesh->indices[j];
}