L3DT users' community
Large 3D terrain generator

Need a script to decrease height linearly from a point

Correspondence concerning plugins and scripts; development, use, bugs and ideas.

Need a script to decrease height linearly from a point

Postby SharkD » Fri Aug 28, 2009 4:18 am

Hi!

I'm new to L3DT. Nice tool!

I've imported a heightfield I created a long time ago in Leveller. I was wondering if there were an easy way to decrease the height of the existing heightfield as the distance from a point (such as the center) increases? Does such a script exist? If I were editing the heightfield in Photoshop I would create a transparency channel and make it white in the middle and increasingly black as the radius increases.

If the script were slightly more flexible (more blob-ish behavior maybe) that would be great too, but not really necessary for my current project.

Thanks!

-Mike
SharkD
New member
 
Posts: 4
Joined: Fri Aug 28, 2009 4:07 am

Postby Aaron » Fri Aug 28, 2009 12:46 pm

Hi Mike,

The script below will decrease the height in the heightfield radially from the centre. To run this script, use the 'Extensions->ZeoScript->Run script' menu option. Please note that this script was only tested with the latest developmental build, and it may throw errors if used in older versions of L3DT.

When run, the script will ask you to enter the height by which you wish the edge of the map to be lowered (default = 200m), and it will then interpolate across the rest of the map accordingly. If you don't like the results, the script also automatically creates an undo point, so you can press the 'undo' toolbar button to revert the changes to your heightfield.

Code: Select all
//  get HF handle
hvar pHF
set pHF <zs:project.GetMapH "HF">

// get HF size
int nx ny
set nx <zs:map.GetWidth pHF>
set ny <zs:map.GetHeight pHF>
assert <zs:and nx ny> "Error: Heightfield not initialised!"

// ask user for edge offset value
float EdgeOffset
set EdgeOffset 200 // metres
if <zs:not <zs:EditUI EdgeOffset "Enter edge offset (metres)">>
  return false
endif 
 
// create undo point
L3DTio_Backup.ExtBackupMap "HF" "Radial distort script" 0 "view.ShowMap \"HF\""

// create overlay
map Overlay
calc.HF.GenPeakOverlay Overlay <zs:div <zs:max nx ny> 2> EdgeOffset 0

// offset to make centre zero and edge sub-zero
calc.HF.ShiftMap Overlay <zs:sub 0 EdgeOffset> false

// apply overlay
calc.HF.ApplyOverlay pHF Overlay <zs:div nx 2> <zs:div ny 2> 1 true

// redraw HF
view.ShowMap "HF"

return true


Please let me know if you find any problems.

Best regards,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Postby SharkD » Mon Aug 31, 2009 1:35 am

Awesome! Thank you very much!

-Mike
SharkD
New member
 
Posts: 4
Joined: Fri Aug 28, 2009 4:07 am


Return to Plugins and scripts

Who is online

Users browsing this forum: No registered users and 5 guests

cron