Table of Contents

Scripts > Import heightmap tile

Description A script to import an area of the heightfield from a file.
Author Aaron
Created 2010/05/24
Requires L3DT 11.07 beta 2 or later
Download import heightmap tile.zs

Script contents

// Author:  A. Torpy
// Updated: 14 Jul 2011

hvar hMap
set hMap <GetMap "HF">
assert hMap "Cannot get heightfield!"

// exit immediately if HF is not initialised
assert <map.GetWidth hMap> "Heightfield is not initialised!"

// initialise and edit file selector
filesel FS
filesel.Init &FS true NULL "Heightfield files|*.hfz;*.hf2;*.hff;*.ter;*.bt;*.png;*.bmp;*.tga|All files (*.*)|*.*|" NULL NULL
assert <EditUI &FS "Select tile to import"> "Import aborted"

// initialise and edit settings list
int ls.x_offset ls.y_offset
set ls.x_offset 0
set ls.y_offset 0
assert <EditUI &ls "Tile overlay settings"> "Import aborted"

// load the map tile
map TileMap
assert <map.LoadFile2 &TileMap <filesel.GetPathA &FS> HF false true> "Error loading file"

// store a backup
L3DTio_Backup.BackupMap "HF" "Import HF tile" 0 "view.ShowMap \"HF\""

// overlay the tile
assert <calc.HF.CombineMapsEx hMap &TileMap 4 ls.x_offset ls.y_offset 0 0> "Error combining maps"

// refresh the heightfield
view.ShowMap "HF"

Comments

None.