Fix indices counter reset each face group
This commit is contained in:
parent
f08db9a448
commit
97d66c1794
@ -21,6 +21,7 @@ unsigned char exportOBJModel(T_HOB_OBJECT* hob_objects, const char *out_path) {
|
||||
obj* objConstruct = NULL;
|
||||
unsigned int i,j;
|
||||
int surfID = 0, materialID = 0, tmpVertex = 0, tmpIndex = 0;
|
||||
int indexOffset = 0; // Used to compensate reset of indices between face group
|
||||
float vertexBuff[3] = {0}, textureBuff[2] = {0};
|
||||
int indicesBuff[3] = {0};
|
||||
|
||||
@ -68,9 +69,9 @@ unsigned char exportOBJModel(T_HOB_OBJECT* hob_objects, const char *out_path) {
|
||||
for ( j = 0; j < hob_objects->face_groups[i].face_count; j++ ) {
|
||||
tmpIndex = obj_add_poly(objConstruct, surfID);
|
||||
|
||||
indicesBuff[0] = (int)hob_objects->face_groups[i].faces[j].indices[0];
|
||||
indicesBuff[1] = (int)hob_objects->face_groups[i].faces[j].indices[1];
|
||||
indicesBuff[2] = (int)hob_objects->face_groups[i].faces[j].indices[2];
|
||||
indicesBuff[0] = indexOffset + (int)hob_objects->face_groups[i].faces[j].indices[0];
|
||||
indicesBuff[1] = indexOffset + (int)hob_objects->face_groups[i].faces[j].indices[1];
|
||||
indicesBuff[2] = indexOffset + (int)hob_objects->face_groups[i].faces[j].indices[2];
|
||||
|
||||
obj_set_poly(objConstruct, surfID, tmpIndex, indicesBuff);
|
||||
|
||||
@ -78,13 +79,15 @@ unsigned char exportOBJModel(T_HOB_OBJECT* hob_objects, const char *out_path) {
|
||||
if (hob_objects->face_groups[i].faces[j].flags_bits.fIsQuad) {
|
||||
tmpIndex = obj_add_poly(objConstruct, surfID);
|
||||
|
||||
indicesBuff[0] = (int)hob_objects->face_groups[i].faces[j].indices[0];
|
||||
indicesBuff[1] = (int)hob_objects->face_groups[i].faces[j].indices[2];
|
||||
indicesBuff[2] = (int)hob_objects->face_groups[i].faces[j].indices[3];
|
||||
indicesBuff[0] = indexOffset + (int)hob_objects->face_groups[i].faces[j].indices[0];
|
||||
indicesBuff[1] = indexOffset + (int)hob_objects->face_groups[i].faces[j].indices[2];
|
||||
indicesBuff[2] = indexOffset + (int)hob_objects->face_groups[i].faces[j].indices[3];
|
||||
|
||||
obj_set_poly(objConstruct, surfID, tmpIndex, indicesBuff);
|
||||
}
|
||||
}
|
||||
|
||||
indexOffset = obj_num_vert(objConstruct);
|
||||
}
|
||||
|
||||
obj_write(objConstruct, objExport_path, NULL, 8);
|
||||
|
Loading…
x
Reference in New Issue
Block a user