2
0
mirror of https://github.com/dpethes/rerogue.git synced 2025-06-07 18:58:32 +02:00

hob parser: properly distinguish between quad and triangle faces

This commit is contained in:
dpethes 2014-10-14 01:57:58 +02:00
parent 37c2d95600
commit 02029c9da6
2 changed files with 11 additions and 13 deletions

View File

@ -61,16 +61,15 @@ NOF * face block
4B int face count FC 4B int face count FC
FC * face FC * face
{ {
4B int ? 4B int face flags? if bit 3 is set, the face is a quad, otherwise triangle
1B int 46/49/4B 1B int 46/49/4B
1B int 51/71 1B int 51/71
1B int 0C 1B int 0C
1B int block size / 4: A = 40B, 9 = 36, etc. 1B int block size / 4: A = 40B, 9 = 36, etc.
2B int zero? 2B int zero?
2B int texture/material index? 2B int texture/material index?
4x 2B vertex indices, relative to the face group 4x 2B vertex indices, relative to the face group. The last index is zero in triangle faces
-if the last index is zero, the face is most probably a triangle x bytes until block size: most probably texture coordinates and some other stuff?
x bytes until block size
} }
} }

View File

@ -8,7 +8,7 @@ uses
type type
THobFace = record THobFace = record
dw1: integer; flags: integer;
b1, b2, b3: byte; b1, b2, b3: byte;
bsize: byte; bsize: byte;
ftype: byte; //3 - tri, 4 - quad ftype: byte; //3 - tri, 4 - quad
@ -84,7 +84,7 @@ begin
SetLength(group.faces, group.face_count); SetLength(group.faces, group.face_count);
for i := 0 to group.face_count - 1 do begin for i := 0 to group.face_count - 1 do begin
file_pos := f.Position; file_pos := f.Position;
face.dw1 := f.ReadDWord; //? face.flags := f.ReadDWord; //?
face.b1 := f.ReadByte; //46/49/4B face.b1 := f.ReadByte; //46/49/4B
face.b2 := f.ReadByte; //51/71 face.b2 := f.ReadByte; //51/71
face.b3 := f.ReadByte; //0C face.b3 := f.ReadByte; //0C
@ -105,18 +105,17 @@ begin
for k := 0 to unknown - 1 do for k := 0 to unknown - 1 do
buf[k] := f.ReadByte; buf[k] := f.ReadByte;
//face type: don't know how to distinguish between quad and triangle, so hack: //face type: quad or triangle
//if last vertex index is 0, consider this to be a triangle, quad otherwise. if face.flags and %1000 > 0 then
//Breaks faces that really use the 0 vertex. face.ftype := 4
if face.indices[3] = 0 then
face.ftype := 3
else else
face.ftype := 4; face.ftype := 3;
group.faces[i] := face; group.faces[i] := face;
if DumpFaces then begin if DumpFaces then begin
write(face.dw1:8, face.b1:3, face.b2:3, face.b3:3, face.bsize:3); if face.ftype = 3 then write('t') else write('q');
write(face.flags:5, face.b1:3, face.b2:3, face.b3:3, face.bsize:3);
write(' ti: ', face.tex_index); write(' ti: ', face.tex_index);
write(' coords: '); write(' coords: ');
for k := 0 to 3 do for k := 0 to 3 do