mirror of
https://github.com/dpethes/rerogue.git
synced 2025-06-07 18:58:32 +02:00
HOB parser: change how triangle / quad faces are determined
This commit is contained in:
parent
91b625d677
commit
7075f10021
@ -66,10 +66,10 @@ NOF * face block
|
|||||||
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.
|
||||||
if block size = 9, this is a triangle, else quad
|
|
||||||
2B int zero?
|
2B int zero?
|
||||||
2B int texture/material index?
|
2B int texture/material index?
|
||||||
4x 2B vertex indices, if triangle, the last index is zero. Vertex indices are relative to the face group
|
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
|
x bytes until block size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,9 @@ function ParseHobFile(const fname: string): THobFile;
|
|||||||
//**************************************************************************************************
|
//**************************************************************************************************
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
const
|
||||||
|
DumpFaces = false;
|
||||||
|
|
||||||
function NameToString(name: array of byte): string;
|
function NameToString(name: array of byte): string;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
@ -63,6 +66,7 @@ var
|
|||||||
face: THobFace;
|
face: THobFace;
|
||||||
unknown: integer;
|
unknown: integer;
|
||||||
file_pos: integer;
|
file_pos: integer;
|
||||||
|
buf: array[0..255] of byte;
|
||||||
begin
|
begin
|
||||||
unknown := f.ReadDWord;
|
unknown := f.ReadDWord;
|
||||||
if (unknown <> 0) then
|
if (unknown <> 0) then
|
||||||
@ -84,36 +88,43 @@ begin
|
|||||||
face.b2 := f.ReadByte; //51/71
|
face.b2 := f.ReadByte; //51/71
|
||||||
face.b3 := f.ReadByte; //0C
|
face.b3 := f.ReadByte; //0C
|
||||||
face.bsize := f.ReadByte * 4; //block size: A = 40B, 9 = 36
|
face.bsize := f.ReadByte * 4; //block size: A = 40B, 9 = 36
|
||||||
if face.bsize = 36 then
|
|
||||||
face.ftype := 3
|
|
||||||
else
|
|
||||||
face.ftype := 4;
|
|
||||||
|
|
||||||
write(face.dw1:8, face.b1:3, face.b2:3, face.b3:3, face.bsize:3);
|
|
||||||
|
|
||||||
unknown := f.ReadWord;
|
unknown := f.ReadWord;
|
||||||
if (unknown <> 0) then
|
if (unknown <> 0) then
|
||||||
writeln('unusual file: unknown');
|
writeln('unusual file: unknown');
|
||||||
|
|
||||||
face.tex_index := f.ReadWord;
|
face.tex_index := f.ReadWord;
|
||||||
write(' ti: ', face.tex_index);
|
|
||||||
|
|
||||||
//read vertex indices
|
//read vertex indices
|
||||||
write(' coords: ');
|
for k := 0 to 3 do
|
||||||
for k := 0 to 3 do begin
|
|
||||||
face.indices[k] := f.ReadWord;
|
face.indices[k] := f.ReadWord;
|
||||||
write(face.indices[k]:4);
|
|
||||||
end;
|
|
||||||
|
|
||||||
//read rest of the face block
|
//read rest of the face block
|
||||||
write(' rest: ');
|
unknown := file_pos + face.bsize - f.Position;
|
||||||
for k := f.Position to file_pos + face.bsize - 1 do begin
|
for k := 0 to unknown - 1 do
|
||||||
unknown := f.ReadByte;
|
buf[k] := f.ReadByte;
|
||||||
write(unknown: 4);
|
|
||||||
end;
|
//face type: don't know how to distinguish between quad and triangle, so hack:
|
||||||
writeln;
|
//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
|
||||||
|
else
|
||||||
|
face.ftype := 4;
|
||||||
|
|
||||||
group.faces[i] := face;
|
group.faces[i] := face;
|
||||||
|
|
||||||
|
if DumpFaces then begin
|
||||||
|
write(face.dw1:8, 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
|
||||||
|
write(face.indices[k]:4);
|
||||||
|
write(' rest: ');
|
||||||
|
for k := 0 to unknown - 1 do
|
||||||
|
write(buf[k]:4);
|
||||||
|
writeln;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -172,9 +183,7 @@ var
|
|||||||
f: TMemoryStream;
|
f: TMemoryStream;
|
||||||
hob: THobFile;
|
hob: THobFile;
|
||||||
i: integer;
|
i: integer;
|
||||||
vertex_count: integer;
|
obj_count: integer;
|
||||||
obj_count, face_block_offset: integer;
|
|
||||||
meshdef_offset: integer;
|
|
||||||
unknown: integer;
|
unknown: integer;
|
||||||
begin
|
begin
|
||||||
f := TMemoryStream.Create;
|
f := TMemoryStream.Create;
|
||||||
@ -203,7 +212,6 @@ begin
|
|||||||
hob.face_group_count0 := f.ReadWord;
|
hob.face_group_count0 := f.ReadWord;
|
||||||
if hob.face_group_count <> hob.face_group_count0 then begin
|
if hob.face_group_count <> hob.face_group_count0 then begin
|
||||||
writeln('reading failed: facegroup counts don''t match!: ', hob.face_group_count, hob.face_group_count0:5);
|
writeln('reading failed: facegroup counts don''t match!: ', hob.face_group_count, hob.face_group_count0:5);
|
||||||
halt;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//read face group defs
|
//read face group defs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user