| Description | Combine the height in the water map with the heightfield, so that the heightfield has flat areas for the surface of the water bodies. |
|---|---|
| Author | Aaron |
| Created | 2011/03/02 |
| Requires | L3DT v2.9 build 12 or later |
| Download | Combine WM and HF.zs |
// Author: A. Torpy
// Written: 02 Mar 2011
hvar pHF
set pHF <GetMap "HF">
hvar pWM
set pWM <GetMap "WM">
assert <map.GetWidth pHF> "Error: Heightfield is not initialised!"
assert <map.GetWidth pWM> "Error: map is not initialised!"
// create temp HF to contain WM as HF
map TempMap
// convert water map to temp HF
//#define WMFLAG_INCLUDE_SEA 0x00000001
//#define WMFLAG_INCLUDE_LAKES 0x00000002
//#define WMFLAG_INCLUDE_WTABLE 0x00000004
//#define WMFLAG_INCLUDE_EDGES 0x00000008
//#define WMFLAG_SHOW_RESULT 0x00000010
//#define WMFLAG_SHOW_PROGRESS 0x00000020
assert <calc.WM.ConvToHF pWM &TempMap 0x0000002B> "Error: cannot convert water map to heightmap!"
// ask whether to copy over the heightfield, or save as HF_plus_WM?
if <iseq 6 <MessageBox "Overwrite existing heightfield map layer?\r\n\r\n(if 'no', output will be stored in a separate map layer)" 0x00000024>>
//
// user returned 'yes'; store output in heightfield
//
// firstly, backup the heightfield
L3DTio_Backup.BackupMap "HF" "Combine WM and HF" 0x0 "view.ShowMap \"HF\""
// combine
// #define MIXMODE_REPLACE 0
// #define MIXMODE_ADD 1
// #define MIXMODE_SUB 2
// #define MIXMODE_USE_MAX 3
// #define MIXMODE_USE_MIN 4
// #define MIXMODE_MULTIPLY 5
assert <calc.HF.CombineMaps pHF &TempMap 3 0 0> "Error: cannot combine heightfield and water map heightmap!"
// mark output map as visible
//#define MAPFLAG_READY 1
//#define MAPFLAG_SAVED 2
//#define MAPFLAG_MOSAIC 3
//#define MAPFLAG_INVALID 4
//#define MAPFLAG_MODIFIED 5
//#define MAPFLAG_SEAMFIX 6
map.SetFlag pHF 1 true
map.SetFlag pHF 5 true
//show the map
view.ShowMap "HF"
else
//
// user returned 'no'; store output in separate map
//
// create output map
hvar pHF2
set pHF2 <project.GetMap "HF_plus_WM">
if pHF2
// map arelady exists; backup & free
L3DTio_Backup.BackupMap "HF_plus_WM" "Combine WM and HF" 0x0 "view.ShowMap \"HF_plus_WM\""
map.Free pHF2
else
set pHF2 <project.CreateMap "HF_plus_WM">
endif
assert pHF2 "Error: cannot create output map!"
// copy HF into output map
assert <calc.map.CopyArea pHF 0 0 <map.GetWidth pHF> <map.GetHeight pHF> pHF2 0 0 0x00000001> "Error: cannot copy heightfield into swap map!"
// combine
// #define MIXMODE_REPLACE 0
// #define MIXMODE_ADD 1
// #define MIXMODE_SUB 2
// #define MIXMODE_USE_MAX 3
// #define MIXMODE_USE_MIN 4
// #define MIXMODE_MULTIPLY 5
assert <calc.HF.CombineMaps pHF2 &TempMap 3 0 0> "Error: cannot combine heightfield and water map heightmap!"
// mark output map as visible
map.SetFlag pHF2 1 true
map.SetFlag pHF2 5 true
//show the map
view.ShowMap "HF_plus_WM"
endif
return 0
None.