extract method rotateVertices
xxx extract method
This commit is contained in:
parent
5e2b792591
commit
c39f2c19ee
@ -245,48 +245,47 @@ 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 rotation is not None:
|
|
||||||
origin = rotation["origin"]
|
|
||||||
axis = rotation["axis"]
|
|
||||||
angle = rotation["angle"]
|
|
||||||
rescale = rotation.get("rescale", False)
|
|
||||||
matrix = npRotate(axis, angle, rescale)
|
|
||||||
ox, oy, oz = origin
|
|
||||||
origin = ox/16., oy/16., oz/16.
|
|
||||||
|
|
||||||
xyzuvc[:, :3] -= origin
|
|
||||||
xyz = xyzuvc[:, :3].transpose()
|
|
||||||
xyzuvc[:, :3] = (matrix[:3, :3] * xyz).transpose()
|
|
||||||
xyzuvc[:, :3] += origin
|
|
||||||
|
|
||||||
rotate = variantXrot or variantYrot or variantZrot
|
|
||||||
if rotate:
|
|
||||||
matrix = numpy.matrix(numpy.identity(4))
|
|
||||||
if variantYrot:
|
|
||||||
matrix *= npRotate("y", -variantYrot)
|
|
||||||
if variantXrot:
|
|
||||||
matrix *= npRotate("x", -variantXrot)
|
|
||||||
if variantZrot:
|
|
||||||
matrix *= npRotate("z", -variantZrot)
|
|
||||||
xyzuvc[:, :3] -= 0.5, 0.5, 0.5
|
|
||||||
xyz = xyzuvc[:, :3].transpose()
|
|
||||||
xyzuvc[:, :3] = (matrix[:3, :3] * xyz).transpose()
|
|
||||||
xyzuvc[:, :3] += 0.5, 0.5, 0.5
|
|
||||||
|
|
||||||
if shade:
|
if shade:
|
||||||
xyzuvc.view('uint8')[:, 20:] = faceShades[face]
|
xyzuvc.view('uint8')[:, 20:] = faceShades[face]
|
||||||
else:
|
else:
|
||||||
xyzuvc.view('uint8')[:, 20:] = 0xff
|
xyzuvc.view('uint8')[:, 20:] = 0xff
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cookedQuads.append((face, xyzuvc, cullface))
|
cookedQuads.append((face, xyzuvc, cullface))
|
||||||
|
|
||||||
cookedModels[nameAndState] = cookedQuads
|
cookedModels[nameAndState] = cookedQuads
|
||||||
|
|
||||||
self.cookedModels = cookedModels
|
self.cookedModels = cookedModels
|
||||||
|
|
||||||
|
def rotateVertices(self, rotation, variantXrot, variantYrot, variantZrot, xyzuvc):
|
||||||
|
if rotation is not None:
|
||||||
|
origin = rotation["origin"]
|
||||||
|
axis = rotation["axis"]
|
||||||
|
angle = rotation["angle"]
|
||||||
|
rescale = rotation.get("rescale", False)
|
||||||
|
matrix = npRotate(axis, angle, rescale)
|
||||||
|
ox, oy, oz = origin
|
||||||
|
origin = ox / 16., oy / 16., oz / 16.
|
||||||
|
|
||||||
|
xyzuvc[:, :3] -= origin
|
||||||
|
xyz = xyzuvc[:, :3].transpose()
|
||||||
|
xyzuvc[:, :3] = (matrix[:3, :3] * xyz).transpose()
|
||||||
|
xyzuvc[:, :3] += origin
|
||||||
|
rotate = variantXrot or variantYrot or variantZrot
|
||||||
|
if rotate:
|
||||||
|
matrix = numpy.matrix(numpy.identity(4))
|
||||||
|
if variantYrot:
|
||||||
|
matrix *= npRotate("y", -variantYrot)
|
||||||
|
if variantXrot:
|
||||||
|
matrix *= npRotate("x", -variantXrot)
|
||||||
|
if variantZrot:
|
||||||
|
matrix *= npRotate("z", -variantZrot)
|
||||||
|
xyzuvc[:, :3] -= 0.5, 0.5, 0.5
|
||||||
|
xyz = xyzuvc[:, :3].transpose()
|
||||||
|
xyzuvc[:, :3] = (matrix[:3, :3] * xyz).transpose()
|
||||||
|
xyzuvc[:, :3] += 0.5, 0.5, 0.5
|
||||||
|
|
||||||
faceRotations = (
|
faceRotations = (
|
||||||
(
|
(
|
||||||
faces.FaceYIncreasing,
|
faces.FaceYIncreasing,
|
||||||
|
Reference in New Issue
Block a user