From 54522ac3297e95697df3ec30544ddd1a59ab3215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Wed, 25 Jul 2018 14:26:47 +0200 Subject: [PATCH] ENNTool/ENNTool{,GL{CanvasPanel,TTFTexture}}.py: adds [-c x,y,z] & [-t float]. --- ENNTool/ENNTool.py | 23 +++++++++++++++++------ ENNTool/ENNToolGLCanvasPanel.py | 6 +++--- ENNTool/ENNToolGLTTFTexture.py | 3 --- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/ENNTool/ENNTool.py b/ENNTool/ENNTool.py index 907a794..9f13b4e 100755 --- a/ENNTool/ENNTool.py +++ b/ENNTool/ENNTool.py @@ -39,11 +39,12 @@ class ENNToolApp(object): def parseArgv(self, argv): def usage(argv0): print("usage: {}".format(os.path.basename(argv0)), file=sys.stderr) - print(" [-A] [-f fps] [-h] [-o fname]".format(os.path.basename(argv0)), file=sys.stderr) + print(" [-a] [-c x,y,z] [-f fps] [-h] [-o fname]".format(os.path.basename(argv0)), file=sys.stderr) print(" [-p] [-r WxH] [-R WxH] [-s fname]", file=sys.stderr) - print(" [-S] [-v] [--] fname..", file=sys.stderr) + print(" [-S] [-t float] [-v] [--] fname..", file=sys.stderr) print("", file=sys.stderr) print(" -a........: select animation mode (UNIMPLEMENTED)", file=sys.stderr) + print(" -c x,y,z..: specify camera position", file=sys.stderr) print(" -f fps....: set video FPS; defaults to 25", file=sys.stderr) print(" -h........: show this screen", file=sys.stderr) print(" -o fname..: output video filename; extension determines video type", file=sys.stderr) @@ -52,9 +53,10 @@ class ENNToolApp(object): print(" -R WxH....: set MiRCART cube resolution; defaults to 0.1x0.2", file=sys.stderr) print(" -s fname..: input script filename", file=sys.stderr) print(" -S........: select scrolling mode", file=sys.stderr) + print(" -t float..: scrolling rate in Y coordinates per frame", file=sys.stderr) print(" -v........: be verbose", file=sys.stderr) try: - optlist, argv = getopt(argv[1:], "Af:ho:pr:R:s:Sv") + optlist, argv = getopt(argv[1:], "Ac:f:ho:pr:R:s:St:v") optdict = dict(optlist) if "-h" in optdict: @@ -69,6 +71,8 @@ class ENNToolApp(object): if not "-R" in optdict: optdict["-R"] = "0.1x0.2" + if "-c" in optdict: + optdict["-c"] = [float(r) for r in optdict["-c"].split(",")][0:3] if "-r" in optdict: optdict["-r"] = [int(r) for r in optdict["-r"].split("x")][0:2] if "-R" in optdict: @@ -87,9 +91,13 @@ class ENNToolApp(object): print("\r[{:<50}] {}%".format( ("=" * int(progressDiv * 50)), int(progressDiv * 100)), end=endChar) # }}} - # {{{ modeScroll(self, argv, optdict, GLVideoWriter, GLpanel, GLpanel, fps=25, scrollRate=0.1): XXX - def modeScroll(self, argv, optdict, GLVideoWriter, GLcanvas, GLpanel, fps=25, scrollRate=0.1): + # {{{ modeScroll(self, argv, optdict, GLVideoWriter, GLpanel, GLpanel, fps=25): XXX + def modeScroll(self, argv, optdict, GLVideoWriter, GLcanvas, GLpanel, fps=25): MiRCART = [] + if "-t" in optdict: + scrollRate = float(optdict["-t"]) + else: + scrollRate = 0.1 if "-v" in optdict: time0 = time.time() for inFileArg in argv: @@ -150,7 +158,10 @@ class ENNToolApp(object): videoFps, videoPath = int(optdict["-f"]), optdict["-o"] if "-o" in optdict else None GLpanel = ENNToolGLPanel(appPanelSkin, size=optdict["-r"], parentFrame=self.appFrame) GLcanvas = ENNToolGLCanvas(GLpanel, optdict["-r"]) - GLcanvas.initOpenGL() + if "-c" in optdict: + GLcanvas.initOpenGL(cameraPos=optdict["-c"]) + else: + GLcanvas.initOpenGL() GLcanvas.initShaders() GLVideoWriter = ENNToolGLVideoWriter(videoPath, GLpanel.GetClientSize(), videoFps=videoFps) diff --git a/ENNTool/ENNToolGLCanvasPanel.py b/ENNTool/ENNToolGLCanvasPanel.py index 63d8c4e..5b5c22d 100644 --- a/ENNTool/ENNToolGLCanvasPanel.py +++ b/ENNTool/ENNToolGLCanvasPanel.py @@ -20,8 +20,8 @@ from OpenGL.GL import shaders import ctypes, wx, wx.glcanvas class ENNToolGLCanvas(wx.glcanvas.GLCanvas): - # {{{ initOpenGL(self): XXX - def initOpenGL(self): + # {{{ initOpenGL(self, cameraPos=(-5.0, 3.0, -5)): XXX + def initOpenGL(self, cameraPos=(-5.0, 3.0, -5)): self.glContext = wx.glcanvas.GLContext(self) self.SetCurrent(self.glContext) @@ -31,7 +31,7 @@ class ENNToolGLCanvas(wx.glcanvas.GLCanvas): glLoadIdentity(); glFrustum(-1, 1, -1, 1, 1, 100); glMatrixMode(GL_MODELVIEW) glEnable(GL_DEPTH_TEST) - glTranslatef(-5.0, 3.0, -5) + glTranslatef(*cameraPos) # }}} # {{{ initShaders(self): XXX def initShaders(self): diff --git a/ENNTool/ENNToolGLTTFTexture.py b/ENNTool/ENNToolGLTTFTexture.py index e56c838..844f05e 100644 --- a/ENNTool/ENNToolGLTTFTexture.py +++ b/ENNTool/ENNToolGLTTFTexture.py @@ -48,9 +48,6 @@ class ENNToolGLTTFTexture(object): underLine = False if newChar[3] != " ": pilImageDraw.text(curPos, newChar[3], (255, 255, 255, 255), pilFont) - elif newChar[0] == newChar[1]: - pilImageDraw.rectangle((*curPos, curPos[0] + pilFontSize[0], curPos[1] + pilFontSize[1] - 1), - fill=(255, 255, 255, 255)) if underLine and False: pilImageDraw.line( xy=(curPos[0], curPos[1] + (pilFontSize[1] - 2),