Skip to content

Commit

Permalink
Merge pull request #141 from travnick/feature/remove_deprecated_features
Browse files Browse the repository at this point in the history
[#6][#124]Remove deprecated features
  • Loading branch information
Daniel White committed Feb 14, 2016
2 parents e19149d + 85da48c commit cd93bba
Showing 1 changed file with 5 additions and 173 deletions.
178 changes: 5 additions & 173 deletions io_export_cryblend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,153 +271,6 @@ def execute(self, context):
return {'FINISHED'}


#------------------------------------------------------------------------------
# Material Tools:
#------------------------------------------------------------------------------

class SetMaterialNames(bpy.types.Operator):
'''Materials will be named after the first CryExportNode the Object is in.'''
"""Set Material Names by heeding the RC naming scheme:
- CryExportNode group name
- Strict number sequence beginning with 1 for each CryExportNode (max 999)
- Physics
"""
bl_label = "Update material names in CryExportNodes"
bl_idname = "material.set_material_names"

material_name = StringProperty(name="Cry Material Name")
material_phys = EnumProperty(
name="Physic Proxy",
items=(
("physDefault", "Default", desc.list['physDefault']),
("physProxyNoDraw", "Physical Proxy", desc.list['physProxyNoDraw']),
("physNoCollide", "No Collide", desc.list['physNoCollide']),
("physObstruct", "Obstruct", desc.list['physObstruct']),
("physNone", "None", desc.list['physNone'])
),
default="physDefault")

just_rephysic = BoolProperty(
name="Only Physic",
description="Only change physic of selected material.")

object_ = None
errorReport = None

def __init__(self):
cryNodeReport = "Please select a object that in a Cry Export node" \
+ " for 'Do Material Convention'. If you have not created" \
+ " it yet, please create it with 'Add ExportNode' tool."

self.object_ = bpy.context.active_object

if self.object_ is None or self.object_.users_group is None:
self.errorReport = cryNodeReport
return None

for group in self.object_.users_group:
if utils.is_export_node(group.name):
self.material_name = utils.get_node_name(group.name)
return None

self.errorReport = cryNodeReport

return None

def execute(self, context):
if self.errorReport is not None:
return {'FINISHED'}

if self.just_rephysic:
return add.add_phys_material(self, context, self.material_phys)

# Revert all materials to fetch also those that are no longer in a group
# and store their possible physics properties in a dictionary.
physicsProperties = getMaterialPhysics()
removeCryBlendProperties()

# Create a dictionary with all CryExportNodes to store the current number
# of materials in it.
materialCounter = getMaterialCounter()

for group in self.object_.users_group:
if utils.is_export_node(group.name):
for object in group.objects:
for slot in object.material_slots:

# Skip materials that have been renamed already.
if not utils.is_cryblend_material(slot.material.name):
materialCounter[group.name] += 1
materialOldName = slot.material.name

# Load stored Physics if available for that
# material.
if physicsProperties.get(slot.material.name):
physics = physicsProperties[slot.material.name]
else:
physics = self.material_phys

# Rename.
slot.material.name = "{}__{:02d}__{}__{}".format(
self.material_name,
materialCounter[group.name],
utils.replace_invalid_rc_characters(materialOldName),
physics)
message = "Renamed {} to {}".format(
materialOldName,
slot.material.name)
self.report({'INFO'}, message)
cbPrint(message)
return {'FINISHED'}

def invoke(self, context, event):
if self.errorReport is not None:
return self.report({'ERROR'}, self.errorReport)

return context.window_manager.invoke_props_dialog(self)


class RemoveCryBlendProperties(bpy.types.Operator):
'''Removes all CryBlend properties from material names. This includes \
physics, so they get lost.'''
bl_label = "Remove CryBlend properties from material names"
bl_idname = "material.remove_cry_blend_properties"

def execute(self, context):
removeCryBlendProperties()
message = "Removed CryBlend properties from material names"
self.report({'INFO'}, message)
cbPrint(message)
return {'FINISHED'}


def getMaterialCounter():
"""Returns a dictionary with all CryExportNodes."""
materialCounter = {}
for group in bpy.data.groups:
if utils.is_export_node(group.name):
materialCounter[group.name] = 0
return materialCounter


def removeCryBlendProperties():
"""Removes CryBlend properties from all material names."""
for material in bpy.data.materials:
properties = utils.extract_cryblend_properties(material.name)
if properties:
material.name = properties["Name"]


def getMaterialPhysics():
"""Returns a dictionary with the physics of all material names."""
physicsProperties = {}
for material in bpy.data.materials:
properties = utils.extract_cryblend_properties(material.name)
if properties:
physicsProperties[properties["Name"]] = properties["Physics"]
return physicsProperties


#------------------------------------------------------------------------------
# CryEngine-Related Tools:
#------------------------------------------------------------------------------
Expand Down Expand Up @@ -1999,16 +1852,6 @@ def draw(self, context):
layout = self.layout
col = layout.column(align=True)

col.label("Materials", icon="MATERIAL")
col.separator()
col.operator(
"material.set_material_names",
text="Do Material Convention")
col.operator(
"material.remove_cry_blend_properties",
text="Undo Material Convention")
col.separator()

col.label("Add Physics Proxy", icon="ROTATE")
col.separator()
row = col.row(align=True)
Expand Down Expand Up @@ -2042,23 +1885,22 @@ def draw(self, context):
layout = self.layout
col = layout.column(align=True)

col.label("Skeleton", icon="BONE_DATA")
col.label("Skeleton", icon="ARMATURE_DATA")
col.separator()
col.operator("armature.add_root_bone", text="Add Root Bone")
col.operator(
"ops.apply_animation_scaling",
text="Apply Animation Scaling")
col.operator("scene.remove_fake_bones", text="Remove Old Fakebones")

col.separator()
col.label(text="Bone")

col.label(text="Bone", icon="BONE_DATA")
col.separator()
col.operator(
"object.edit_inverse_kinematics",
text=" Edit Inverse Kinematics",
icon="CONSTRAINT")

text=" Edit Inverse Kinematics")
col.separator()

col.label("Physics", icon="PHYSICS")
col.separator()
col.operator("armature.add_bone_geometry", text="Add BoneGeometry")
Expand Down Expand Up @@ -2142,14 +1984,6 @@ def draw(self, context):
"object.selected_to_cry_export_nodes",
text="ExportNodes from Objects")
layout.separator()
layout.operator(
"material.set_material_names",
text="Do Material Convention",
icon="MATERIAL")
layout.operator(
"material.remove_cry_blend_properties",
text="Undo Material Convention")
layout.separator()
layout.operator(
"object.apply_transforms",
text="Apply All Transforms",
Expand Down Expand Up @@ -2454,8 +2288,6 @@ def get_classes_to_register():

AddCryExportNode,
SelectedToCryExportNodes,
SetMaterialNames,
RemoveCryBlendProperties,
AddRootBone,
ApplyTransforms,
AddProxy,
Expand Down

0 comments on commit cd93bba

Please sign in to comment.