Skip to content

Commit

Permalink
Merge pull request #12 from Menithal/development
Browse files Browse the repository at this point in the history
0.6.4: Added Error Messages
  • Loading branch information
Menithal authored Mar 17, 2018
2 parents 1c79b84 + 019a5eb commit fe89661
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 13 deletions.
4 changes: 3 additions & 1 deletion __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": (0,6,3),
"version": (0,6,4),
"blender": (2,7,7),
"location": "File > Import-Export, Materials, Armature",
"description": "Blender tools to allow for easier Content creation for High Fidelity",
Expand Down Expand Up @@ -79,6 +79,7 @@ def menu_func_export(self,context):
def register():
bpy.utils.register_class(HifiJsonOperator)
bpy.utils.register_class(HifiJsonWriter)
bpy.utils.register_class(HifiATPReminderOperator)
bpy.types.INFO_MT_file_import.append(menu_func_import)
bpy.types.INFO_MT_file_export.append(menu_func_export)
material_ui_register()
Expand All @@ -87,6 +88,7 @@ def register():
def unregister():
bpy.utils.unregister_class(HifiJsonOperator)
bpy.utils.unregister_class(HifiJsonWriter)
bpy.utils.unregister_class(HifiATPReminderOperator)
bpy.types.INFO_MT_file_import.remove(menu_func_import)
bpy.types.INFO_MT_file_export.remove(menu_func_export)
material_ui_unregister()
Expand Down
12 changes: 6 additions & 6 deletions hifi_armature_repose.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

from math import pi
from .hifi_armature_data import structure as base_armature

# This is unit tested to be correct.


def correct_scale_rotation(obj, rotation):
current_context = bpy.context.area.type
bpy.context.area.type = 'VIEW_3D'
Expand Down Expand Up @@ -63,7 +61,7 @@ def navigate_armature(data, current_rest_node, world_matrix, parent, parent_node
def retarget_armature(options):

armature = bpy.context.object
if armature.type == "ARMATURE":
if armature != None and armature.type == "ARMATURE":
# Center Children First
bpy.ops.object.mode_set(mode='OBJECT')

Expand Down Expand Up @@ -124,7 +122,9 @@ def retarget_armature(options):
bpy.ops.object.mode_set(mode='POSE')
print("Apply Armature")
bpy.ops.pose.armature_apply()



bpy.ops.object.mode_set(mode='OBJECT')

else:
#Judas proofing:
print("No Armature, select, throw an exception")
raise Exception("You must select an armature to continue")
47 changes: 42 additions & 5 deletions hifi_armature_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,36 +142,73 @@ def execute(self, context):

class HifiArmatureRetargetPoseOperator(bpy.types.Operator):
bl_idname = "armature_toolset_retarget.hifi"
bl_label = "Retarget Avatar Pose / Fix Avatar"
bl_label = "Retarget Avatar Pose / Fix Avatar Scale / Rotation"

bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
bl_category = "High Fidelity"

def execute(self, context):
retarget_armature({'apply': True})
try:
retarget_armature({'apply': True})
except Exception:
bpy.ops.hifi_error.armature_not_selected('INVOKE_DEFAULT')
return {'CANCELLED'}

return {'FINISHED'}


class HifiArmaturePoseOperator(bpy.types.Operator):
bl_idname = "armature_toolset_pose.hifi"
bl_label = "Test with Hifi Avatar rest Pose"
bl_label = "Test Avatar Rest Pose"

bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
bl_category = "High Fidelity"

def execute(self, context):
retarget_armature({'apply': False})
try:
retarget_armature({'apply': False})
except Exception:
bpy.ops.hifi_error.armature_not_selected('INVOKE_DEFAULT')
return {'CANCELLED'}

return {'FINISHED'}


class HifiReminderOperator(bpy.types.Operator):
bl_idname = "hifi_error.armature_not_selected"
bl_label = "You must select an armature first prior to pressing the button"
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=200)

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(self.bl_label)



classes = [
HifiArmaturePanel,
HifiArmatureCreateOperator,
HifiArmatureRetargetPoseOperator,
HifiArmaturePoseOperator
HifiArmaturePoseOperator,
HifiReminderOperator
]

def armature_create_menu_func(self,context):
Expand Down
33 changes: 32 additions & 1 deletion hifi_json_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,9 @@ def execute(self, context):
raise Exception("filepath not set")

if not self.url_override and not self.atp:
raise Exception("You must Use ATP or Set the Marketplace / base URL to make sure that the content can be reached after you upload it. ATP currently not supported")
bpy.ops.hifi_error.atp_or_override_not_in_use('INVOKE_DEFAULT')
return {'CANCELLED'}
# raise Exception("You must Use ATP or Set the Marketplace / base URL to make sure that the content can be reached after you upload it. ATP currently not supported")

current_scene = bpy.context.scene
read_scene = current_scene
Expand Down Expand Up @@ -457,3 +459,32 @@ def execute(self, context):

return {'FINISHED'}

class HifiATPReminderOperator(bpy.types.Operator):
bl_idname = "hifi_error.atp_or_override_not_in_use"
bl_label = "You must either select ATP export or override a baseURL for your host (be it marketplace or your own)"
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=300)

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("You must either select ATP export ")
row = layout.row()
row.label(" or override a baseURL for your host")
row = layout.row()
row.label(" (be it marketplace or your own)")

0 comments on commit fe89661

Please sign in to comment.