X-Git-Url: https://git.ao2.it/vrm.git/blobdiff_plain/aa602f68ddbdd0dd7dacedb0efaf6430361789aa..ae133d0af9d635758bb88c6fc6383d42b207d02f:/vrm.py?ds=sidebyside diff --git a/vrm.py b/vrm.py index 67bcf3a..84e4588 100755 --- a/vrm.py +++ b/vrm.py @@ -83,6 +83,8 @@ __bpydoc__ = """\ # * Remove the real file opening in the abstract VectorWriter # * View frustum clipping # * Scene clipping done using bounding box instead of object center +# * Fix camera type selection for blender>2.43 (Thanks to Thomas Lachmann) +# * Compatibility with python 2.3 # # --------------------------------------------------------------------- @@ -92,6 +94,13 @@ from Blender.Mathutils import * from math import * import sys, time +def uniq(alist): + tmpdict = dict() + return [tmpdict.setdefault(e,e) for e in alist if e not in tmpdict] + # in python > 2.4 we ca use the following + #return [ u for u in alist if u not in locals()['_[1]'] ] + + # Constants EPS = 10e-5 @@ -683,9 +692,13 @@ class HSR: negVertList.append(V1) - # uniq - posVertList = [ u for u in posVertList if u not in locals()['_[1]'] ] - negVertList = [ u for u in negVertList if u not in locals()['_[1]'] ] + # uniq for python > 2.4 + #posVertList = [ u for u in posVertList if u not in locals()['_[1]'] ] + #negVertList = [ u for u in negVertList if u not in locals()['_[1]'] ] + + # a more portable way + posVertList = uniq(posVertList) + negVertList = uniq(negVertList) # If vertex are all on the same half-space, return @@ -887,13 +900,22 @@ class Projector: fovy = atan(0.5/aspect/(camera.lens/32)) fovy = fovy * 360.0/pi - + + + if Blender.Get('version') < 243: + camPersp = 0 + camOrtho = 1 + else: + camPersp = 'persp' + camOrtho = 'ortho' + # What projection do we want? - if camera.type == 0: + if camera.type == camPersp: mP = self._calcPerspectiveMatrix(fovy, aspect, near, far) - elif camera.type == 1: - mP = self._calcOrthoMatrix(fovy, aspect, near, far, scale) + elif camera.type == camOrtho: + mP = self._calcOrthoMatrix(fovy, aspect, near, far, scale) + # View transformation cam = Matrix(cameraObj.getInverseMatrix()) cam.transpose()