Skip to content

Commit

Permalink
Correct y vs. z translation; show export when shape selected, not object
Browse files Browse the repository at this point in the history
  • Loading branch information
Qwertygiy committed Jan 23, 2020
1 parent 419c187 commit df3144a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions shapes_operator/tera_shape_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class TERA_SHAPE_OT_shape_exporter(bpy.types.Operator, bpy_extras.io_utils.Expor

@classmethod
def poll(cls, context):
return context.active_object != None
return 0 < context.scene.tera_shape_select_index < len(bpy.data.objects)

def meshify(self, bm):
mesh = bpy.data.meshes.new('temp')
Expand All @@ -80,9 +80,9 @@ def meshify(self, bm):

for vert in mesh.vertices:
result['vertices'].append(
NoIndent([-vert.co.x, vert.co.y, vert.co.z]))
NoIndent([-vert.co.x, vert.co.z, vert.co.y]))
result['normals'].append(
NoIndent([-vert.normal.x, vert.normal.y, vert.normal.z]))
NoIndent([-vert.normal.x, vert.normal.z, vert.normal.y]))

uv_active = mesh.uv_layers.active
for layer in uv_active.data:
Expand All @@ -99,7 +99,7 @@ def meshify(self, bm):
def execute(self, context):
path = bpy.path.ensure_ext(self.filepath, self.filename_ext)

if (context.scene.tera_shape_select_index > 0 and context.scene.tera_shape_select_index < len(bpy.data.objects)):
if (0 < context.scene.tera_shape_select_index < len(bpy.data.objects)):
selected_object = bpy.data.objects[context.scene.tera_shape_select_index]
shape = selected_object.tera_shape

Expand Down Expand Up @@ -148,8 +148,8 @@ def execute(self, context):
for aabb in shape.aabb:
result['collision']['colliders'].append({
'type': 'AABB',
'position': NoIndent([aabb.origin[0], aabb.origin[1], aabb.origin[2]]),
'extents': NoIndent([aabb.extent[0], aabb.extent[1], aabb.extent[2]])
'position': NoIndent([aabb.origin[0], aabb.origin[2], aabb.origin[1]]),
'extents': NoIndent([aabb.extent[0], aabb.extent[2], aabb.extent[1]])
})

if (hasColliders == True):
Expand Down
2 changes: 1 addition & 1 deletion shapes_operator/tera_shape_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def execute(self, context):
p = collider['position']
r = collider['radius']
bpy.ops.mesh.primitive_uv_sphere_add(
segments=16, location=(-p[0], p[1], p[2]), size=r)
segments=16, location=(-p[0], p[2], p[1]), size=r)
bpy.ops.object.transform_apply(
location=True, scale=True, rotation=True)

Expand Down

0 comments on commit df3144a

Please sign in to comment.