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:
parent
a86e9edec0
commit
d104b606cd
@ -17,9 +17,6 @@
|
|||||||
<i18n>
|
<i18n>
|
||||||
<EnableI18N LFM="False"/>
|
<EnableI18N LFM="False"/>
|
||||||
</i18n>
|
</i18n>
|
||||||
<VersionInfo>
|
|
||||||
<StringTable ProductVersion=""/>
|
|
||||||
</VersionInfo>
|
|
||||||
<BuildModes Count="1">
|
<BuildModes Count="1">
|
||||||
<Item1 Name="Default" Default="True"/>
|
<Item1 Name="Default" Default="True"/>
|
||||||
</BuildModes>
|
</BuildModes>
|
||||||
@ -36,12 +33,10 @@
|
|||||||
<Unit0>
|
<Unit0>
|
||||||
<Filename Value="hmp2obj.lpr"/>
|
<Filename Value="hmp2obj.lpr"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="hmp2obj"/>
|
|
||||||
</Unit0>
|
</Unit0>
|
||||||
<Unit1>
|
<Unit1>
|
||||||
<Filename Value="rs_world.pas"/>
|
<Filename Value="rs_world.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="rs_world"/>
|
|
||||||
</Unit1>
|
</Unit1>
|
||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
@ -55,12 +50,6 @@
|
|||||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
<Other>
|
|
||||||
<CompilerMessages>
|
|
||||||
<MsgFileName Value=""/>
|
|
||||||
</CompilerMessages>
|
|
||||||
<CompilerPath Value="$(CompPath)"/>
|
|
||||||
</Other>
|
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
<Debugging>
|
<Debugging>
|
||||||
<Exceptions Count="3">
|
<Exceptions Count="3">
|
||||||
|
@ -35,6 +35,7 @@ begin
|
|||||||
writeln('tile size: ', world.TileWidth, 'x', world.TileHeight);
|
writeln('tile size: ', world.TileWidth, 'x', world.TileHeight);
|
||||||
|
|
||||||
world.ExportToObj('heightmap.obj');
|
world.ExportToObj('heightmap.obj');
|
||||||
|
world.ExportToRaw('heightmap.raw');
|
||||||
writeln('world exported');
|
writeln('world exported');
|
||||||
|
|
||||||
world.Free;
|
world.Free;
|
||||||
|
@ -65,6 +65,7 @@ type
|
|||||||
|
|
||||||
procedure LoadFromFiles(const hmp, tex, texmap: string);
|
procedure LoadFromFiles(const hmp, tex, texmap: string);
|
||||||
procedure ExportToObj(const objfname: string);
|
procedure ExportToObj(const objfname: string);
|
||||||
|
procedure ExportToRaw(const rawfname: string);
|
||||||
|
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -347,7 +348,6 @@ var
|
|||||||
v: TVertex3f;
|
v: TVertex3f;
|
||||||
x, y, stride: integer;
|
x, y, stride: integer;
|
||||||
i2, i3: integer;
|
i2, i3: integer;
|
||||||
texfname: string;
|
|
||||||
begin
|
begin
|
||||||
AssignFile(f, objFname);
|
AssignFile(f, objFname);
|
||||||
Rewrite(f);
|
Rewrite(f);
|
||||||
@ -405,6 +405,22 @@ begin
|
|||||||
WriteToObj(objfname);
|
WriteToObj(objfname);
|
||||||
end;
|
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;
|
constructor TWorld.Create;
|
||||||
begin
|
begin
|
||||||
height_texture := nil;
|
height_texture := nil;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user