diff --git a/io_export_cryblend/__init__.py b/io_export_cryblend/__init__.py index 77f480f..d497f6a 100644 --- a/io_export_cryblend/__init__.py +++ b/io_export_cryblend/__init__.py @@ -58,9 +58,9 @@ import bpy from io_export_cryblend import add, export, exceptions, utils -from bpy.props import BoolProperty, EnumProperty, FloatVectorProperty, \ +from bpy.props import BoolProperty, EnumProperty, FloatVectorProperty, \ FloatProperty, IntProperty, StringProperty -from bpy.types import Menu, Panel +from bpy.types import Menu, Panel from bpy_extras.io_utils import ExportHelper from io_export_cryblend.configuration import Configuration from io_export_cryblend.outPipe import cbPrint @@ -95,6 +95,7 @@ def execute(self, context): class FindRC(bpy.types.Operator, PathSelectTemplate): + '''Select the Resource Compiler executable.''' bl_label = "Find The Resource Compiler" @@ -113,6 +114,7 @@ def invoke(self, context, event): class FindTextureRC(bpy.types.Operator, PathSelectTemplate): + '''Select if you are using RC from cryengine \ newer than 3.4.5. Provide RC path from cryengine 3.4.5 \ to be able to export your textures as dds files.''' @@ -125,8 +127,8 @@ class FindTextureRC(bpy.types.Operator, PathSelectTemplate): def process(self, filepath): Configuration.texture_rc_path = "%s" % filepath cbPrint("Found RC at {!r}.".format( - Configuration.texture_rc_path), - 'debug') + Configuration.texture_rc_path), + 'debug') def invoke(self, context, event): self.filepath = Configuration.texture_rc_path @@ -135,6 +137,7 @@ def invoke(self, context, event): class SelectTexturesDirectory(bpy.types.Operator, PathSelectTemplate): + '''This path will be used to create relative path \ for textures in .mtl file.''' @@ -146,8 +149,8 @@ class SelectTexturesDirectory(bpy.types.Operator, PathSelectTemplate): def process(self, filepath): Configuration.texture_directory = "%s" % os.path.dirname(filepath) cbPrint("Textures directory: {!r}.".format( - Configuration.texture_directory), - 'debug') + Configuration.texture_directory), + 'debug') def invoke(self, context, event): self.filepath = Configuration.texture_directory @@ -156,6 +159,7 @@ def invoke(self, context, event): class SaveCryBlendConfiguration(bpy.types.Operator): + '''operator: Saves current CryBlend configuration.''' bl_label = "Save Config File" bl_idname = "config.save" @@ -175,6 +179,7 @@ def invoke(self, context, event): #------------------------------------------------------------------------------ class AddCryExportNode(bpy.types.Operator): + '''Add selected objects to an existing or new CryExportNode''' bl_label = "Add Export Node" bl_idname = "object.add_cry_export_node" @@ -225,6 +230,7 @@ def invoke(self, context, event): class SelectedToCryExportNodes(bpy.types.Operator): + '''Add selected objects to individual CryExportNodes.''' bl_label = "Nodes from Object Names" bl_idname = "object.selected_to_cry_export_nodes" @@ -255,6 +261,7 @@ def draw(self, context): class ApplyTransforms(bpy.types.Operator): + '''Click to apply transforms on selected objects.''' bl_label = "Apply Transforms" bl_idname = "object.apply_transforms" @@ -263,7 +270,10 @@ def execute(self, context): selected = bpy.context.selected_objects if selected: message = "Applying object transforms." - bpy.ops.object.transform_apply(location=True, rotation=True, scale=True) + bpy.ops.object.transform_apply( + location=True, + rotation=True, + scale=True) else: message = "No Object Selected." self.report({'INFO'}, message) @@ -273,8 +283,9 @@ def execute(self, context): #------------------------------------------------------------------------------ # CryEngine-Related Tools #------------------------------------------------------------------------------ - + class AddProxy(bpy.types.Operator): + '''Click to add proxy to selected mesh. The proxy will always display as a box but will \ be converted to the selected shape in CryEngine.''' bl_label = "Add Proxy" @@ -308,7 +319,11 @@ def __add_proxy(self, object_): bpy.ops.object.select_all(action="DESELECT") bpy.ops.mesh.primitive_cube_add() bound_box = bpy.context.active_object - bound_box.name = "{}_{}-proxy".format(object_.name, getattr(self, "type_")) + bound_box.name = "{}_{}-proxy".format( + object_.name, + getattr( + self, + "type_")) bound_box.draw_type = "WIRE" bound_box.dimensions = object_.dimensions bound_box.location = object_.location @@ -322,13 +337,13 @@ def __add_proxy(self, object_): bound_box.data.materials.append(proxy_material) # if (getattr(self, "type_") == "box"): - # bpy.ops.object.add_property("box") + # bpy.ops.object.add_property("box") # elif (getattr(self, "type_") == "capsule"): - # bpy.ops.object.add_property("capsule") + # bpy.ops.object.add_property("capsule") # elif (getattr(self, "type_") == "cylinder"): - # bpy.ops.object.add_property("cylinder") + # bpy.ops.object.add_property("cylinder") # else: # sphere proxy - # bpy.ops.object.add_property("sphere") + # bpy.ops.object.add_property("sphere") bpy.context.scene.cursor_location = old_origin bpy.ops.object.select_all(action="DESELECT") @@ -342,6 +357,7 @@ def __add_proxy(self, object_): class AddBreakableJoint(bpy.types.Operator): + '''Click to add a pre-broken breakable joint to current selection.''' bl_label = "Add Joint" bl_idname = "object.add_joint" @@ -351,6 +367,7 @@ def execute(self, context): class AddBranch(bpy.types.Operator): + '''Click to add a branch at active vertex or first vertex in a set of vertices.''' bl_label = "Add Branch" bl_idname = "mesh.add_branch" @@ -361,7 +378,14 @@ def execute(self, context): selected_vert_coordinates = get_vertex_data() if (selected_vert_coordinates): selected_vert = selected_vert_coordinates[0] - bpy.ops.object.add(type='EMPTY', view_align=False, enter_editmode=False, location=(selected_vert[0], selected_vert[1], selected_vert[2])) + bpy.ops.object.add( + type='EMPTY', + view_align=False, + enter_editmode=False, + location=( + selected_vert[0], + selected_vert[1], + selected_vert[2])) empty_object = bpy.context.active_object empty_object.name = name_branch(True) bpy.context.scene.objects.active = active_object @@ -374,6 +398,7 @@ def execute(self, context): class AddBranchJoint(bpy.types.Operator): + '''Click to add a branch joint at selected vertex or first vertex in a set of vertices.''' bl_label = "Add Branch Joint" bl_idname = "mesh.add_branch_joint" @@ -384,7 +409,14 @@ def execute(self, context): selected_vert_coordinates = get_vertex_data() if (selected_vert_coordinates): selected_vert = selected_vert_coordinates[0] - bpy.ops.object.add(type='EMPTY', view_align=False, enter_editmode=False, location=(selected_vert[0], selected_vert[1], selected_vert[2])) + bpy.ops.object.add( + type='EMPTY', + view_align=False, + enter_editmode=False, + location=( + selected_vert[0], + selected_vert[1], + selected_vert[2])) empty_object = bpy.context.active_object empty_object.name = name_branch(False) bpy.context.scene.objects.active = active_object @@ -397,7 +429,8 @@ def execute(self, context): def get_vertex_data(): - selected_vert_coordinates = [i.co for i in bpy.context.active_object.data.vertices if i.select] + selected_vert_coordinates = [ + i.co for i in bpy.context.active_object.data.vertices if i.select] return selected_vert_coordinates @@ -419,7 +452,9 @@ def name_branch(is_new_branch): if (is_new_branch): return ("branch%s_1" % (highest_branch_number + 1)) else: - return ("branch%s_%s" % (highest_branch_number, highest_joint_number + 1)) + return ( + "branch%s_%s" % + (highest_branch_number, highest_joint_number + 1)) else: return "branch1_1" @@ -429,6 +464,7 @@ def name_branch(is_new_branch): #------------------------------------------------------------------------------ class AddProperty(bpy.types.Operator): + '''Click to add a user defined property to the selected object.''' bl_label = "Add Property" bl_idname = "object.add_property" @@ -438,36 +474,36 @@ class AddProperty(bpy.types.Operator): def __init__(self): self.numbers = { - "mass": add.add_mass_property, - "density": add.add_density_property, - "pieces": add.add_pieces_property, - "bend": add.add_bend_property, - "twist": add.add_twist_property, - "push": add.add_push_property, - "pull": add.add_pull_property, - "shift": add.add_shift_property, - "limit": add.add_limit_property, - "min_angle": add.add_min_angle_property, - "max_angle": add.add_max_angle_property, + "mass": add.add_mass_property, + "density": add.add_density_property, + "pieces": add.add_pieces_property, + "bend": add.add_bend_property, + "twist": add.add_twist_property, + "push": add.add_push_property, + "pull": add.add_pull_property, + "shift": add.add_shift_property, + "limit": add.add_limit_property, + "min_angle": add.add_min_angle_property, + "max_angle": add.add_max_angle_property, } - + self.booleans = { - "entity": add.add_entity_property, - "dynamic": add.add_dynamic_property, - "no_hit_refinement": add.add_no_hit_refinement_property, - "box": add.add_box_proxy_property, - "cylinder": add.add_cylinder_proxy_property, - "capsule": add.add_capsule_proxy_property, - "sphere": add.add_sphere_proxy_property, - "notaprim": add.add_notaprim_proxy_property, - "no_explosion_occlusion": add.add_no_explosion_occlusion_property, - "other_rendermesh": add.add_other_rendermesh_property, - "colltype_player": add.add_colltype_player_property, - "gameplay_critical": add.add_gameplay_critical_property, - "player_can_break": add.add_player_can_break_property, - "damping": add.add_damping_property, - "collision": add.add_collision_property, - "wheel": add.add_wheel_property, + "entity": add.add_entity_property, + "dynamic": add.add_dynamic_property, + "no_hit_refinement": add.add_no_hit_refinement_property, + "box": add.add_box_proxy_property, + "cylinder": add.add_cylinder_proxy_property, + "capsule": add.add_capsule_proxy_property, + "sphere": add.add_sphere_proxy_property, + "notaprim": add.add_notaprim_proxy_property, + "no_explosion_occlusion": add.add_no_explosion_occlusion_property, + "other_rendermesh": add.add_other_rendermesh_property, + "colltype_player": add.add_colltype_player_property, + "gameplay_critical": add.add_gameplay_critical_property, + "player_can_break": add.add_player_can_break_property, + "damping": add.add_damping_property, + "collision": add.add_collision_property, + "wheel": add.add_wheel_property, } def execute(self, context): @@ -493,6 +529,7 @@ def invoke(self, context, event): class AddDeformableProperties(bpy.types.Operator): + '''Click to add deformable mesh properties.''' bl_label = "Deformable" bl_idname = "object.add_deformable_properties" @@ -516,9 +553,18 @@ class AddDeformableProperties(bpy.types.Operator): ) def execute(self, context): - add.add_deformable_properties(self, context, self.mass, self.stiffness, self.hardness, - self.max_stretch, self.max_impulse, self.skin_dist, - self.thickness, self.explosion_scale, self.is_primitive) + add.add_deformable_properties( + self, + context, + self.mass, + self.stiffness, + self.hardness, + self.max_stretch, + self.max_impulse, + self.skin_dist, + self.thickness, + self.explosion_scale, + self.is_primitive) message = "Adding deformable properties" self.report({'INFO'}, message) @@ -534,6 +580,7 @@ def invoke(self, context, event): #------------------------------------------------------------------------------ class AddMaterialPhysics(bpy.types.Operator): + '''Physics will be appended to the material name.''' bl_label = "Add Material Physics" bl_idname = "material.add_material_physics" @@ -542,11 +589,11 @@ class AddMaterialPhysics(bpy.types.Operator): def __init__(self): self.__physics = { - "physDefault": add.add_phys_default, - "physProxyNoDraw": add.add_phys_proxy_no_draw, - "physNone": add.add_phys_none, - "physObstruct": add.add_phys_obstruct, - "physNoCollide": add.add_phys_no_collide, + "physDefault": add.add_phys_default, + "physProxyNoDraw": add.add_phys_proxy_no_draw, + "physNone": add.add_phys_none, + "physObstruct": add.add_phys_obstruct, + "physNoCollide": add.add_phys_no_collide, } def execute(self, context): @@ -563,6 +610,7 @@ def execute(self, context): #------------------------------------------------------------------------------ class FindDegenerateFaces(bpy.types.Operator): + '''Select the object to test in object mode with nothing selected in \ it's mesh before running this.''' bl_label = "Find Degenerate Faces" @@ -575,7 +623,7 @@ def execute(self, context): # Deselect any vertices previously selected in Edit mode saved_mode = bpy.context.object.mode bpy.ops.object.mode_set(mode='EDIT') - bpy.ops.mesh.select_all(action = 'DESELECT') + bpy.ops.mesh.select_all(action='DESELECT') ''' Vertices data should be actually manipulated in Object mode to be displayed in Edit mode correctly.''' @@ -610,6 +658,7 @@ def execute(self, context): # Duo Oratar class FindMultifaceLines(bpy.types.Operator): + '''Select the object to test in object mode with nothing selected in \ it's mesh before running this.''' bl_label = "Find Lines with 3+ Faces." @@ -625,7 +674,7 @@ def execute(self, context): counter = 0 for polygon in me.data.polygons: if (i.vertices[0] in polygon.vertices - and i.vertices[1] in polygon.vertices): + and i.vertices[1] in polygon.vertices): counter += 1 if counter > 2: cbPrint('Found a multi-face line') @@ -637,6 +686,7 @@ def execute(self, context): class FindWeightless(bpy.types.Operator): + '''Select the object in object mode with nothing in its mesh selected \ before running this''' bl_label = "Find Weightless Vertices" @@ -645,7 +695,8 @@ class FindWeightless(bpy.types.Operator): # Minimum net weight to be considered non-weightless weight_epsilon = 0.0001 - # Weightless: a vertex not belonging to any groups or with a net weight of 0 + # Weightless: a vertex not belonging to any groups or with a net weight of + # 0 def execute(self, context): obj = bpy.context.active_object bpy.ops.object.mode_set(mode="EDIT") @@ -667,6 +718,7 @@ def execute(self, context): class RemoveAllWeight(bpy.types.Operator): + '''Select vertices from which to remove weight in edit mode.''' bl_label = "Remove All Weight from Selected Vertices" bl_idname = "mesh.remove_weight" @@ -685,6 +737,7 @@ def execute(self, context): class FindNoUVs(bpy.types.Operator): + '''Use this with no objects selected in object mode \ to find all items without UVs.''' bl_label = "Find All Objects with No UV's" @@ -707,6 +760,7 @@ def execute(self, context): class AddUVTexture(bpy.types.Operator): + '''Add UVs to all meshes without UVs.''' bl_label = "Add UV's to Objects" bl_idname = "mesh.add_uv_texture" @@ -732,6 +786,7 @@ def execute(self, context): #------------------------------------------------------------------------------ class AddRootBone(bpy.types.Operator): + '''Click to add a root bone to the active armature.''' bl_label = "Add Root Bone" bl_idname = "armature.add_root_bone" @@ -767,6 +822,7 @@ def execute(self, context): class AddBoneGeometry(bpy.types.Operator): + '''Add BoneGeometry for bones in selected armatures.''' bl_label = "Add BoneGeometry" bl_idname = "armature.add_bone_geometry" @@ -784,18 +840,20 @@ def execute(self, context): physBonesList = [] if "%s_Phys" % obj.name in nameList: - for bone in bpy.data.objects["%s_Phys" % obj.name].data.bones: + for bone in bpy.data.objects[ + "%s_Phys" % + obj.name].data.bones: physBonesList.append(bone.name) for bone in obj.data.bones: if ((not "%s_boneGeometry" % bone.name in nameList - and not "%s_Phys" % obj.name in nameList) - or ("%s_Phys" % obj.name in nameList - and "%s_Phys" % bone.name in physBonesList - and not "%s_boneGeometry" % bone.name in nameList) + and not "%s_Phys" % obj.name in nameList) + or ("%s_Phys" % obj.name in nameList + and "%s_Phys" % bone.name in physBonesList + and not "%s_boneGeometry" % bone.name in nameList) ): mesh = bpy.data.meshes.new( - "%s_boneGeometry" % bone.name + "%s_boneGeometry" % bone.name ) bm = bmesh.new() @@ -822,7 +880,7 @@ def execute(self, context): return {'FINISHED'} - + def add_bone_geometry(): """ This function takes inputs and returns vertex and face arrays. @@ -845,16 +903,17 @@ def add_bone_geometry(): (1, 5, 6, 2), (2, 6, 7, 3), (4, 0, 3, 7), - ] + ] return verts, faces - + class RemoveBoneGeometry(bpy.types.Operator): - '''Remove BoneGeometry for bones in selected armatures''' + + '''Remove BoneGeometry for bones in selected armatures''' bl_label = "Remove BoneGeometry" bl_idname = "armature.remove_bone_geometry" - bl_options = {'REGISTER', 'UNDO'} + bl_options = {'REGISTER', 'UNDO'} def execute(self, context): bpy.ops.object.mode_set(mode='OBJECT') @@ -879,15 +938,18 @@ def execute(self, context): for bone in obj.data.bones: # For each bone if "%s_boneGeometry" % bone.name in nameList: - bpy.data.objects["%s_boneGeometry" % bone.name].select = True + bpy.data.objects[ + "%s_boneGeometry" % + bone.name].select = True bpy.ops.object.delete() return {'FINISHED'} - + # Duo Oratar class RenamePhysBones(bpy.types.Operator): + '''Renames bones with _Phys extension.''' bl_label = "Rename Phys Bones" bl_idname = "armature.rename_phys_bones" @@ -896,7 +958,7 @@ class RenamePhysBones(bpy.types.Operator): def execute(self, context): for obj in bpy.context.scene.objects: if ('_Phys' == obj.name[-5:] - and obj.type == 'ARMATURE'): + and obj.type == 'ARMATURE'): for bone in obj.data.bones: bone.name = "%s_Phys" % bone.name @@ -908,6 +970,7 @@ def execute(self, context): #------------------------------------------------------------------------------ class AddSDKSkeleton(bpy.types.Operator): + '''Adds a template to the scene.''' bl_label = "Add Template" bl_idname = "scene.add_template" @@ -919,7 +982,9 @@ def execute(self, context): script_directory = os.path.dirname(os.path.abspath(__file__)) path = "//{}.blend/Object/Armature".format(self.type_) name = "Armature" - directory = "{}/resources/{}.blend/Object/".format(script_directory, self.type_) + directory = "{}/resources/{}.blend/Object/".format( + script_directory, + self.type_) bpy.ops.wm.append(filepath=path, filename=name, directory=directory) return {'FINISHED'} @@ -928,8 +993,9 @@ def execute(self, context): #------------------------------------------------------------------------------ # Export Handler #------------------------------------------------------------------------------ - + class Export(bpy.types.Operator, ExportHelper): + '''Select to export to game.''' bl_label = "Export to Game" bl_idname = "scene.export_to_game" @@ -937,82 +1003,83 @@ class Export(bpy.types.Operator, ExportHelper): filter_glob = StringProperty(default="*.dae", options={'HIDDEN'}) apply_modifiers = BoolProperty( - name="Apply Modifiers", - description="Apply all modifiers before exporting.", - default=True, - ) + name="Apply Modifiers", + description="Apply all modifiers before exporting.", + default=True, + ) do_not_merge = BoolProperty( - name="Do Not Merge Nodes", - description="Generally a good idea.", - default=True, - ) + name="Do Not Merge Nodes", + description="Generally a good idea.", + default=True, + ) suppress_printouts = BoolProperty( name="Suppress RC Printouts", description="Generally a good idea.", default=True, - ) + ) do_materials = BoolProperty( - name="Do Materials", - description="Create MTL files for materials.", - default=False, - ) + name="Do Materials", + description="Create MTL files for materials.", + default=False, + ) do_textures = BoolProperty( - name="Do Textures", - description="Converts source textures to DDS while exporting materials.", - default=False, - ) + name="Do Textures", + description="Converts source textures to DDS while exporting materials.", + default=False, + ) make_chrparams = BoolProperty( - name="Make CHRPARAMS File", - description="Create a base CHRPARAMS file for character animations.", - default=False, - ) + name="Make CHRPARAMS File", + description="Create a base CHRPARAMS file for character animations.", + default=False, + ) make_cdf = BoolProperty( - name="Make CDF File", - description="Create a base CDF file for character attachments.", - default=False, - ) + name="Make CDF File", + description="Create a base CDF file for character attachments.", + default=False, + ) include_ik = BoolProperty( - name="Include IK in Character", - description="Add IK to the physics skeleton upon export.", - default=False, - ) + name="Include IK in Character", + description="Add IK to the physics skeleton upon export.", + default=False, + ) fix_weights = BoolProperty( - name="Fix Weights", - description="For use with .chr files. Generally a good idea.", - default=True, - ) + name="Fix Weights", + description="For use with .chr files. Generally a good idea.", + default=True, + ) average_planar = BoolProperty( - name="Average Planar Face Normals", - description="Align face normals within 1 degree of each other.", - default=False, - ) + name="Average Planar Face Normals", + description="Align face normals within 1 degree of each other.", + default=False, + ) make_layer = BoolProperty( - name="Make LYR File", - description="Makes a LYR to reassemble your scene in CryEngine.", - default=False, - ) + name="Make LYR File", + description="Makes a LYR to reassemble your scene in CryEngine.", + default=False, + ) disable_rc = BoolProperty( - name="Disable RC", - description="Do not run the resource compiler.", - default=False, - ) + name="Disable RC", + description="Do not run the resource compiler.", + default=False, + ) save_dae = BoolProperty( - name="Save DAE", - description="Save the DAE file for developing purposes.", - default=False, - ) + name="Save DAE", + description="Save the DAE file for developing purposes.", + default=False, + ) save_tiffs = BoolProperty( - name="Save TIFFs", - description="Saves TIFF images that are generated during conversion to DDS.", - default=False, - ) + name="Save TIFFs", + description="Saves TIFF images that are generated during conversion to DDS.", + default=False, + ) run_in_profiler = BoolProperty( - name="Profile CryBlend", - description="Select only if you want to profile CryBlend.", - default=False, - ) + name="Profile CryBlend", + description="Select only if you want to profile CryBlend.", + default=False, + ) class Config: + def __init__(self, config): attributes = ( 'filepath', @@ -1039,8 +1106,20 @@ def __init__(self, config): setattr(self, 'cryblend_version', VERSION) setattr(self, 'rc_path', Configuration.rc_path) setattr(self, 'texture_rc_path', Configuration.texture_rc_path) - setattr(self, 'texture_dir', utils.build_path(os.path.dirname(self.filepath), "textures")) - setattr(self, 'texture_dir', utils.build_path(os.path.dirname(self.filepath), "textures")) + setattr( + self, + 'texture_dir', + utils.build_path( + os.path.dirname( + self.filepath), + "textures")) + setattr( + self, + 'texture_dir', + utils.build_path( + os.path.dirname( + self.filepath), + "textures")) def execute(self, context): cbPrint(Configuration.rc_path, 'debug') @@ -1052,12 +1131,14 @@ def execute(self, context): cProfile.runctx('export.save(config)', {}, {'export': export, 'config': config}) else: - + export.save(config) except exceptions.CryBlendException as exception: cbPrint(exception.what(), 'error') - bpy.ops.screen.display_error('INVOKE_DEFAULT', message=exception.what()) + bpy.ops.screen.display_error( + 'INVOKE_DEFAULT', + message=exception.what()) return {'FINISHED'} @@ -1130,7 +1211,7 @@ def multiline_label(col, text): #------------------------------------------------------------------------------ # CryBlend Tab #------------------------------------------------------------------------------ - + class PropPanel(): bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1158,9 +1239,11 @@ def draw(self, context): col = layout.column(align=True) col.label("ExportNodes", icon="GROUP") col.separator() - row = col.row(align=True) + row = col.row(align=True) row.operator("object.add_cry_export_node", text="Add ExportNode") - col.operator("object.selected_to_cry_export_nodes", text="ExportNodes from Objects") + col.operator( + "object.selected_to_cry_export_nodes", + text="ExportNodes from Objects") col.separator() col.operator("object.apply_transforms", text="Apply All Transforms") @@ -1195,7 +1278,7 @@ def draw(self, context): col.label("Touch Bending:", icon="OUTLINER_OB_EMPTY") col.separator() col.operator("mesh.add_branch", text="Add Branch") - col.operator("mesh.add_branch_joint", text="Add Branch Joint") + col.operator("mesh.add_branch_joint", text="Add Branch Joint") class BoneUtilitiesPanel(View3DPanel, Panel): @@ -1212,7 +1295,9 @@ def draw(self, context): col.label("Physics", icon="PHYSICS") col.separator() col.operator("armature.add_bone_geometry", text="Add BoneGeometry") - col.operator("armature.remove_bone_geometry", text="Remove BoneGeometry") + col.operator( + "armature.remove_bone_geometry", + text="Remove BoneGeometry") col.operator("armature.rename_phys_bones", text="Rename Phys Bones") @@ -1263,7 +1348,9 @@ def draw(self, context): col.operator("file.find_rc", text="Find RC") col.operator("file.find_texture_rc", text="Find Texture RC") col.separator() - col.operator("file.select_texture_directory", text="Select Textures Folder") + col.operator( + "file.select_texture_directory", + text="Select Textures Folder") #------------------------------------------------------------------------------ @@ -1279,12 +1366,20 @@ def draw(self, context): layout.label(text='v%s' % VERSION) # layout.operator("open_donate.wp", icon='FORCE_DRAG') - layout.operator("object.add_cry_export_node", text="Add ExportNode", icon="GROUP") - layout.operator("object.selected_to_cry_export_nodes", text="ExportNodes from Objects") + layout.operator( + "object.add_cry_export_node", + text="Add ExportNode", + icon="GROUP") + layout.operator( + "object.selected_to_cry_export_nodes", + text="ExportNodes from Objects") layout.separator() - layout.operator("object.apply_transforms", text="Apply All Transforms", icon="MESH_DATA") + layout.operator( + "object.apply_transforms", + text="Apply All Transforms", + icon="MESH_DATA") layout.separator() - + layout.menu("menu.add_physics_proxy", icon="ROTATE") layout.separator() layout.menu(BoneUtilitiesMenu.bl_idname, icon='BONE_DATA') @@ -1314,13 +1409,25 @@ def draw(self, context): layout = self.layout layout.label("Proxies") - add_box_proxy = layout.operator("object.add_proxy", text="Box", icon="META_CUBE") + add_box_proxy = layout.operator( + "object.add_proxy", + text="Box", + icon="META_CUBE") add_box_proxy.type_ = "box" - add_capsule_proxy = layout.operator("object.add_proxy", text="Capsule", icon="META_ELLIPSOID") + add_capsule_proxy = layout.operator( + "object.add_proxy", + text="Capsule", + icon="META_ELLIPSOID") add_capsule_proxy.type_ = "capsule" - add_cylinder_proxy = layout.operator("object.add_proxy", text="Cylinder", icon="META_CAPSULE") + add_cylinder_proxy = layout.operator( + "object.add_proxy", + text="Cylinder", + icon="META_CAPSULE") add_cylinder_proxy.type_ = "cylinder" - add_sphere_proxy = layout.operator("object.add_proxy", text="Sphere", icon="META_BALL") + add_sphere_proxy = layout.operator( + "object.add_proxy", + text="Sphere", + icon="META_BALL") add_sphere_proxy.type_ = "sphere" @@ -1332,13 +1439,25 @@ def draw(self, context): layout = self.layout layout.label(text="Skeleton") - layout.operator("armature.add_root_bone", text="Add Root Bone", icon="BONE_DATA") + layout.operator( + "armature.add_root_bone", + text="Add Root Bone", + icon="BONE_DATA") layout.separator() layout.label(text="Physics") - layout.operator("armature.add_bone_geometry", text="Add BoneGeometry", icon="PHYSICS") - layout.operator("armature.remove_bone_geometry", text="Remove BoneGeometry", icon="PHYSICS") - layout.operator("armature.rename_phys_bones", text="Rename Phys Bones", icon="PHYSICS") + layout.operator( + "armature.add_bone_geometry", + text="Add BoneGeometry", + icon="PHYSICS") + layout.operator( + "armature.remove_bone_geometry", + text="Remove BoneGeometry", + icon="PHYSICS") + layout.operator( + "armature.rename_phys_bones", + text="Rename Phys Bones", + icon="PHYSICS") class BreakablesMenu(bpy.types.Menu): @@ -1360,8 +1479,14 @@ def draw(self, context): layout = self.layout layout.label(text="Touch Bending") - layout.operator("mesh.add_branch", text="Add Branch", icon='MOD_SIMPLEDEFORM') - layout.operator("mesh.add_branch_joint", text="Add Branch Joint", icon='EMPTY_DATA') + layout.operator( + "mesh.add_branch", + text="Add Branch", + icon='MOD_SIMPLEDEFORM') + layout.operator( + "mesh.add_branch_joint", + text="Add Branch Joint", + icon='EMPTY_DATA') class MeshUtilitiesMenu(bpy.types.Menu): @@ -1372,18 +1497,36 @@ def draw(self, context): layout = self.layout layout.label(text="Weight Repair") - layout.operator("mesh.find_weightless", text="Find Weightless", icon="WPAINT_HLT") - layout.operator("mesh.remove_weight", text="Remove Weight", icon="WPAINT_HLT") + layout.operator( + "mesh.find_weightless", + text="Find Weightless", + icon="WPAINT_HLT") + layout.operator( + "mesh.remove_weight", + text="Remove Weight", + icon="WPAINT_HLT") layout.separator() layout.label(text="Mesh Repair") - layout.operator("object.find_degenerate_faces", text="Find Degenerate", icon='ZOOM_ALL') - layout.operator("mesh.find_multiface_lines", text="Find Multi-face", icon='ZOOM_ALL') + layout.operator( + "object.find_degenerate_faces", + text="Find Degenerate", + icon='ZOOM_ALL') + layout.operator( + "mesh.find_multiface_lines", + text="Find Multi-face", + icon='ZOOM_ALL') layout.separator() layout.label(text="UV Repair") - layout.operator("scene.find_no_uvs", text="Find All Objects with No UV's", icon="UV_FACESEL") - layout.operator("mesh.add_uv_texture", text="Add UV's to Objects", icon="UV_FACESEL") + layout.operator( + "scene.find_no_uvs", + text="Find All Objects with No UV's", + icon="UV_FACESEL") + layout.operator( + "mesh.add_uv_texture", + text="Add UV's to Objects", + icon="UV_FACESEL") class CustomPropertiesMenu(bpy.types.Menu): @@ -1396,59 +1539,143 @@ def draw(self, context): col = row.column() col.label("Rendermesh") - col.operator("object.add_property", text="Mass", icon="FORCE_LENNARDJONES").type_ = "mass" - col.operator("object.add_property", text="Density", icon="BBOX").type_ = "density" - col.operator("object.add_property", text="Pieces", icon="STICKY_UVS_DISABLE").type_ = "pieces" + col.operator( + "object.add_property", + text="Mass", + icon="FORCE_LENNARDJONES").type_ = "mass" + col.operator( + "object.add_property", + text="Density", + icon="BBOX").type_ = "density" + col.operator( + "object.add_property", + text="Pieces", + icon="STICKY_UVS_DISABLE").type_ = "pieces" col.label(" ") col.label(" ") col.separator() - col.operator("object.add_property", text="Entity", icon="FILE_TICK").type_ = "entity" - col.operator("object.add_property", text="Dynamic", icon="FILE_TICK").type_ = "dynamic" - col.operator("object.add_property", text="No Hit Refinement", icon="FILE_TICK").type_ = "no_hit_refinement" + col.operator( + "object.add_property", + text="Entity", + icon="FILE_TICK").type_ = "entity" + col.operator( + "object.add_property", + text="Dynamic", + icon="FILE_TICK").type_ = "dynamic" + col.operator( + "object.add_property", + text="No Hit Refinement", + icon="FILE_TICK").type_ = "no_hit_refinement" col = row.column() col.label("Physics Proxy") - col.operator("object.add_property", text="Box", icon="META_CUBE").type_ = "box" - col.operator("object.add_property", text="Cylinder", icon="META_CAPSULE").type_ = "cylinder" - col.operator("object.add_property", text="Capsule", icon="META_ELLIPSOID").type_ = "capsule" - col.operator("object.add_property", text="Sphere", icon="META_BALL").type_ = "sphere" - col.operator("object.add_property", text="Not a Primitive", icon="X").type_ = "notaprim" + col.operator( + "object.add_property", + text="Box", + icon="META_CUBE").type_ = "box" + col.operator( + "object.add_property", + text="Cylinder", + icon="META_CAPSULE").type_ = "cylinder" + col.operator( + "object.add_property", + text="Capsule", + icon="META_ELLIPSOID").type_ = "capsule" + col.operator( + "object.add_property", + text="Sphere", + icon="META_BALL").type_ = "sphere" + col.operator( + "object.add_property", + text="Not a Primitive", + icon="X").type_ = "notaprim" col.separator() - col.operator("object.add_property", text="No Explosion Occlusion", icon="FILE_TICK").type_ = "no_explosion_occlusion" - col.operator("object.add_property", text="Other Rendermesh", icon="FILE_TICK").type_ = "other_rendermesh" - col.operator("object.add_property", text="Colltype Player", icon="FILE_TICK").type_ = "colltype_player" + col.operator( + "object.add_property", + text="No Explosion Occlusion", + icon="FILE_TICK").type_ = "no_explosion_occlusion" + col.operator( + "object.add_property", + text="Other Rendermesh", + icon="FILE_TICK").type_ = "other_rendermesh" + col.operator( + "object.add_property", + text="Colltype Player", + icon="FILE_TICK").type_ = "colltype_player" col = row.column() col.label("Joint Node") - col.operator("object.add_property", text="Bend", icon="LINCURVE").type_ = "bend" - col.operator("object.add_property", text="Twist", icon="MOD_SCREW").type_ = "twist" - col.operator("object.add_property", text="Pull", icon="FULLSCREEN_ENTER").type_ = "pull" - col.operator("object.add_property", text="Push", icon="FULLSCREEN_EXIT").type_ = "push" - col.operator("object.add_property", text="Shift", icon="NEXT_KEYFRAME").type_ = "shift" + col.operator( + "object.add_property", + text="Bend", + icon="LINCURVE").type_ = "bend" + col.operator( + "object.add_property", + text="Twist", + icon="MOD_SCREW").type_ = "twist" + col.operator( + "object.add_property", + text="Pull", + icon="FULLSCREEN_ENTER").type_ = "pull" + col.operator( + "object.add_property", + text="Push", + icon="FULLSCREEN_EXIT").type_ = "push" + col.operator( + "object.add_property", + text="Shift", + icon="NEXT_KEYFRAME").type_ = "shift" col.separator() - col.operator("object.add_property", text="Gameplay Critical", icon="FILE_TICK").type_ = "gameplay_critical" - col.operator("object.add_property", text="Player Can Break", icon="FILE_TICK").type_ = "player_can_break" + col.operator( + "object.add_property", + text="Gameplay Critical", + icon="FILE_TICK").type_ = "gameplay_critical" + col.operator( + "object.add_property", + text="Player Can Break", + icon="FILE_TICK").type_ = "player_can_break" col = row.column() col.label("Constraints") - col.operator("object.add_property", text="Limit", icon="CONSTRAINT").type_ = "limit" - col.operator("object.add_property", text="Min Angle", icon="ZOOMOUT").type_ = "min_angle" - col.operator("object.add_property", text="Max Angle", icon="ZOOMIN").type_ = "max_angle" + col.operator( + "object.add_property", + text="Limit", + icon="CONSTRAINT").type_ = "limit" + col.operator( + "object.add_property", + text="Min Angle", + icon="ZOOMOUT").type_ = "min_angle" + col.operator( + "object.add_property", + text="Max Angle", + icon="ZOOMIN").type_ = "max_angle" col.label(" ") col.label(" ") col.separator() - col.operator("object.add_property", text="Damping", icon="FILE_TICK").type_ = "damping" - col.operator("object.add_property", text="Collision", icon="FILE_TICK").type_ = "collision" + col.operator( + "object.add_property", + text="Damping", + icon="FILE_TICK").type_ = "damping" + col.operator( + "object.add_property", + text="Collision", + icon="FILE_TICK").type_ = "collision" col = row.column() col.label("Other") - col.operator("object.add_deformable_properties", text="Deformable", icon="MOD_SIMPLEDEFORM") + col.operator( + "object.add_deformable_properties", + text="Deformable", + icon="MOD_SIMPLEDEFORM") col.label(" ") col.label(" ") col.label(" ") col.label(" ") col.separator() - col.operator("object.add_property", text="Wheel", icon="FILE_TICK").type_ = "wheel" + col.operator( + "object.add_property", + text="Wheel", + icon="FILE_TICK").type_ = "wheel" class AddTemplateMenu(bpy.types.Menu): @@ -1458,9 +1685,15 @@ class AddTemplateMenu(bpy.types.Menu): def draw(self, context): layout = self.layout layout.label(text="Add Template") - template = layout.operator("scene.add_template", text="SDK Skeleton", icon="OUTLINER_OB_ARMATURE") + template = layout.operator( + "scene.add_template", + text="SDK Skeleton", + icon="OUTLINER_OB_ARMATURE") template.type_ = "sdk_skeleton" - template = layout.operator("scene.add_template", text="SDK FP Arms", icon="OUTLINER_OB_ARMATURE") + template = layout.operator( + "scene.add_template", + text="SDK FP Arms", + icon="OUTLINER_OB_ARMATURE") template.type_ = "sdk_fp_arms" @@ -1473,9 +1706,15 @@ def draw(self, context): layout.label("Configure") layout.operator("file.find_rc", text="Find RC", icon="SPACE2") - layout.operator("file.find_texture_rc", text="Find Texture RC", icon="SPACE2") + layout.operator( + "file.find_texture_rc", + text="Find Texture RC", + icon="SPACE2") layout.separator() - layout.operator("file.select_texture_directory", text="Select Textures Folder", icon="FILE_FOLDER") + layout.operator( + "file.select_texture_directory", + text="Select Textures Folder", + icon="FILE_FOLDER") class AddMaterialPhysicsMenu(bpy.types.Menu): @@ -1487,11 +1726,26 @@ def draw(self, context): layout.label(text="Add Material Physics") layout.separator() - layout.operator("material.add_material_physics", text="physDefault", icon='PHYSICS').type_ = "physDefault" - layout.operator("material.add_material_physics", text="physProxyNoDraw", icon='PHYSICS').type_ = "physProxyNoDraw" - layout.operator("material.add_material_physics", text="physNone", icon='PHYSICS').type_ = "physNone" - layout.operator("material.add_material_physics", text="physObstruct", icon='PHYSICS').type_ = "physObstruct" - layout.operator("material.add_material_physics", text="physNoCollide", icon='PHYSICS').type_ = "physNoCollide" + layout.operator( + "material.add_material_physics", + text="physDefault", + icon='PHYSICS').type_ = "physDefault" + layout.operator( + "material.add_material_physics", + text="physProxyNoDraw", + icon='PHYSICS').type_ = "physProxyNoDraw" + layout.operator( + "material.add_material_physics", + text="physNone", + icon='PHYSICS').type_ = "physNone" + layout.operator( + "material.add_material_physics", + text="physObstruct", + icon='PHYSICS').type_ = "physObstruct" + layout.operator( + "material.add_material_physics", + text="physNoCollide", + icon='PHYSICS').type_ = "physNoCollide" class CryBlendReducedMenu(bpy.types.Menu): @@ -1501,7 +1755,10 @@ class CryBlendReducedMenu(bpy.types.Menu): def draw(self, context): layout = self.layout - layout.operator("object.apply_transforms", text="Apply All Transforms", icon="MESH_DATA") + layout.operator( + "object.apply_transforms", + text="Apply All Transforms", + icon="MESH_DATA") layout.separator() layout.menu("menu.add_physics_proxy", icon="ROTATE") layout.separator() @@ -1574,9 +1831,9 @@ def get_classes_to_register(): CustomPropertiesMenu, AddTemplateMenu, ConfigurationsMenu, - + AddMaterialPhysicsMenu, - CryBlendReducedMenu, + CryBlendReducedMenu, ) return classes @@ -1602,7 +1859,12 @@ def register(): kc = wm.keyconfigs.addon if kc: km = kc.keymaps.new(name='3D View', space_type='VIEW_3D') - kmi = km.keymap_items.new('wm.call_menu', 'Q', 'PRESS', ctrl = False, shift = True) + kmi = km.keymap_items.new( + 'wm.call_menu', + 'Q', + 'PRESS', + ctrl=False, + shift=True) kmi.properties.name = "view3d.cryblend_reduced_menu" bpy.types.INFO_HT_header.append(draw_item) diff --git a/io_export_cryblend/add.py b/io_export_cryblend/add.py index be19af8..525da4d 100644 --- a/io_export_cryblend/add.py +++ b/io_export_cryblend/add.py @@ -173,57 +173,77 @@ def add_collision_property(self, context): # deformable -def add_deformable_property(self, context, mass, stiffness, hardness, - max_stretch, max_impulse, skin_dist, thickness, explosion_scale, is_primitive): - ob = bpy.context.active_object - ob['mass'] = 'mass=%s' % mass - ob['stfns'] = 'stiffness=%s' % stiffness - ob['stfns'] = 'hardness=%s' % hardness - ob['mxstr'] = 'max_stretch=%s' % max_stretch - ob['mxstr'] = 'max_impulse=%s' % max_impulse - ob['skdist'] = 'skin_dist=%s' % skin_dist - ob['thkns'] = 'thickness=%s' % thickness - ob['thkns'] = 'explosion_scale=%s' % explosion_scale - if (is_primitive == 'Yes'): - ob['notap'] = 'notaprim=0' - else: - ob['notap'] = 'notaprim=1' - return{'FINISHED'} +def add_deformable_property( + self, + context, + mass, + stiffness, + hardness, + max_stretch, + max_impulse, + skin_dist, + thickness, + explosion_scale, + is_primitive): + ob = bpy.context.active_object + ob['mass'] = 'mass=%s' % mass + ob['stfns'] = 'stiffness=%s' % stiffness + ob['stfns'] = 'hardness=%s' % hardness + ob['mxstr'] = 'max_stretch=%s' % max_stretch + ob['mxstr'] = 'max_impulse=%s' % max_impulse + ob['skdist'] = 'skin_dist=%s' % skin_dist + ob['thkns'] = 'thickness=%s' % thickness + ob['thkns'] = 'explosion_scale=%s' % explosion_scale + if (is_primitive == 'Yes'): + ob['notap'] = 'notaprim=0' + else: + ob['notap'] = 'notaprim=1' + return{'FINISHED'} # material physics def add_phys_default(self, context): me = bpy.context.active_object if me.active_material: - me.active_material.name = replacePhysMaterial(me.active_material.name, '__physDefault') + me.active_material.name = replacePhysMaterial( + me.active_material.name, + '__physDefault') return{'FINISHED'} def add_phys_none(self, context): me = bpy.context.active_object if me.active_material: - me.active_material.name = replacePhysMaterial(me.active_material.name, '__physNone') + me.active_material.name = replacePhysMaterial( + me.active_material.name, + '__physNone') return{'FINISHED'} def add_phys_proxy_no_draw(self, context): me = bpy.context.active_object if me.active_material: - me.active_material.name = replacePhysMaterial(me.active_material.name, '__physProxyNoDraw') + me.active_material.name = replacePhysMaterial( + me.active_material.name, + '__physProxyNoDraw') return{'FINISHED'} def add_phys_obstruct(self, context): me = bpy.context.active_object if me.active_material: - me.active_material.name = replacePhysMaterial(me.active_material.name, '__physObstruct') + me.active_material.name = replacePhysMaterial( + me.active_material.name, + '__physObstruct') return{'FINISHED'} def add_phys_no_collide(self, context): me = bpy.context.active_object if me.active_material: - me.active_material.name = replacePhysMaterial(me.active_material.name, '__physNoCollide') + me.active_material.name = replacePhysMaterial( + me.active_material.name, + '__physNoCollide') return{'FINISHED'} diff --git a/io_export_cryblend/configuration.py b/io_export_cryblend/configuration.py index 1283f4f..0a1b32c 100644 --- a/io_export_cryblend/configuration.py +++ b/io_export_cryblend/configuration.py @@ -25,7 +25,7 @@ class __Configuration: __CONFIG_FILENAME = 'cryblend.cfg' __CONFIG_FILEPATH = os.path.join(__CONFIG_PATH, __CONFIG_FILENAME) __DEFAULT_CONFIGURATION = {'RC_PATH': r'', - 'TEXTURE_RC_PATH': r''} + 'TEXTURE_RC_PATH': r''} def __init__(self): self.__CONFIG = self.__load({}) diff --git a/io_export_cryblend/exceptions.py b/io_export_cryblend/exceptions.py index 80b95f7..5632eaa 100644 --- a/io_export_cryblend/exceptions.py +++ b/io_export_cryblend/exceptions.py @@ -13,6 +13,7 @@ class CryBlendException(RuntimeError): + def __init__(self, message): self._message = message @@ -24,6 +25,7 @@ def what(self): class BlendNotSavedException(CryBlendException): + def __init__(self): message = 'Blend file has to be saved before exporting.' @@ -31,6 +33,7 @@ def __init__(self): class TextureAndBlendDiskMismatchException(CryBlendException): + def __init__(self, blend_path, texture_path): message = """ Blend file and all textures have to be placed on the same disk. @@ -42,6 +45,7 @@ def __init__(self, blend_path, texture_path): class NoRcSelectedException(CryBlendException): + def __init__(self): message = """ Please find Resource Compiler first. diff --git a/io_export_cryblend/export.py b/io_export_cryblend/export.py index d3cafd4..e75275d 100644 --- a/io_export_cryblend/export.py +++ b/io_export_cryblend/export.py @@ -69,6 +69,7 @@ class CrytekDaeExporter: + def __init__(self, config): self.__config = config self.__doc = Document() @@ -78,8 +79,9 @@ def export(self): self.__prepare_for_export() root_element = self.__doc.createElement('collada') - root_element.setAttribute('xmlns', - 'http://www.collada.org/2005/11/COLLADASchema') + root_element.setAttribute( + 'xmlns', + 'http://www.collada.org/2005/11/COLLADASchema') root_element.setAttribute('version', '1.4.1') self.__doc.appendChild(root_element) self.__create_file_header(root_element) @@ -120,21 +122,27 @@ def __get_materials(self): continue material_counter[group.name] += 1 - nodename = utils.get_node_name(group.name.replace("CryExportNode_", "")) - name, physics = utils.get_material_props(slot.material.name) + nodename = utils.get_node_name( + group.name.replace( + "CryExportNode_", + "")) + name, physics = utils.get_material_props( + slot.material.name) already_exists = False for materialname, material in materials.items(): - pattern = '{}__[0-9]+__{}__phys[A-Za-z0-9]+'.format(nodename, name) + pattern = '{}__[0-9]+__{}__phys[A-Za-z0-9]+'.format( + nodename, + name) if re.search(pattern, materialname): already_exists = True break if not already_exists: materialname = "{}__{:03d}__{}__{}".format( - nodename, - material_counter[group.name], - name, - physics) + nodename, + material_counter[group.name], + name, + physics) materials[materialname] = slot.material @@ -174,7 +182,8 @@ def __create_file_header(self, parent_element): author_tool.appendChild(author_name_text) contributor.appendChild(author_tool) created = self.__doc.createElement('created') - created_value = self.__doc.createTextNode(datetime.now().isoformat(' ')) + created_value = self.__doc.createTextNode( + datetime.now().isoformat(' ')) created.appendChild(created_value) asset.appendChild(created) modified = self.__doc.createElement('modified') @@ -211,7 +220,10 @@ def __export_library_images(self, parent_element): def __export_library_image(self, image): image_name = utils.get_filename(image.filepath) - dds_path = utils.build_path(self.__config.texture_dir, image_name, ".dds") + dds_path = utils.build_path( + self.__config.texture_dir, + image_name, + ".dds") image_path = utils.trim_path_to(dds_path, "Objects") image_element = self.__doc.createElement('image') @@ -248,20 +260,27 @@ def __export_library_effects(self, parent_element): current_element = self.__doc.createElement('library_effects') parent_element.appendChild(current_element) for materialname, material in self.__materials.items(): - self.__export_library_effects_material(materialname, material, current_element) - - def __export_library_effects_material(self, materialname, material, current_element): + self.__export_library_effects_material( + materialname, + material, + current_element) + + def __export_library_effects_material( + self, + materialname, + material, + current_element): images = [[], [], []] texture_slots = utils.get_texture_slots_for_material(material) for texture_slot in texture_slots: image = texture_slot.texture.image if not image: raise exceptions.CryBlendException( - 'One of texture slots has no image assigned.') + 'One of texture slots has no image assigned.') surface, sampler = self.__create_surface_and_sampler(image.name) if texture_slot.use_map_color_diffuse: - images[0] = [image.name, surface, sampler] + images[0] = [image.name, surface, sampler] if texture_slot.use_map_color_spec: images[1] = [image.name, surface, sampler] if texture_slot.use_map_normal: @@ -280,7 +299,7 @@ def __export_library_effects_material(self, materialname, material, current_elem phong = self.__create_material_node(material, images) technique_common.appendChild(phong) profile_node.appendChild(technique_common) - + extra = self.__create_double_sided_extra('GOOGLEEARTH') profile_node.appendChild(extra) effect_node.appendChild(profile_node) @@ -304,7 +323,7 @@ def __create_surface_and_sampler(self, image_name): sampler_node = self.__doc.createElement('sampler2D') source_node = self.__doc.createElement('source') temp_node = self.__doc.createTextNode( - '%s-surface' % (image_name)) + '%s-surface' % (image_name)) source_node.appendChild(temp_node) sampler_node.appendChild(source_node) sampler.appendChild(sampler_node) @@ -326,7 +345,9 @@ def __create_material_node(self, material, images): specular = self.__create_color_node(material, 'specular') shininess = self.__create_attribute_node(material, 'shininess') - index_refraction = self.__create_attribute_node(material, 'index_refraction') + index_refraction = self.__create_attribute_node( + material, + 'index_refraction') phong.appendChild(emission) phong.appendChild(ambient) @@ -520,7 +541,7 @@ def __write_vertex_colors(self, object_, mesh, root): for color in colors: if color_layer.name.lower() == 'alpha': alpha_found = True - alpha = (color[0] + color[1] + color[2])/3 + alpha = (color[0] + color[1] + color[2]) / 3 float_colors.extend([1, 1, 1, alpha]) else: float_colors.extend(color) @@ -540,17 +561,25 @@ def __write_vertices(self, object_, mesh, root): def __write_polylist(self, object_, mesh, root): matindex = 0 - for materialname, material in self.__get_materials_for_object(object_).items(): + for materialname, material in self.__get_materials_for_object( + object_).items(): vert_data = '' verts_per_poly = '' poly_count = normal = texcoord = 0 for face in mesh.tessfaces: if face.material_index == matindex: - verts_per_poly = join(verts_per_poly, len(face.vertices), ' ') + verts_per_poly = join( + verts_per_poly, len( + face.vertices), ' ') poly_count += 1 for vert in face.vertices: - data = self.__write_vertex_data(mesh, face, vert, normal, texcoord) + data = self.__write_vertex_data( + mesh, + face, + vert, + normal, + texcoord) vert_data = join(vert_data, data) texcoord += 1 else: @@ -570,11 +599,31 @@ def __write_polylist(self, object_, mesh, root): polylist.setAttribute('count', str(poly_count)) inputs = [] - inputs.append(utils.write_input(object_.name, 0, 'vertices', 'VERTEX')) - inputs.append(utils.write_input(object_.name, 1, 'normals', 'NORMAL')) - inputs.append(utils.write_input(object_.name, 2, 'UVMap-0', 'TEXCOORD')) + inputs.append( + utils.write_input( + object_.name, + 0, + 'vertices', + 'VERTEX')) + inputs.append( + utils.write_input( + object_.name, + 1, + 'normals', + 'NORMAL')) + inputs.append( + utils.write_input( + object_.name, + 2, + 'UVMap-0', + 'TEXCOORD')) if mesh.vertex_colors: - inputs.append(utils.write_input(object_.name, 3, 'colors', 'COLOR')) + inputs.append( + utils.write_input( + object_.name, + 3, + 'colors', + 'COLOR')) for input in inputs: polylist.appendChild(input) @@ -596,7 +645,11 @@ def __write_vertex_data(self, mesh, face, vert, normal, texcoord): normal = vert if mesh.vertex_colors: - return '{:d} {:d} {:d} {:d} '.format(vert, normal, texcoord, texcoord) + return '{:d} {:d} {:d} {:d} '.format( + vert, + normal, + texcoord, + texcoord) else: return '{:d} {:d} {:d} '.format(vert, normal, texcoord) @@ -721,12 +774,16 @@ def __export_library_animation_clips_and_animations(self, parent_element): if node_type in allowed: animation_clip = self.__doc.createElement('animation_clip') node_name = utils.get_node_name(group.name) - animation_clip.setAttribute('id', - '{!s}-{!s}'.format(node_name, node_name)) - animation_clip.setAttribute('start', - '{:f}'.format(utils.frame_to_time(scene.frame_start))) - animation_clip.setAttribute('end', - '{:f}'.format(utils.frame_to_time(scene.frame_end))) + animation_clip.setAttribute( + 'id', '{!s}-{!s}'.format(node_name, node_name)) + animation_clip.setAttribute( + 'start', '{:f}'.format( + utils.frame_to_time( + scene.frame_start))) + animation_clip.setAttribute( + 'end', '{:f}'.format( + utils.frame_to_time( + scene.frame_end))) is_animation = False for object_ in group.objects: if (object_.type != 'ARMATURE' and object_.animation_data and @@ -734,17 +791,22 @@ def __export_library_animation_clips_and_animations(self, parent_element): is_animation = True for axis in iter(AXES): - animation = self.__get_animation_location(object_, axis) + animation = self.__get_animation_location( + object_, + axis) if animation is not None: libanm.appendChild(animation) for axis in iter(AXES): - animation = self.__get_animation_rotation(object_, axis) + animation = self.__get_animation_rotation( + object_, + axis) if animation is not None: libanm.appendChild(animation) - self.__export_instance_animation_parameters(object_, - animation_clip) + self.__export_instance_animation_parameters( + object_, + animation_clip) if is_animation: libanmcl.appendChild(animation_clip) @@ -762,15 +824,25 @@ def __export_instance_animation_parameters(self, object_, animation_clip): break if location_exists: - self.__export_instance_parameter(object_, animation_clip, 'location') + self.__export_instance_parameter( + object_, + animation_clip, + 'location') if rotation_exists: - self.__export_instance_parameter(object_, animation_clip, 'rotation_euler') + self.__export_instance_parameter( + object_, + animation_clip, + 'rotation_euler') def __export_instance_parameter(self, object_, animation_clip, parameter): for axis in iter(AXES): inst = self.__doc.createElement('instance_animation') - inst.setAttribute('url', - '#{!s}_{!s}_{!s}'.format(object_.name, parameter, axis)) + inst.setAttribute( + 'url', + '#{!s}_{!s}_{!s}'.format( + object_.name, + parameter, + axis)) animation_clip.appendChild(inst) def __get_animation_location(self, object_, axis): @@ -810,7 +882,8 @@ def __get_animation_attribute(self, source_prefix = '#{!s}'.format(id_prefix) for curve in object_.animation_data.action.fcurves: - if (curve.data_path == attribute_type and curve.array_index == AXES[axis]): + if (curve.data_path == + attribute_type and curve.array_index == AXES[axis]): keyframe_points = curve.keyframe_points sources = { 'input': [], @@ -828,20 +901,28 @@ def __get_animation_attribute(self, sources['input'].append(utils.frame_to_time(frame)) sources['output'].append(value * multiplier) - sources['interpolation'].append(keyframe_point.interpolation) - sources['intangent'].extend( [utils.frame_to_time(khlx), khly] ) - sources['outangent'].extend( [utils.frame_to_time(khrx), khry] ) + sources['interpolation'].append( + keyframe_point.interpolation) + sources['intangent'].extend( + [utils.frame_to_time(khlx), khly]) + sources['outangent'].extend( + [utils.frame_to_time(khrx), khry]) animation_element = self.__doc.createElement('animation') animation_element.setAttribute('id', id_prefix) for type_, data in sources.items(): - anim_node = self.__create_animation_node(type_, data, id_prefix) + anim_node = self.__create_animation_node( + type_, + data, + id_prefix) animation_element.appendChild(anim_node) sampler = self.__create_sampler(id_prefix, source_prefix) channel = self.__doc.createElement('channel') - channel.setAttribute('source', '{!s}-sampler'.format(source_prefix)) + channel.setAttribute( + 'source', + '{!s}-sampler'.format(source_prefix)) channel.setAttribute('target', target) animation_element.appendChild(sampler) @@ -852,14 +933,18 @@ def __get_animation_attribute(self, def __create_animation_node(self, type_, data, id_prefix): id_ = '{!s}-{!s}'.format(id_prefix, type_) type_map = { - 'input': ['float', ['TIME']], - 'output': ['float', ['VALUE']], - 'intangent': ['float', 'XY'], - 'outangent': ['float', 'XY'], - 'interpolation': ['name', ['INTERPOLATION']] + 'input': ['float', ['TIME']], + 'output': ['float', ['VALUE']], + 'intangent': ['float', 'XY'], + 'outangent': ['float', 'XY'], + 'interpolation': ['name', ['INTERPOLATION']] } - source = utils.write_source(id_, type_map[type_][0], data, type_map[type_][1]) + source = utils.write_source( + id_, + type_map[type_][0], + data, + type_map[type_][1]) return source @@ -875,13 +960,19 @@ def __create_sampler(self, id_prefix, source_prefix): output.setAttribute('source', '{!s}-output'.format(source_prefix)) interpolation = self.__doc.createElement('input') interpolation.setAttribute('semantic', 'INTERPOLATION') - interpolation.setAttribute('source', '{!s}-interpolation'.format(source_prefix)) + interpolation.setAttribute( + 'source', + '{!s}-interpolation'.format(source_prefix)) intangent = self.__doc.createElement('input') intangent.setAttribute('semantic', 'IN_TANGENT') - intangent.setAttribute('source', '{!s}-intangent'.format(source_prefix)) + intangent.setAttribute( + 'source', + '{!s}-intangent'.format(source_prefix)) outangent = self.__doc.createElement('input') outangent.setAttribute('semantic', 'OUT_TANGENT') - outangent.setAttribute('source', '{!s}-outangent'.format(source_prefix)) + outangent.setAttribute( + 'source', + '{!s}-outangent'.format(source_prefix)) sampler.appendChild(input) sampler.appendChild(output) @@ -907,7 +998,7 @@ def __export_library_visual_scenes(self, parent_element): for group in utils.get_export_nodes(): self.__write_export_node(group, visual_scene) else: - pass # TODO: Handle No Export Nodes Error + pass # TODO: Handle No Export Nodes Error def __write_export_node(self, group, visual_scene): nodename = 'CryExportNode_{}'.format(utils.get_node_name(group.name)) @@ -932,7 +1023,8 @@ def __write_export_node(self, group, visual_scene): def __write_visual_scene_node(self, objects, nodeparent, root): for object_ in objects: if object_.type == 'ARMATURE': - self.__write_bone_list([utils.get_root_bone(object_)], object_, root, root) + self.__write_bone_list( + [utils.get_root_bone(object_)], object_, root, root) node = root elif not utils.is_fakebone(object_): node = self.__doc.createElement('node') @@ -1000,15 +1092,24 @@ def __create_translation_node(self, object_): trans = self.__doc.createElement('translate') trans.setAttribute('sid', 'translation') trans_text = self.__doc.createTextNode('{:f} {:f} {:f}'.format( - * object_.location)) + * object_.location)) trans.appendChild(trans_text) return trans def __create_rotation_node(self, object_): - rotx = self.__write_rotation('X', '1 0 0 {:f}', object_.rotation_euler[0]) - roty = self.__write_rotation('Y', '0 1 0 {:f}', object_.rotation_euler[1]) - rotz = self.__write_rotation('Z', '0 0 1 {:f}', object_.rotation_euler[2]) + rotx = self.__write_rotation( + 'X', + '1 0 0 {:f}', + object_.rotation_euler[0]) + roty = self.__write_rotation( + 'Y', + '0 1 0 {:f}', + object_.rotation_euler[1]) + rotz = self.__write_rotation( + 'Z', + '0 0 1 {:f}', + object_.rotation_euler[2]) return rotx, roty, rotz @@ -1016,7 +1117,7 @@ def __write_rotation(self, axis, textFormat, rotation): rot = self.__doc.createElement('rotate') rot.setAttribute('sid', 'rotation_{}'.format(axis)) rot_text = self.__doc.createTextNode(textFormat.format( - rotation * utils.to_degrees)) + rotation * utils.to_degrees)) rot.appendChild(rot_text) return rot @@ -1025,7 +1126,7 @@ def __create_scale_node(self, object_): scale = self.__doc.createElement('scale') scale.setAttribute('sid', 'scale') scale_text = self.__doc.createTextNode( - utils.floats_to_string(object_.scale, ' ', '%s')) + utils.floats_to_string(object_.scale, ' ', '%s')) scale.appendChild(scale_text) return scale @@ -1037,8 +1138,8 @@ def __create_instance(self, object_): instance = self.__doc.createElement('instance_controller') # This binds the mesh object to the armature in control of it instance.setAttribute('url', '#{!s}_{!s}'.format( - armature.name, - object_.name)) + armature.name, + object_.name)) elif object_.name[:6] != '_joint' and object_.type == 'MESH': instance = self.__doc.createElement('instance_geometry') instance.setAttribute('url', '#{!s}'.format(object_.name)) @@ -1052,15 +1153,16 @@ def __create_bind_material(self, object_): bind_material = self.__doc.createElement('bind_material') technique_common = self.__doc.createElement('technique_common') - for materialname, material in self.__get_materials_for_object(object_).items(): + for materialname, material in self.__get_materials_for_object( + object_).items(): instance_material = self.__doc.createElement( - 'instance_material') + 'instance_material') instance_material.setAttribute('symbol', materialname) instance_material.setAttribute('target', '#{!s}'.format( - materialname)) + materialname)) bind_vertex_input = self.__doc.createElement( - 'bind_vertex_input') + 'bind_vertex_input') bind_vertex_input.setAttribute('semantic', 'UVMap') bind_vertex_input.setAttribute('input_semantic', 'TEXCOORD') bind_vertex_input.setAttribute('input_set', '0') @@ -1071,7 +1173,7 @@ def __create_bind_material(self, object_): bind_material.appendChild(technique_common) return bind_material - + def __create_cryengine_extra(self, node): extra = self.__doc.createElement('extra') technique = self.__doc.createElement('technique') @@ -1082,7 +1184,8 @@ def __create_cryengine_extra(self, node): node_type = utils.get_node_type(node.name) allowed = {'cgf', 'cga', 'chr', 'skin', 'anm', 'i_caf', 'caf'} if node_type in allowed: - prop = self.__doc.createTextNode('fileType={}'.format(node_type)) + prop = self.__doc.createTextNode( + 'fileType={}'.format(node_type)) properties.appendChild(prop) if self.__config.do_not_merge: prop = self.__doc.createTextNode('DoNotMerge') @@ -1092,7 +1195,9 @@ def __create_cryengine_extra(self, node): return for prop in node.rna_type.id_data.items(): if prop: - user_defined_property = self.__doc.createTextNode('{!s}'.format(prop[1])) + user_defined_property = self.__doc.createTextNode( + '{!s}'.format( + prop[1])) properties.appendChild(user_defined_property) technique.appendChild(properties) @@ -1108,11 +1213,19 @@ def __create_helper_joint(self, object_): x1, y1, z1, x2, y2, z2 = utils.get_bounding_box(object_) min = self.__doc.createElement('bound_box_min') - min_text = self.__doc.createTextNode('{:f} {:f} {:f}'.format(x1, y1, z1)) + min_text = self.__doc.createTextNode( + '{:f} {:f} {:f}'.format( + x1, + y1, + z1)) min.appendChild(min_text) max = self.__doc.createElement('bound_box_max') - max_text = self.__doc.createTextNode('{:f} {:f} {:f}'.format(x2, y2, z2)) + max_text = self.__doc.createTextNode( + '{:f} {:f} {:f}'.format( + x2, + y2, + z2)) max.appendChild(max_text) joint = self.__doc.createElement('helper') @@ -1132,33 +1245,34 @@ def __create_ik_properties(self, bone, object_, export_node): pose_bone = armature_object.pose.bones[bone.name[:-5]] props = join( - '%{!s}%'.format(nodename), - '--PRprops_name={!s}_'.format(props_name), - - 'xmax={!s}_'.format(pose_bone.ik_max_x), - 'xmin={!s}_'.format(pose_bone.ik_min_x), - 'xdamping={!s}_'.format(pose_bone.ik_stiffness_x), - 'xspringangle={!s}_'.format(0.0), - 'xspringtension={!s}_'.format(1.0), - - 'ymax={!s}_'.format(pose_bone.ik_max_y), - 'ymin={!s}_'.format(pose_bone.ik_min_y), - 'ydamping={!s}_'.format(pose_bone.ik_stiffness_y), - 'yspringangle={!s}_'.format(0.0), - 'yspringtension={!s}_'.format(1.0), - - 'zmax={!s}_'.format(pose_bone.ik_max_z), - 'zmin={!s}_'.format(pose_bone.ik_min_z), - 'zdamping={!s}_'.format(pose_bone.ik_stiffness_z), - 'zspringangle={!s}_'.format(0.0), - 'zspringtension={!s}_'.format(1.0) - ) + '%{!s}%'.format(nodename), + '--PRprops_name={!s}_'.format(props_name), + + 'xmax={!s}_'.format(pose_bone.ik_max_x), + 'xmin={!s}_'.format(pose_bone.ik_min_x), + 'xdamping={!s}_'.format(pose_bone.ik_stiffness_x), + 'xspringangle={!s}_'.format(0.0), + 'xspringtension={!s}_'.format(1.0), + + 'ymax={!s}_'.format(pose_bone.ik_max_y), + 'ymin={!s}_'.format(pose_bone.ik_min_y), + 'ydamping={!s}_'.format(pose_bone.ik_stiffness_y), + 'yspringangle={!s}_'.format(0.0), + 'yspringtension={!s}_'.format(1.0), + + 'zmax={!s}_'.format(pose_bone.ik_max_z), + 'zmin={!s}_'.format(pose_bone.ik_min_z), + 'zdamping={!s}_'.format(pose_bone.ik_stiffness_z), + 'zspringangle={!s}_'.format(0.0), + 'zspringtension={!s}_'.format(1.0) + ) return props def __export_scene(self, parent_element): scene = self.__doc.createElement('scene') - instance_visual_scene = self.__doc.createElement('instance_visual_scene') + instance_visual_scene = self.__doc.createElement( + 'instance_visual_scene') instance_visual_scene.setAttribute('url', '#scene') scene.appendChild(instance_visual_scene) parent_element.appendChild(scene) @@ -1170,7 +1284,7 @@ def write_scripts(config): return dae_path = utils.get_absolute_path_for_rc(filepath) - output_path = os.path.dirname(dae_path) + output_path = os.path.dirname(dae_path) chr_names = [] for group in utils.get_export_nodes(): if utils.get_node_type(group.name) == 'chr': diff --git a/io_export_cryblend/outPipe.py b/io_export_cryblend/outPipe.py index 224c59e..aa9225d 100644 --- a/io_export_cryblend/outPipe.py +++ b/io_export_cryblend/outPipe.py @@ -17,6 +17,7 @@ class OutPipe(): + def __init__(self): pass @@ -35,7 +36,7 @@ def pump(self, message, message_type='info'): else: raise exceptions.CryBlendException('No such message type {!r}'. - format(message_type)) + format(message_type)) op = OutPipe() @@ -43,4 +44,3 @@ def pump(self, message, message_type='info'): def cbPrint(msg, message_type='info'): op.pump(msg, message_type) - diff --git a/io_export_cryblend/rc.py b/io_export_cryblend/rc.py index adc2453..a1f2580 100644 --- a/io_export_cryblend/rc.py +++ b/io_export_cryblend/rc.py @@ -30,6 +30,7 @@ class RCInstance: + def __init__(self, config): self.__config = config @@ -48,6 +49,7 @@ def convert_dae(self, source): class _DAEConverter: + def __init__(self, config, source): self.__config = config self.__doc = source @@ -60,7 +62,11 @@ def __call__(self): dae_path = utils.get_absolute_path_for_rc(filepath) if not self.__config.disable_rc: - rc_params = ['/verbose', '/threads=processors', '/refresh', '/logfiles=1'] + rc_params = [ + '/verbose', + '/threads=processors', + '/refresh', + '/logfiles=1'] if self.__config.do_materials: rc_params.append('/createmtl=1') @@ -89,8 +95,12 @@ def __recompile(self, dae_path): allowed = ['cgf', 'cga', 'chr', 'skin'] if node_type in allowed: out_file = '{0}{1}'.format(output_path, - group.name) - args = [self.__config.rc_path, '/refresh', '/vertexindexformat=u16', out_file] + group.name) + args = [ + self.__config.rc_path, + '/refresh', + '/vertexindexformat=u16', + out_file] if (self.__config.suppress_printouts): args.append('/quiet') rc_second_pass = subprocess.Popen(args) @@ -126,7 +136,9 @@ def __make_layer(self): object_node.setAttribute('name', group.name[14:]) object_node.setAttribute('Type', 'Entity') object_node.setAttribute('Id', utils.get_guid()) - object_node.setAttribute('LayerGUID', layer.getAttribute('GUID')) + object_node.setAttribute( + 'LayerGUID', + layer.getAttribute('GUID')) object_node.setAttribute('Layer', layer_name) cbPrint(origin) positionString = "%s, %s, %s" % origin[:] @@ -186,7 +198,9 @@ def __make_layer(self): return layer_doc.toprettyxml(indent=" ") + class _TIFConverter: + def __init__(self, config, source): self.__config = config self.__images = source @@ -206,15 +220,20 @@ def __call__(self): self.__save_as_tiff(image, tiff_path) rc_process = run_rc(self.__config.texture_rc_path, - tiff_path, - self.__get_rc_params()) + tiff_path, + self.__get_rc_params()) rc_process.wait() if not self.__config.save_tiffs: self.__remove_tiffs() def __get_rc_params(self): - params = ['/verbose', '/threads=cores', '/userdialog=1', '/refresh', '/quiet'] + params = [ + '/verbose', + '/threads=cores', + '/userdialog=1', + '/refresh', + '/quiet'] if (self.__config.suppress_printouts): params.append('/quiet') diff --git a/io_export_cryblend/utils.py b/io_export_cryblend/utils.py index 5656313..b4b54c3 100644 --- a/io_export_cryblend/utils.py +++ b/io_export_cryblend/utils.py @@ -75,6 +75,7 @@ def matrix_to_array(matrix): return array + def write_matrix(matrix, node): doc = Document() for row in matrix: @@ -189,7 +190,7 @@ def normalize_path(path): if path[0] == "/": path = path[1:] - + if path[-1] == "/": path = path[:-1] @@ -198,7 +199,7 @@ def normalize_path(path): def build_path(*components): path = "/".join(components) - path = path.replace("/.", ".") # accounts for extension + path = path.replace("/.", ".") # accounts for extension return normalize_path(path) @@ -215,7 +216,7 @@ def trim_path_to(path, trim_to): for index, component in enumerate(components): if component == trim_to: cbPrint("FOUND AN INSTANCE") - break; + break cbPrint(index) components_trimmed = components[index:] cbPrint(components_trimmed) @@ -260,21 +261,21 @@ def replace_invalid_rc_characters(string): string = '_'.join(string.split()) character_map = { - '_': '.', - 'a': 'àáâå', - 'c': 'ç', - 'e': 'èéêë', - 'i': 'ìíîï', - 'l': 'ł', - 'n': 'ñ', - 'o': 'òóô', - 'u': 'ùúû', - 'y': 'ÿ', + '_': '.', + 'a': 'àáâå', + 'c': 'ç', + 'e': 'èéêë', + 'i': 'ìíîï', + 'l': 'ł', + 'n': 'ñ', + 'o': 'òóô', + 'u': 'ùúû', + 'y': 'ÿ', 'ss': 'ß', 'ae': 'äæ', 'oe': 'ö', 'ue': 'ü' - } # Expand with more individual replacement rules. + } # Expand with more individual replacement rules. # Individual replacement. for good, bad in character_map.items(): @@ -292,9 +293,12 @@ def fix_weights(): for object_ in get_type('skins'): override = get_3d_context(object_) try: - bpy.ops.object.vertex_group_normalize_all(override, lock_active=False) + bpy.ops.object.vertex_group_normalize_all( + override, + lock_active=False) except: - raise exceptions.CryBlendException('Please fix weightless vertices first.') + raise exceptions.CryBlendException( + 'Please fix weightless vertices first.') cbPrint('Weights Corrected.') @@ -335,6 +339,7 @@ def get_type(type_): } return list(set(dispatch[type_]())) + def __get_nodes(): items = [] for group in get_export_nodes(): @@ -342,15 +347,17 @@ def __get_nodes(): return items + def __get_geometry(): items = [] allowed = {'MESH'} for object_ in get_type('nodes'): if object_.type in allowed and not is_fakebone(object_): - items.append(object_) + items.append(object_) return items + def __get_controllers(): items = [] for object_ in get_type('nodes'): @@ -362,6 +369,7 @@ def __get_controllers(): return items + def __get_skins(): items = [] allowed = {'MESH'} @@ -375,6 +383,7 @@ def __get_skins(): return items + def __get_fakebones(): items = [] allowed = {'MESH'} @@ -384,6 +393,7 @@ def __get_fakebones(): return items + def __get_bone_geometry(): items = [] allowed = {'MESH'} @@ -394,6 +404,7 @@ def __get_bone_geometry(): return items + def __get_materials(): items = [] allowed = {'MESH'} @@ -404,6 +415,7 @@ def __get_materials(): return items + def __get_texture_slots(): items = [] for material in get_type('materials'): @@ -411,6 +423,7 @@ def __get_texture_slots(): return items + def __get_textures(): items = [] texture_slots = get_type('texture_slots') @@ -462,13 +475,15 @@ def raise_exception_if_textures_have_same_type(texture_types): ERROR_TEMPLATE = 'There is more than one texture of type {!r}.' error_messages = [] - for type_name, type_count in texture_types.items(): + for type_name, type_count in texture_types.items(): if type_count > 1: error_messages.append(ERROR_TEMPLATE.format(type_name.lower())) if error_messages: - raise exceptions.CryBlendException('\n'.join(error_messages) + '\n' - + 'Please correct that and try again.') + raise exceptions.CryBlendException( + '\n'.join(error_messages) + + '\n' + + 'Please correct that and try again.') def is_valid_image(image): @@ -544,7 +559,7 @@ def are_duplicate_nodes(): def get_node_name(groupname): node_type = get_node_type(groupname) - return groupname[:-(len(node_type)+1)] + return groupname[:-(len(node_type) + 1)] def get_node_type(groupname): @@ -649,7 +664,7 @@ def keyframe_fakebones(armature): fakebone.keyframe_insert(data_path='location') fakebone.keyframe_insert(data_path='rotation_euler') i += 1 - + scene.frame_set(scene.frame_start) @@ -891,26 +906,26 @@ def fix_write_xml(self, writer, indent='', addindent='', newl=''): # indent = current indentation # addindent = indentation to add to higher levels # newl = newline string - writer.write(indent + '<' + self.tagName) - attrs = self._get_attributes() - for a_name in sorted(attrs.keys()): - writer.write(' %s=\'' % a_name) - xml.dom.minidom._write_data(writer, attrs[a_name].value) - writer.write('\'') - if self.childNodes: - if (len(self.childNodes) == 1 - and self.childNodes[0].nodeType - == xml.dom.minidom.Node.TEXT_NODE): - writer.write('>') - self.childNodes[0].writexml(writer, '', '', '') - writer.write('%s' % (self.tagName, newl)) - return - writer.write('>%s' % (newl)) - for node in self.childNodes: - node.writexml(writer, indent + addindent, addindent, newl) - writer.write('%s%s' % (indent, self.tagName, newl)) - else: - writer.write('/>%s' % (newl)) + writer.write(indent + '<' + self.tagName) + attrs = self._get_attributes() + for a_name in sorted(attrs.keys()): + writer.write(' %s=\'' % a_name) + xml.dom.minidom._write_data(writer, attrs[a_name].value) + writer.write('\'') + if self.childNodes: + if (len(self.childNodes) == 1 + and self.childNodes[0].nodeType + == xml.dom.minidom.Node.TEXT_NODE): + writer.write('>') + self.childNodes[0].writexml(writer, '', '', '') + writer.write('%s' % (self.tagName, newl)) + return + writer.write('>%s' % (newl)) + for node in self.childNodes: + node.writexml(writer, indent + addindent, addindent, newl) + writer.write('%s%s' % (indent, self.tagName, newl)) + else: + writer.write('/>%s' % (newl)) # this is needed if you want to access more than the first def