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:
parent
53506af6b3
commit
32d9abb3ba
@ -175,11 +175,11 @@ procedure TModel.HmtRead(stream: TMemoryStream);
|
||||
for i := 0 to _hmt.texture_count - 1 do
|
||||
if _hmt.textures[i].name_string = name then begin
|
||||
tex := _hmt.textures[i];
|
||||
if not (tex.image.type_ in [0,1,3,4]) then
|
||||
break;
|
||||
|
||||
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.width := tex.width;
|
||||
@ -255,10 +255,13 @@ procedure TModel.InitGL;
|
||||
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);
|
||||
//pnm_save(IntToStr(mat.gl_tex_id)+'.pnm', mat.pixels, mat.width, mat.height);
|
||||
end;
|
||||
if mat.bpp = 8 then begin
|
||||
end
|
||||
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);
|
||||
//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;
|
||||
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
||||
|
@ -97,10 +97,7 @@ var
|
||||
file_pos: integer;
|
||||
color: integer;
|
||||
begin
|
||||
zero := f.ReadDWord;
|
||||
if (zero <> 0) then
|
||||
writeln('unusual file: zero');
|
||||
zero := f.ReadDWord;
|
||||
zero := f.ReadQWord;
|
||||
if (zero <> 0) then
|
||||
writeln('unusual file: zero');
|
||||
file_pos := f.ReadDWord;
|
||||
@ -209,15 +206,11 @@ var fgid: integer = 0;
|
||||
|
||||
procedure ReadFaceGroup(var fg: THobFaceGroup; var f: TMemoryStream);
|
||||
var
|
||||
filepos: int64;
|
||||
fnum: single;
|
||||
i: Integer;
|
||||
zero: int64;
|
||||
fg_next, fg_end: integer;
|
||||
begin
|
||||
//save file position before seeking to face/vertex data and restore it, to read next group properly
|
||||
filepos := f.Position;
|
||||
|
||||
//read group/meshdef0
|
||||
fg_next := f.ReadDWord;
|
||||
f.Seek(4*2, fsFromCurrent); //unknown
|
||||
@ -238,7 +231,7 @@ begin
|
||||
//writeln(fnum);
|
||||
end;
|
||||
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);
|
||||
//writeln(fnum);
|
||||
end;
|
||||
@ -295,12 +288,15 @@ begin
|
||||
mesh.face_group_header_offset := f.ReadDWord;
|
||||
mesh.face_group_header2_offset := f.ReadDWord;
|
||||
|
||||
//TODO skipped stuff
|
||||
|
||||
writeln('object: ', NameToString(mesh.name));
|
||||
writeln('face group offset: ', mesh.face_group_offset);
|
||||
|
||||
//get face group count
|
||||
//Facegroup header
|
||||
|
||||
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;
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user