Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
paddywwoof committed Sep 5, 2017
2 parents e972d42 + 6c89009 commit 4936052
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 16 deletions.
9 changes: 9 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 47 additions & 11 deletions pi3d/Shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -776,7 +813,6 @@ def __getstate__(self):
'buf': self.buf,
'textures': self.textures,
'shader': self.shader

}

def __setstate__(self, state):
Expand Down
14 changes: 9 additions & 5 deletions pi3d/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""
import time

__version__ = '2.20'
__version__ = '2.21'
year = time.localtime().tm_year

STARTUP_MESSAGE = """
Expand Down Expand Up @@ -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
Expand All @@ -95,9 +96,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')
Expand Down

0 comments on commit 4936052

Please sign in to comment.