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

model viewer: support texture subtype 5 and set subtype 3 properly as a 32bit

This commit is contained in:
dpethes 2017-02-04 17:07:41 +01:00
parent 53506af6b3
commit 32d9abb3ba
2 changed files with 15 additions and 16 deletions

View File

@ -175,11 +175,11 @@ procedure TModel.HmtRead(stream: TMemoryStream);
for i := 0 to _hmt.texture_count - 1 do for i := 0 to _hmt.texture_count - 1 do
if _hmt.textures[i].name_string = name then begin if _hmt.textures[i].name_string = name then begin
tex := _hmt.textures[i]; tex := _hmt.textures[i];
if not (tex.image.type_ in [0,1,3,4]) then
break;
mat.bpp := 24; mat.bpp := 24;
if tex.image.type_ = 4 then if tex.image.type_ = 3 then
mat.bpp := 32;
if tex.image.type_ in [4,5] then
mat.bpp := 8; mat.bpp := 8;
mat.width := tex.width; mat.width := tex.width;
@ -255,10 +255,13 @@ procedure TModel.InitGL;
if mat.bpp = 24 then begin if mat.bpp = 24 then begin
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, mat.width, mat.height, 0, GL_RGB, GL_UNSIGNED_BYTE, mat.pixels); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, mat.width, mat.height, 0, GL_RGB, GL_UNSIGNED_BYTE, mat.pixels);
//pnm_save(IntToStr(mat.gl_tex_id)+'.pnm', mat.pixels, mat.width, mat.height); //pnm_save(IntToStr(mat.gl_tex_id)+'.pnm', mat.pixels, mat.width, mat.height);
end; end
if mat.bpp = 8 then begin else if mat.bpp = 8 then begin
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, mat.width, mat.height, 0, GL_RED, GL_UNSIGNED_BYTE, mat.pixels); glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, mat.width, mat.height, 0, GL_RED, GL_UNSIGNED_BYTE, mat.pixels);
//pgm_save(IntToStr(mat.gl_tex_id)+'.pgm', mat.pixels, mat.width, mat.height); //pgm_save(IntToStr(mat.gl_tex_id)+'.pgm', mat.pixels, mat.width, mat.height);
end
else if mat.bpp = 32 then begin
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, mat.width, mat.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, mat.pixels);
end; end;
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );

View File

@ -97,10 +97,7 @@ var
file_pos: integer; file_pos: integer;
color: integer; color: integer;
begin begin
zero := f.ReadDWord; zero := f.ReadQWord;
if (zero <> 0) then
writeln('unusual file: zero');
zero := f.ReadDWord;
if (zero <> 0) then if (zero <> 0) then
writeln('unusual file: zero'); writeln('unusual file: zero');
file_pos := f.ReadDWord; file_pos := f.ReadDWord;
@ -209,15 +206,11 @@ var fgid: integer = 0;
procedure ReadFaceGroup(var fg: THobFaceGroup; var f: TMemoryStream); procedure ReadFaceGroup(var fg: THobFaceGroup; var f: TMemoryStream);
var var
filepos: int64;
fnum: single; fnum: single;
i: Integer; i: Integer;
zero: int64; zero: int64;
fg_next, fg_end: integer; fg_next, fg_end: integer;
begin begin
//save file position before seeking to face/vertex data and restore it, to read next group properly
filepos := f.Position;
//read group/meshdef0 //read group/meshdef0
fg_next := f.ReadDWord; fg_next := f.ReadDWord;
f.Seek(4*2, fsFromCurrent); //unknown f.Seek(4*2, fsFromCurrent); //unknown
@ -238,7 +231,7 @@ begin
//writeln(fnum); //writeln(fnum);
end; end;
fg.fg_group_id := f.ReadDWord; fg.fg_group_id := f.ReadDWord;
for i := 1 to (3*4 + 3*4 + 4*4) div 4 do begin for i := 1 to (3+3+4) do begin //unknown floats
f.ReadBuffer(fnum, 4); f.ReadBuffer(fnum, 4);
//writeln(fnum); //writeln(fnum);
end; end;
@ -295,12 +288,15 @@ begin
mesh.face_group_header_offset := f.ReadDWord; mesh.face_group_header_offset := f.ReadDWord;
mesh.face_group_header2_offset := f.ReadDWord; mesh.face_group_header2_offset := f.ReadDWord;
//TODO skipped stuff
writeln('object: ', NameToString(mesh.name)); writeln('object: ', NameToString(mesh.name));
writeln('face group offset: ', mesh.face_group_offset); writeln('face group offset: ', mesh.face_group_offset);
//get face group count //Facegroup header
f.Seek(mesh.face_group_header_offset, fsFromBeginning); //16B zero f.Seek(mesh.face_group_header_offset, fsFromBeginning); //16B zero
mesh.face_group_count := f.ReadWord; //which? mesh.face_group_count := f.ReadWord; //face group count - which?
mesh.face_group_count0 := f.ReadWord; mesh.face_group_count0 := f.ReadWord;
if mesh.face_group_count <> mesh.face_group_count0 then begin if mesh.face_group_count <> mesh.face_group_count0 then begin
writeln('facegroup counts don''t match!: ', mesh.face_group_count, mesh.face_group_count0:5); writeln('facegroup counts don''t match!: ', mesh.face_group_count, mesh.face_group_count0:5);