L3DT users' wiki
Large 3D terrain generator

 

Scripts > Cone overlay

Description Add a cone to the heightfield at a user-specified position, with user-specified radius and height.
Author Aaron
Created 2011/01/04
Updated 2011/01/04
Requires L3DT v2.9 build 4 or later
Download cone overlay.zs

Script contents

// Author:  A. Torpy
// Created: 04 Jan 2011

// exit immediately if HF is not initialised
hvar pHF
set pHF <GetMap "HF">
assert <map.GetWidth pHF> "Heightfield is not initialised!"

// initiailise the settings
int ls.x_pos_px
int ls.y_pos_px
int ls.radius_px
float ls.height_m

set ls.x_pos_px <div <map.GetWidth pHF> 2>
set ls.y_pos_px <div <map.GetHeight pHF> 2>
set ls.radius_px 100
set ls.height_m 1000

// edit settings UI, and exit if cancelled
if <not <EditUI &ls "Enter cone settings">>
  return -1
endif

// store a backup
L3DTio_Backup.BackupMap "HF" "Apply cone to HF" 0 "view.ShowMap \"HF\""

int PEAK_MODE
set PEAK_MODE 0 // 0 = cone, 1 = , 2 = sinusioid, 3 = pseudo-Gaussian
int MIX_MODE
set MIX_MODE 0  // 0 = add, 1 = subtract, 2 = max, 3 = min, 4 = replace, 5 = multiply

map m
if <not <calc.HF.GenPeakOverlay &m ls.radius_px ls.height_m PEAK_MODE>>
  echo "Error: cannot generate peak overlay in 'Cone overlay.zs'"
  return -1
endif

// apply the peak
if <not <calc.HF.CombineMapsEx pHF &m MIX_MODE <sub ls.x_pos_px ls.radius_px> <sub ls.y_pos_px ls.radius_px> 0 0>>
  echo "Error: cannot combine peak overlay with HF in 'Cone overlay.zs'"
  return -1
endif

// refresh the heightfield
view.ShowMap "HF"

Comments

Position

The position of the cone is set using the x_pos_px and y_pos_px inputs. These are measured from the bottom-left of the map, and are in units of pixels. The default value is the centre of the heightfield.

Peak type

By default, the peak added to the heightfield is a cone. You can change the peak type using the PEAK_MODE variable, which can have the following values:

Value Result
0 cone
1 sinusiod
2 pseudo Gaussian

Overlay type

By default, the peak is added to the heightfield. You can change the overlay mode using the MIX_MODE variable, which can have the following values:

Value Result
0 add
1 subtract
2 maximum
3 minimum
4 replace
5 multiply

Undo

The script automatically creates an undo point before applying the peak. Thus, if you do not like the peak position, height or radius, you may undo the action by pressing CTRL+Z or by selecting the 'Edit→Undo' menu item.

 
scripts/cone_overlay.txt · Last modified: 2017/08/31 05:56 (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