L3DT users' wiki
Large 3D terrain generator

 

Scripts > DM_Clip

Description A script to clip the altitude range of the design map (maximum, minimum or both).
Author Aaron
Created 2010/07/07
Requires L3DT v2.9 beta or later
Download DM_Clip.zs

Script contents

//
//   Title | DM_Clip
// Purpose | A script to clip the altitude layer of the design map
//  Author | Aaron Torpy
//    Date | 7 July 2010
//


hvar hDM
set hDM <GetMap "DM">
assert <not <iseq hDM NULL>> "Error: Design map is not present"
assert <map.GetWidth hDM> "Error: Design map is not initialised"

// ask for clipping mode
combosel CS
combosel.InitCS &CS "Clip above|Clip below|Clip both" "Clip above"
if <not <EditUI &CS "Select clipping mode">>
  return -1
endif


// check clipping mode, and ask for clipping altitudes
float ClipAltMin
float ClipAltMax
set ClipAltMin 0
set ClipAltMax 0
int ClipMode
set ClipMode 0
if <iseq <combosel.GetCurSel &CS> "Clip above">
  set ClipMode 0
  if <not <EditUI &ClipAltMax "Enter max clip height (metres)">>
    return -1
  endif
elseif <iseq <combosel.GetCurSel &CS> "Clip below">
  set ClipMode 1
  if <not <EditUI &ClipAltMin "Enter min clip height (metres)">>
    return -1
  endif
elseif <iseq <combosel.GetCurSel &CS> "Clip both">
  set ClipMode 2
  if <not <EditUI &ClipAltMin "Enter min clip height (metres)">>
    return -1
  endif
  if <not <EditUI &ClipAltMax "Enter max clip height (metres)">>
    return -1
  endif
else
  echo "ClipDesignMap script error:\r\n - unknown clipping mode"
  return -1
endif
//echo <strcat ClipAltMin ClipAltMax> // debugging

// create temp HF to contain DM alt layer
map TempHF
if <not <calc.DM.GetLayer hDM &TempHF 0>>
  echo "ClipDesignMap script error:\r\n - cannot extract altitude layer from design map"
  return -1
endif

// store a backup
if <not <L3DTio_Backup.ExtBackupMap "DM" "Clip design map alt" 0 "view.ShowMap \"DM\"">>
  echo "ClipDesignMap script error:\r\n - cannot store backup point for design map"
  //return -1
endif
  

// clip the design map alt layer
if <or <iseq ClipMode 0> <iseq ClipMode 2>>
  if <not <calc.HF.ClipAbove &TempHF ClipAltMax ClipAltMax true>>
    echo "ClipDesignMap script error:\r\n - cannot clip max altitude layer of design map"
    return -1
  endif
endif
// clip the design map alt layer
if <or <iseq ClipMode 1> <iseq ClipMode 2>>
  if <not <calc.HF.ClipBelow &TempHF ClipAltMin ClipAltMin true>>
    echo "ClipDesignMap script error:\r\n - cannot clip min altitude layer of design map"
    return -1
  endif
endif
  
// copy back to design map
if <not <calc.DM.SetLayer hDM &TempHF 0>>
  echo "ClipDesignMap script error:\r\n - cannot copy altitude layer into design map"
  return -1
endif

// redraw design map
view.ShowMap "DM"

MessageBox "Clipping complete!" 0x40
return 0

Comments

None.

 
scripts/clipdesignmap.txt · Last modified: 2017/08/31 06:10 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki