From 34e3dc3dce9f09c9bf2a8fd9064d9faced8b16d6 Mon Sep 17 00:00:00 2001 From: paddywwoof Date: Wed, 30 Aug 2017 15:07:40 +0100 Subject: [PATCH 1/4] patch error due to change in ctypes.WinDLL() py2.7.12 to 2.7.13 --- pi3d/constants/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pi3d/constants/__init__.py b/pi3d/constants/__init__.py index d3ef0f59..f49f5d88 100644 --- a/pi3d/constants/__init__.py +++ b/pi3d/constants/__init__.py @@ -69,12 +69,13 @@ def _load_library(name, dll_type="C"): if name: try: if dll_type == "Win": - return ctypes.WinDLL(name) + return ctypes.WinDLL(str(name)) else: return ctypes.CDLL(name) except: - from pi3d.util import Log - Log.logger(__name__).error("Couldn't load library %s", name) + import logging + LOGGER = logging.getLogger(__name__) + LOGGER.error("Couldn't load library %s", name) def _linux(): platform = PLATFORM_LINUX From d808b684760ab6bc1d66058d0ab42b3b1fe6187c Mon Sep 17 00:00:00 2001 From: Giles Thomas Date: Sun, 3 Sep 2017 18:22:04 +0100 Subject: [PATCH 2/4] Fix to allow for GLES shared library rename in Raspbian Stretch release --- pi3d/constants/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pi3d/constants/__init__.py b/pi3d/constants/__init__.py index d3ef0f59..1cedacb9 100644 --- a/pi3d/constants/__init__.py +++ b/pi3d/constants/__init__.py @@ -95,9 +95,12 @@ def _linux(): openegl = _load_library('/system/lib/libEGL.so') else: import os - if os.path.isfile('/opt/vc/lib/libGLESv2.so'): # raspbian + if os.path.isfile('/opt/vc/lib/libGLESv2.so'): # raspbian before stretch release opengles = _load_library('/opt/vc/lib/libGLESv2.so') openegl = _load_library('/opt/vc/lib/libEGL.so') + elif os.path.isfile('/opt/vc/lib/libbrcmGLESv2.so'): # raspbian after stretch release + opengles = _load_library('/opt/vc/lib/libbrcmGLESv2.so') + openegl = _load_library('/opt/vc/lib/libbrcmEGL.so') elif os.path.isfile('/usr/lib/libGLESv2.so'): # ubuntu MATE (but may catch others - monitor problems) opengles = _load_library('/usr/lib/libGLESv2.so') openegl = _load_library('/usr/lib/libEGL.so') From 25a0973c74c9977b4de25ccc35eec5043f8cc9ff Mon Sep 17 00:00:00 2001 From: paddywwoof Date: Mon, 4 Sep 2017 23:58:56 +0100 Subject: [PATCH 3/4] update version for next release, include xyz properties in Shape and tidy rotation flag initiation --- pi3d/Shape.py | 58 ++++++++++++++++++++++++++++++-------- pi3d/constants/__init__.py | 2 +- 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/pi3d/Shape.py b/pi3d/Shape.py index 082555bb..c32f20b0 100644 --- a/pi3d/Shape.py +++ b/pi3d/Shape.py @@ -130,20 +130,14 @@ def __init_matrices(self): [0.0, self.unif[7], 0.0, 0.0], [0.0, 0.0, self.unif[8], 0.0], [0.0, 0.0, 0.0, 1.0]]) - if self.unif[6] != 1.0 or self.unif[7] != 1.0 or self.unif[8] != 1.0: - self.sclflg = True - else: - self.sclflg = False + self.sclflg = (self.unif[6] != 1.0) or (self.unif[7] != 1.0) or (self.unif[8] != 1.0) """scale""" self.tr2 = np.array([[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [self.unif[9], self.unif[10], self.unif[11], 1.0]]) - if self.unif[9] != 0.0 or self.unif[10] != 0.0 or self.unif[11] != 0.0: - self.tr2flg = True - else: - self.tr2flg = False + self.tr2flg = (self.unif[9] != 0.0) or (self.unif[10] != 0.0) or (self.unif[11] != 0.0) """translate to offset""" self.MFlg = True @@ -517,14 +511,15 @@ def position(self, x, y, z): y position *z* z position - """ + self.tr1[3, 0] = x - self.unif[9] self.tr1[3, 1] = y - self.unif[10] self.tr1[3, 2] = z - self.unif[11] self.unif[0] = x self.unif[1] = y self.unif[2] = z - self.MFlg = True + self.MFlg = True""" + self.xyz = x, y, z def positionX(self, v): """Arguments: @@ -688,6 +683,48 @@ def rotateIncZ(self, v): self.MFlg = True self.rozflg = True + # propteries and setters for the 3D vectors pos, rot, scale, offset + @property + def xyz(self): + return self.unif[0:3] + + @xyz.setter + def xyz(self, val): + self.tr1[3, 0:3] = [val[i] - self.unif[9 + i] for i in range(3)] + self.unif[0:3] = val + self.MFlg = True + + @property + def rxryrz(self): + return self.unif[3:6] + + @rxryrz.setter + def rxryrz(self, val): + self.rotateToX(val[0]) + self.rotateToY(val[1]) + self.rotateToZ(val[2]) + + @property + def sxsysz(self): + return self.unif[0:3] + + @sxsysz.setter + def sxsysz(self, val): + self.scl[[0,1,2],[0,1,2]] = val + self.unif[6:9] = val + self.MFlg = True + self.sclflg = True + + @property + def cxcycz(self): + return self.unif[0:3] + + @cxcycz.setter + def cxcycz(self, val): + self.tr2[3, 0:3] = val + self.unif[9:12] = val + self.MFlg = True + def _lathe(self, path, sides=12, rise=0.0, loops=1.0): """Returns a Buffer object by rotating the points defined in path. @@ -776,7 +813,6 @@ def __getstate__(self): 'buf': self.buf, 'textures': self.textures, 'shader': self.shader - } def __setstate__(self, state): diff --git a/pi3d/constants/__init__.py b/pi3d/constants/__init__.py index 3d1fdbfa..574ea880 100644 --- a/pi3d/constants/__init__.py +++ b/pi3d/constants/__init__.py @@ -5,7 +5,7 @@ """ import time -__version__ = '2.20' +__version__ = '2.21' year = time.localtime().tm_year STARTUP_MESSAGE = """ From 6c890096db65969825819ee8da805db9fac4fa4f Mon Sep 17 00:00:00 2001 From: paddywwoof Date: Tue, 5 Sep 2017 13:30:25 +0100 Subject: [PATCH 4/4] changelog for 2.21 --- ChangeLog.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 0227d7bf..8f19fb8f 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -4,6 +4,15 @@ Tim Skillman, Patrick Gaunt, Tom Ritchford Date Amends +v2.21 +2017-09-05 Bug fixes: Rasbian stretch has renamed libGLES and libEGL so + this is now checked for in constants/__init__.py A change in + ctypes.WinDLL between python 2.7.12 and 2.7.13 means unicode + arguments have to be converted to str (patched back for 2.7.14!) + Improvements: Setting up Shape rotation matrix flags tidier. + properties Shape.xyz rxryrz sxsysz cxcycz added with setters + and getters. + v2.20 2017-07-27 Bug fixes: Removed use of numpy functions not yet available in numpypy (pypy version). Some corrections of Log. Removal