extract method rotateVertices

xxx extract method
This commit is contained in:
David Vierra 2015-01-03 13:02:59 -10:00
parent 5e2b792591
commit c39f2c19ee

View File

@ -245,7 +245,20 @@ class BlockModels(object):
if variantYrot: if variantYrot:
cullface = rotateFace(cullface, 1, variantYrot) cullface = rotateFace(cullface, 1, variantYrot)
self.rotateVertices(rotation, variantXrot, variantYrot, variantZrot, xyzuvc)
if shade:
xyzuvc.view('uint8')[:, 20:] = faceShades[face]
else:
xyzuvc.view('uint8')[:, 20:] = 0xff
cookedQuads.append((face, xyzuvc, cullface))
cookedModels[nameAndState] = cookedQuads
self.cookedModels = cookedModels
def rotateVertices(self, rotation, variantXrot, variantYrot, variantZrot, xyzuvc):
if rotation is not None: if rotation is not None:
origin = rotation["origin"] origin = rotation["origin"]
axis = rotation["axis"] axis = rotation["axis"]
@ -253,13 +266,12 @@ class BlockModels(object):
rescale = rotation.get("rescale", False) rescale = rotation.get("rescale", False)
matrix = npRotate(axis, angle, rescale) matrix = npRotate(axis, angle, rescale)
ox, oy, oz = origin ox, oy, oz = origin
origin = ox/16., oy/16., oz/16. origin = ox / 16., oy / 16., oz / 16.
xyzuvc[:, :3] -= origin xyzuvc[:, :3] -= origin
xyz = xyzuvc[:, :3].transpose() xyz = xyzuvc[:, :3].transpose()
xyzuvc[:, :3] = (matrix[:3, :3] * xyz).transpose() xyzuvc[:, :3] = (matrix[:3, :3] * xyz).transpose()
xyzuvc[:, :3] += origin xyzuvc[:, :3] += origin
rotate = variantXrot or variantYrot or variantZrot rotate = variantXrot or variantYrot or variantZrot
if rotate: if rotate:
matrix = numpy.matrix(numpy.identity(4)) matrix = numpy.matrix(numpy.identity(4))
@ -274,19 +286,6 @@ class BlockModels(object):
xyzuvc[:, :3] = (matrix[:3, :3] * xyz).transpose() xyzuvc[:, :3] = (matrix[:3, :3] * xyz).transpose()
xyzuvc[:, :3] += 0.5, 0.5, 0.5 xyzuvc[:, :3] += 0.5, 0.5, 0.5
if shade:
xyzuvc.view('uint8')[:, 20:] = faceShades[face]
else:
xyzuvc.view('uint8')[:, 20:] = 0xff
cookedQuads.append((face, xyzuvc, cullface))
cookedModels[nameAndState] = cookedQuads
self.cookedModels = cookedModels
faceRotations = ( faceRotations = (
( (
faces.FaceYIncreasing, faces.FaceYIncreasing,