extract method buildBoxQuads
This commit is contained in:
parent
1b766e5fd9
commit
5e2b792591
@ -154,41 +154,8 @@ class BlockModels(object):
|
|||||||
allQuads = []
|
allQuads = []
|
||||||
|
|
||||||
for element in allElements:
|
for element in allElements:
|
||||||
shade = element.get("shade", True)
|
quads = self.buildBoxQuads(element, name, textureVars, variantXrot, variantYrot, variantZrot)
|
||||||
fromPoint = Vector(*element["from"])
|
allQuads.extend(quads)
|
||||||
toPoint = Vector(*element["to"])
|
|
||||||
fromPoint /= 16.
|
|
||||||
toPoint /= 16.
|
|
||||||
box = FloatBox(fromPoint, maximum=toPoint)
|
|
||||||
|
|
||||||
for face, info in element["faces"].iteritems():
|
|
||||||
face = facesByCardinal[face]
|
|
||||||
texture = info["texture"]
|
|
||||||
cullface = info.get("cullface")
|
|
||||||
|
|
||||||
uv = info.get("uv", [0, 0, 16, 16])
|
|
||||||
|
|
||||||
lastvar = texture
|
|
||||||
|
|
||||||
# resolve texture variables
|
|
||||||
for i in range(30):
|
|
||||||
if texture is None:
|
|
||||||
raise ValueError("Texture variable %s is not assigned." % lastvar)
|
|
||||||
elif texture[0] == "#":
|
|
||||||
lastvar = texture
|
|
||||||
texture = textureVars[texture[1:]]
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
raise ValueError("Texture variable loop detected!")
|
|
||||||
|
|
||||||
self.firstTextures.setdefault(name, texture)
|
|
||||||
self._textureNames.add(texture)
|
|
||||||
allQuads.append((box, face,
|
|
||||||
texture, uv, cullface,
|
|
||||||
shade, element.get("rotation"), info.get("rotation"),
|
|
||||||
variantXrot, variantYrot, variantZrot))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -199,9 +166,43 @@ class BlockModels(object):
|
|||||||
allElements, textureVars)
|
allElements, textureVars)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# for name in self.modelQuads:
|
def buildBoxQuads(self, element, name, textureVars, variantXrot, variantYrot, variantZrot):
|
||||||
# log.info("Quads for %s:\n%s\n", name, self.modelQuads[name])
|
quads = []
|
||||||
# raise SystemExit
|
shade = element.get("shade", True)
|
||||||
|
fromPoint = Vector(*element["from"])
|
||||||
|
toPoint = Vector(*element["to"])
|
||||||
|
fromPoint /= 16.
|
||||||
|
toPoint /= 16.
|
||||||
|
box = FloatBox(fromPoint, maximum=toPoint)
|
||||||
|
for face, info in element["faces"].iteritems():
|
||||||
|
face = facesByCardinal[face]
|
||||||
|
texture = info["texture"]
|
||||||
|
cullface = info.get("cullface")
|
||||||
|
|
||||||
|
uv = info.get("uv", [0, 0, 16, 16])
|
||||||
|
|
||||||
|
lastvar = texture
|
||||||
|
|
||||||
|
# resolve texture variables
|
||||||
|
for i in range(30):
|
||||||
|
if texture is None:
|
||||||
|
raise ValueError("Texture variable %s is not assigned." % lastvar)
|
||||||
|
elif texture[0] == "#":
|
||||||
|
lastvar = texture
|
||||||
|
texture = textureVars[texture[1:]]
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
raise ValueError("Texture variable loop detected!")
|
||||||
|
|
||||||
|
self.firstTextures.setdefault(name, texture)
|
||||||
|
self._textureNames.add(texture)
|
||||||
|
quads.append((box, face,
|
||||||
|
texture, uv, cullface,
|
||||||
|
shade, element.get("rotation"), info.get("rotation"),
|
||||||
|
variantXrot, variantYrot, variantZrot))
|
||||||
|
|
||||||
|
return quads
|
||||||
|
|
||||||
def getTextureNames(self):
|
def getTextureNames(self):
|
||||||
return iter(self._textureNames)
|
return iter(self._textureNames)
|
||||||
|
Reference in New Issue
Block a user