Skip to content
This repository has been archived by the owner on Apr 23, 2022. It is now read-only.

Commit

Permalink
Merge pull request #3 from lipki/debug
Browse files Browse the repository at this point in the history
debug
  • Loading branch information
freundTech committed Dec 14, 2014
2 parents 9170eb3 + b92b63b commit 6304628
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions blender2minecraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
nl = os.linesep
tab = " "

particle = ""
toRound = 2


Expand Down Expand Up @@ -97,9 +96,14 @@ def getDir(face):
return ["west", [y, z]]
raise Exception("This should never happen")

class attrdict(dict):
def __init__(self, *args, **kwargs):
dict.__init__(self, *args, **kwargs)
self.__dict__ = self

def write_to_file(context, filepath, include_textures, ambientocclusion, firsttrans, firstscale, firstrot, thirdtrans, thirdscale, thirdrot, invtrans, invscale, invrot):
textures = []
particle = ""
scene = context.scene
objects = scene.objects
file = open(filepath,'w', encoding='utf-8')
Expand Down Expand Up @@ -203,10 +207,12 @@ def write_to_file(context, filepath, include_textures, ambientocclusion, firsttr
if len(face.loops) == 4:
direction, toUse = getDir(face)

uvs = []
for i in range(0, len(face.loops)):
uvs.append([face.loops[i][uv_layer].uv[x] * 16, face.loops[i][uv_layer].uv[y] * 16])

try:
uvs = []
for i in range(0, len(face.loops)):
uvs.append([face.loops[i][uv_layer].uv[x] * 16, face.loops[i][uv_layer].uv[y] * 16])
except AttributeError:
uvs = [[16,16],[ 0,16],[ 0, 0],[16, 0]]

max, min = getMaxMin(uvs, [x, y])

Expand Down Expand Up @@ -292,7 +298,11 @@ def write_to_file(context, filepath, include_textures, ambientocclusion, firsttr
print(rot)
print(mirror)

image = data.uv_textures.active.data[face.index].image
try:
image = data.uv_textures.active.data[face.index].image
except AttributeError:
image = attrdict(name=["texture"], filepath="")

name = [""]
for c in image.name:
if c != '.':
Expand Down Expand Up @@ -713,7 +723,7 @@ def execute(self, context):

# Only needed if you want to add into a dynamic menu
def menu_func_export(self, context):
self.layout.operator(ExportBlockModel.bl_idname, text="Export to Minecraft")
self.layout.operator(ExportBlockModel.bl_idname, text="Minecraft model (.json)")


def register():
Expand Down

0 comments on commit 6304628

Please sign in to comment.