aboutsummaryrefslogtreecommitdiff
path: root/stltogl
diff options
context:
space:
mode:
authorNat Lasseter <nat.lasseter@york.ac.uk>2024-01-22 10:23:58 +0000
committerNat Lasseter <nat.lasseter@york.ac.uk>2024-01-22 10:23:58 +0000
commita79414bcf14d17c58e040a7b8524f7bd8f7e5e03 (patch)
tree4f2f232aca568711ecb35caa3444b54f4dfa4361 /stltogl
Migrate from gists
Diffstat (limited to 'stltogl')
-rw-r--r--stltogl21
1 files changed, 21 insertions, 0 deletions
diff --git a/stltogl b/stltogl
new file mode 100644
index 0000000..5c75287
--- /dev/null
+++ b/stltogl
@@ -0,0 +1,21 @@
+"Get rid of most of the bumpf in the file
+:g/solid/d
+:g/loop/d
+:g/endfacet/d
+"Get rid of leading and trailing spaces
+:%s/^ *//g
+:%s/ *$//g
+"Unify spaces
+:%s/ \+/ /g
+"Rewrite each facet normal into a glNormal3f
+:%s/facet normal /glNormal3f(/g
+"Rewrite each vertex into a glVertex3f
+:%s/vertex /glVertex3f(/g
+"Rewrite line endings into function endings
+"and separate arguments
+:%s/$/);/g
+:%s/ /, /g
+"Colour each vertex
+:%s/\v(glV.*\n)(glV.*\n)(glV.*\n)/glColor3f(1.0, 0.0, 0.0); \1glColor3f(0.0, 1.0, 0.0); \2glColor3f(0.0, 0.0, 1.0); \3/g
+"Get rid of blank lines
+:g/^$/d