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:
parent
37c2d95600
commit
02029c9da6
@ -61,16 +61,15 @@ NOF * face block
|
||||
4B int face count FC
|
||||
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 51/71
|
||||
1B int 0C
|
||||
1B int block size / 4: A = 40B, 9 = 36, etc.
|
||||
2B int zero?
|
||||
2B int texture/material index?
|
||||
4x 2B vertex indices, relative to the face group
|
||||
-if the last index is zero, the face is most probably a triangle
|
||||
x bytes until block size
|
||||
4x 2B vertex indices, relative to the face group. The last index is zero in triangle faces
|
||||
x bytes until block size: most probably texture coordinates and some other stuff?
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ uses
|
||||
|
||||
type
|
||||
THobFace = record
|
||||
dw1: integer;
|
||||
flags: integer;
|
||||
b1, b2, b3: byte;
|
||||
bsize: byte;
|
||||
ftype: byte; //3 - tri, 4 - quad
|
||||
@ -84,7 +84,7 @@ begin
|
||||
SetLength(group.faces, group.face_count);
|
||||
for i := 0 to group.face_count - 1 do begin
|
||||
file_pos := f.Position;
|
||||
face.dw1 := f.ReadDWord; //?
|
||||
face.flags := f.ReadDWord; //?
|
||||
face.b1 := f.ReadByte; //46/49/4B
|
||||
face.b2 := f.ReadByte; //51/71
|
||||
face.b3 := f.ReadByte; //0C
|
||||
@ -105,18 +105,17 @@ begin
|
||||
for k := 0 to unknown - 1 do
|
||||
buf[k] := f.ReadByte;
|
||||
|
||||
//face type: don't know how to distinguish between quad and triangle, so hack:
|
||||
//if last vertex index is 0, consider this to be a triangle, quad otherwise.
|
||||
//Breaks faces that really use the 0 vertex.
|
||||
if face.indices[3] = 0 then
|
||||
face.ftype := 3
|
||||
//face type: quad or triangle
|
||||
if face.flags and %1000 > 0 then
|
||||
face.ftype := 4
|
||||
else
|
||||
face.ftype := 4;
|
||||
face.ftype := 3;
|
||||
|
||||
group.faces[i] := face;
|
||||
|
||||
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(' coords: ');
|
||||
for k := 0 to 3 do
|
||||
|
Loading…
x
Reference in New Issue
Block a user