Skip to content

Commit

Permalink
1.0.3: Added better armature warning
Browse files Browse the repository at this point in the history
- Fixed uuid generation for filenames
- Added Better warnings if missing armature or having too many in a
scene
  • Loading branch information
Menithal committed Apr 30, 2018
1 parent 01b7ae2 commit 1c73448
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 7 deletions.
2 changes: 1 addition & 1 deletion hifi_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
bl_info = {
"name": "HiFi Blender Add-on",
"author": "Matti 'Menithal' Lahtinen",
"version": (1,0,2),
"version": (1,0,3),
"blender": (2,7,7),
"location": "File > Import-Export, Materials, Armature",
"description": "Blender tools to allow for easier Content creation for High Fidelity",
Expand Down
37 changes: 34 additions & 3 deletions hifi_tools/files/fst/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
)
import hifi_tools.files.fst.writer as FSTWriter

from hifi_tools.utils.bones import find_armature
from hifi_tools.utils.bones import find_armatures


class HifiBoneOperator(bpy.types.Operator):
Expand Down Expand Up @@ -97,6 +97,33 @@ def draw(self, context):
row.label("Avatar Export Failed. Please Check the console logs")


class HifiExportErrorNoArmatureOperator(bpy.types.Operator):
bl_idname = "hifi_error_no_armature.export"
bl_label = ""
bl_options = {'REGISTER', 'INTERNAL'}

@classmethod
def poll(cls, context):
return True

def invoke(self, context, even):
print("Invoked")
wm = context.window_manager
return wm.invoke_popup(self, width=400, height=600)

def execute(self, context):
return {'FINISHED'}

def draw(self, context):
layout = self.layout

row = layout.row()
row.label(text="Warning:", icon="ERROR")
row = layout.row()
row.label("Avatar Export Failed. Please have 1 armature on selected")



class HifiExportSucccessOperator(bpy.types.Operator):
bl_idname = "hifi_success.export"
bl_label = ""
Expand Down Expand Up @@ -169,12 +196,16 @@ def execute(self, context):

self.scale = 1 # Add scene scale here

armature = find_armature(to_export)
armatures = find_armatures(to_export)
# armature = find_armature(to_export)
if len(armatures) > 1 or len(armatures) == 0:
bpy.ops.hifi_error_no_armature.export('INVOKE_DEFAULT')
return {'CANCELLED'}

val = FSTWriter.fst_export(self, to_export)
print(val)
if val == {'FINISHED'}:
if len(armature.data.edit_bones) > 100:
if len(armatures[0].data.edit_bones) > 100:
bpy.ops.hifi_warn.bone_count('INVOKE_DEFAULT')
else:
bpy.ops.hifi_success.export('INVOKE_DEFAULT')
Expand Down
6 changes: 3 additions & 3 deletions hifi_tools/files/fst/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"RightHand": "jointRightHand",
"LeftHand": "jointLeftHand",
"Neck": "jointNeck",
"LeftEye": "jointLeftEye",
"RightEye": "jointRightEye",
"LeftEye": "jointEyeLeft",
"RightEye": "jointEyeRight",
"Spine": "jointLean"
}

Expand All @@ -55,7 +55,7 @@
def fst_export(context, selected):

# file = open
uuid_gen = uuid.uuid5(uuid.NAMESPACE_DNS, context.name)
uuid_gen = uuid.uuid5(uuid.NAMESPACE_DNS, context.filepath)
scene_id = str(uuid_gen)

print("Exporting file to filepath", context.filepath)
Expand Down
9 changes: 9 additions & 0 deletions hifi_tools/utils/bones.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ def remove_all_actions():
bpy.data.actions.remove(action)


def find_armatures(selection):
armatures = []
for selected in selection:
if selected.type == "ARMATURE":
armatures.append(selected)

return armatures


def find_armature(selection):
for selected in selection:
if selected.type == "ARMATURE":
Expand Down

0 comments on commit 1c73448

Please sign in to comment.