From a79414bcf14d17c58e040a7b8524f7bd8f7e5e03 Mon Sep 17 00:00:00 2001 From: Nat Lasseter Date: Mon, 22 Jan 2024 10:23:58 +0000 Subject: Migrate from gists --- stltogl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 stltogl (limited to 'stltogl') 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 -- cgit v1.2.3