mirror of
https://github.com/dpethes/rerogue.git
synced 2025-06-07 18:58:32 +02:00
hmp2obj: use height scale value read from file. Might not be the proper scaling, but looks close
This commit is contained in:
parent
b21148ca13
commit
5985a36395
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<CONFIG>
|
<CONFIG>
|
||||||
<ProjectOptions>
|
<ProjectOptions>
|
||||||
<Version Value="9"/>
|
<Version Value="10"/>
|
||||||
<PathDelim Value="\"/>
|
<PathDelim Value="\"/>
|
||||||
<General>
|
<General>
|
||||||
<Flags>
|
<Flags>
|
||||||
|
@ -33,6 +33,7 @@ begin
|
|||||||
|
|
||||||
writeln('world loaded');
|
writeln('world loaded');
|
||||||
writeln('tile size: ', world.TileWidth, 'x', world.TileHeight);
|
writeln('tile size: ', world.TileWidth, 'x', world.TileHeight);
|
||||||
|
writeln('scale: ', world.MapScale:7:3);
|
||||||
|
|
||||||
world.ExportToObj('heightmap.obj');
|
world.ExportToObj('heightmap.obj');
|
||||||
world.ExportToRaw('heightmap.raw');
|
world.ExportToRaw('heightmap.raw');
|
||||||
|
@ -63,6 +63,7 @@ type
|
|||||||
public
|
public
|
||||||
property TileWidth: word read heightmap.width;
|
property TileWidth: word read heightmap.width;
|
||||||
property TileHeight: word read heightmap.height;
|
property TileHeight: word read heightmap.height;
|
||||||
|
property MapScale: single read heightmap.y_scale;
|
||||||
|
|
||||||
procedure LoadFromFiles(const hmp, tex, texmap: string);
|
procedure LoadFromFiles(const hmp, tex, texmap: string);
|
||||||
procedure ExportToObj(const objfname: string);
|
procedure ExportToObj(const objfname: string);
|
||||||
@ -300,13 +301,15 @@ var
|
|||||||
vert: TVertex3f;
|
vert: TVertex3f;
|
||||||
width_half, height_half: integer;
|
width_half, height_half: integer;
|
||||||
i: integer;
|
i: integer;
|
||||||
|
height_scale: single;
|
||||||
begin
|
begin
|
||||||
vertex_count := heightmap.width * 4 * heightmap.height * 4;
|
vertex_count := heightmap.width * 4 * heightmap.height * 4;
|
||||||
va_size := vertex_count * SizeOf(TVertex3f);
|
va_size := vertex_count * SizeOf(TVertex3f);
|
||||||
vertex_array := getmem(va_size);
|
vertex_array := getmem(va_size);
|
||||||
|
|
||||||
width_half := heightmap.width * 2;
|
width_half := heightmap.width * 2; //half of width & height in vertex count
|
||||||
height_half := heightmap.height * 2;
|
height_half := heightmap.height * 2;
|
||||||
|
height_scale := heightmap.y_scale * 2 / 10; //this is just a guesswork, no idea what's the real calculation
|
||||||
|
|
||||||
for y := 0 to heightmap.height * 4 - 1 do
|
for y := 0 to heightmap.height * 4 - 1 do
|
||||||
for x := 0 to heightmap.width * 4 - 1 do begin
|
for x := 0 to heightmap.width * 4 - 1 do begin
|
||||||
@ -315,7 +318,7 @@ begin
|
|||||||
vert.u := x / (heightmap.width * 4);
|
vert.u := x / (heightmap.width * 4);
|
||||||
vert.v := y / (heightmap.height * 4);
|
vert.v := y / (heightmap.height * 4);
|
||||||
i := y * heightmap.width * 4 + x;
|
i := y * heightmap.width * 4 + x;
|
||||||
vert.y := (255 - height_texture[i]) * 0.01; //inverse for mos eisley / lv0
|
vert.y := (255 - height_texture[i]) * height_scale;
|
||||||
vertex_array[i] := vert;
|
vertex_array[i] := vert;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -360,13 +363,13 @@ begin
|
|||||||
//vertices
|
//vertices
|
||||||
for i := 0 to vertex_count - 1 do begin
|
for i := 0 to vertex_count - 1 do begin
|
||||||
v := vertex_array[i];
|
v := vertex_array[i];
|
||||||
writeln(f, 'v ', v.x:10:6, ' ', v.y:10:6, ' ', v.z:10:6);
|
writeln(f, 'v ', v.x:0:2, ' ', v.y:0:2, ' ', v.z:0:2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//uv-s
|
//uv-s
|
||||||
for i := 0 to vertex_count - 1 do begin
|
for i := 0 to vertex_count - 1 do begin
|
||||||
v := vertex_array[i];
|
v := vertex_array[i];
|
||||||
writeln(f, 'vt ', v.u:10:6, ' ', v.v:10:6);
|
writeln(f, 'vt ', v.u:0:4, ' ', v.v:0:4);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//select material
|
//select material
|
||||||
|
Loading…
x
Reference in New Issue
Block a user