aboutsummaryrefslogtreecommitdiff
path: root/project/scripts/kcl
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--project/scripts/kcl/lower-walls.txt41
-rw-r--r--project/scripts/kcl/minimap.txt17
-rw-r--r--project/scripts/kcl/remove-face-down-roads.txt20
3 files changed, 78 insertions, 0 deletions
diff --git a/project/scripts/kcl/lower-walls.txt b/project/scripts/kcl/lower-walls.txt
new file mode 100644
index 0000000..6ec281d
--- /dev/null
+++ b/project/scripts/kcl/lower-walls.txt
@@ -0,0 +1,41 @@
+###############################
+### (c) Wiimm, 2015-12-18 ###
+###############################
+
+# Setup
+@def start = mSec() # start time, for the status line
+@def mod_count = 0 # modification counter
+
+# Get the value for lowering the walls.
+# If 'lower' is defined as number by option --const => use it.
+# Otherwise use the default of 30.
+@def lower = isNumeric(lower) ? lower : 30
+
+# Limit to walls with inclination <45 degree
+# If 'degree' is defined by option --const as number >0 => use it.
+# Otherwise use the default of 45 degrees.
+@def degree = isNumeric(degree) && degree > 0 ? degree : 45
+@def sin_degree = sin(degree)
+
+# Define a function to test the KCL flag for walls
+@function isWall # flag
+ @pdef t = $1 & 0x1f
+ @return t == 0x0c || t == 0x0d || t == 0x0f || t == 0x14 || t == 0x1e || t == 0x1f
+@endfunction
+
+# Main loop: Iterate through all triangles
+@for t=0;tri$n()-1
+ @if isWall(tri$flag(t))
+ @def norm = tri$normal(t,0) # get the first normal
+ @if abs(norm.y) < sin_degree
+ # it's a vertical wall -> lower the wall & increment counter
+ @def status = tri$shift(t,-vy(lower))
+ @def mod_count = mod_count+1
+ @endif
+ @endif
+@endfor
+
+# Print a little status line
+@echo " - " mod_count " of " tri$n() " triangles lowered by " lower
+ > " in " (mSec()-start) " msec."
+
diff --git a/project/scripts/kcl/minimap.txt b/project/scripts/kcl/minimap.txt
new file mode 100644
index 0000000..a79ac08
--- /dev/null
+++ b/project/scripts/kcl/minimap.txt
@@ -0,0 +1,17 @@
+
+@def start = mSec() # start time
+@def mod_count = 0 # modification counter
+
+@function isRoad # flag
+ @pdef t = $1 & 0x1f
+ @return t <= 0x05 || t == 0x17 || t == 0x1d
+@endfunction
+
+@for t=0;tri$n()-1
+ @if !isRoad(tri$flag(t,2))
+ @def status = tri$remove(t)
+ @endif
+@endfor
+
+@echo " - " mod_count " of " tri$n() " triangles lowered in " (mSec()-start) " msec."
+
diff --git a/project/scripts/kcl/remove-face-down-roads.txt b/project/scripts/kcl/remove-face-down-roads.txt
new file mode 100644
index 0000000..e21bddf
--- /dev/null
+++ b/project/scripts/kcl/remove-face-down-roads.txt
@@ -0,0 +1,20 @@
+
+#--- remove face down roads
+
+@def start = mSec() # start time, for the status line
+@def rm_count = 0 # reset status counter
+
+@for t=0; tri$n()-1 # for each tirangle (index 0 based)
+ @pdef type = tri$flag(t) & 0x1f # get the KCL type
+ @if kcl$drive & (1<<type) # if it is a drivable KCL type
+ @def norm = tri$normal(t,0) # get the first normal
+ @if norm.y < 0 # if it is face down
+ @def stat = tri$remove(t) # remove the triangle
+ @def rm_count = rm_count + 1 # incremtent the counter
+ @endif # endif
+ @endif # endif
+@endfor
+
+# print out a summary line
+@echo " - " rm_count " face down road triangles removed in " (mSec()-start) " msec."
+