Scripts > Calculate gradient

Description Calculate the gradient map of the heightfield.
Author Aaron
Created 2012/03/19 06:20
Requires L3DT v12.03
Download HF_CalcGradient.zs

Script contents

hvar pHF
set pHF <project.GetMap "HF">
assert pHF "Error: cannot get heightfield!"
assert <map.GetWidth pHF> "Error: heightfield not initialised!"

hvar hOutput
set hOutput <project.GetMap "HF_Grad">
if hOutput
  L3DTio_Backup.BackupMap "HF_Grad" "HF_CalcGrad" 0 "view.ShowMap \"HF_Grad\""
  map.Free hOutput
else
  set hOutput <project.CreateMap "HF_Grad">
endif

if <not <calc.HF.CalcGrad pHF hOutput 0x7 true>>
  echo "HF_CalcGrad.zs error - call to 'calc.HF.CalcGrad' failed"
  return -1
endif

map.SetFlag hOutput 1 true // ready
map.SetFlag hOutput 5 true // modified

view.ShowMap "HF_Grad"

return 0