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

hmp2obj: export raw 8-bit terrain heightmap

This commit is contained in:
dpethes 2016-12-29 18:21:01 +01:00
parent a86e9edec0
commit d104b606cd
3 changed files with 18 additions and 12 deletions

View File

@ -17,9 +17,6 @@
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
@ -36,12 +33,10 @@
<Unit0>
<Filename Value="hmp2obj.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="hmp2obj"/>
</Unit0>
<Unit1>
<Filename Value="rs_world.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="rs_world"/>
</Unit1>
</Units>
</ProjectOptions>
@ -55,12 +50,6 @@
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Other>
<CompilerMessages>
<MsgFileName Value=""/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">

View File

@ -35,6 +35,7 @@ begin
writeln('tile size: ', world.TileWidth, 'x', world.TileHeight);
world.ExportToObj('heightmap.obj');
world.ExportToRaw('heightmap.raw');
writeln('world exported');
world.Free;

View File

@ -65,6 +65,7 @@ type
procedure LoadFromFiles(const hmp, tex, texmap: string);
procedure ExportToObj(const objfname: string);
procedure ExportToRaw(const rawfname: string);
constructor Create;
destructor Destroy; override;
@ -347,7 +348,6 @@ var
v: TVertex3f;
x, y, stride: integer;
i2, i3: integer;
texfname: string;
begin
AssignFile(f, objFname);
Rewrite(f);
@ -405,6 +405,22 @@ begin
WriteToObj(objfname);
end;
procedure TWorld.ExportToRaw(const rawfname: string);
var
f: file;
image_size, i: integer;
y: Byte;
begin
AssignFile(f, rawfname);
Rewrite(f,1);
image_size := heightmap.width * heightmap.height;
for i := 0 to image_size - 1 do begin
y := 255 - height_texture[i]; //negative scale - Unity uses it like this, for example
BlockWrite(f, y, 1);
end;
CloseFile(f);
end;
constructor TWorld.Create;
begin
height_texture := nil;