Skip to content

Commit

Permalink
Merge pull request #73 from daz3d/develop
Browse files Browse the repository at this point in the history
Update for June
  • Loading branch information
samjay3d authored Jun 21, 2021
2 parents 8259f9a + 7b06b00 commit 4c3dcbf
Show file tree
Hide file tree
Showing 6 changed files with 286 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,16 @@ def finish_obj(self):
Versions.reverse_language()
Versions.pivot_active_element_and_center_and_trnormal()
Global.setRenderSetting(True)


def layGround(self):
bpy.context.preferences.inputs.use_mouse_depth_navigate = True
Util.deleteEmptyDazCollection()
bpy.context.scene.render.engine = 'CYCLES'
bpy.context.space_data.shading.type = 'SOLID'
bpy.context.space_data.shading.color_type = 'OBJECT'
bpy.context.space_data.shading.show_shadows = False
if bpy.context.window_manager.update_scn_settings:
bpy.context.preferences.inputs.use_mouse_depth_navigate = True
bpy.context.scene.render.engine = 'CYCLES'
bpy.context.space_data.shading.type = 'SOLID'
bpy.context.space_data.shading.color_type = 'OBJECT'
bpy.context.space_data.shading.show_shadows = False
Versions.set_english()
bco = bpy.context.object
if bco != None and bco.mode != 'OBJECT':
Expand Down Expand Up @@ -288,12 +290,15 @@ def import_one(self,fbx_adr):
DtbIKBones.set_scene_settings(anim.total_key_count)
self.pbar(100,wm)
DtbIKBones.ik_access_ban = False
if bpy.context.window_manager.morph_prefix:
bpy.ops.rename.morphs()
self.report({"INFO"}, "Success")
else:
self.show_error()

wm.progress_end()
DtbIKBones.ik_access_ban = False


def execute(self, context):
if self.root == "":
Expand All @@ -308,6 +313,7 @@ def execute(self, context):
Global.load_asset_name()
self.import_one(fbx_adr)
self.finish_obj()

return {'FINISHED'}

def show_error(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ def draw(self, context):

l.separator()

# l.operator('df.optimize', icon="MATERIAL")
class DTB_PT_RIGGING(View3DPanel, bpy.types.Panel):
bl_idname = "VIEW3D_PT_rigging_daz"
bl_label = "Rigging Tools"
Expand Down Expand Up @@ -172,21 +171,23 @@ def draw(self, context):

class DTB_PT_GENERAL(View3DPanel, bpy.types.Panel):
bl_idname = "VIEW3D_PT_general_daz"
bl_label = "General Settings"
bl_label = "Import Settings"
bl_options = {"DEFAULT_CLOSED"}

def draw(self, context):
l = self.layout
box = l.box()
w_mgr = context.window_manager
row = box.row(align=True)
row.prop(w_mgr, "quick_heavy", text="Quick But Heavy", toggle=False)
col = box.column(align=True, heading="Material Settings")
col.prop(w_mgr, "combine_materials", text="Combine Dupe Materials", toggle=False)
box = l.box()
col = box.column(align=True, heading="Morph Settings")
col.prop(w_mgr, "morph_prefix", text="Remove Morph Prefix", toggle=False)
box = l.box()
col = box.column(align=True)
col.prop(w_mgr, "update_viewport", text="Update Viewport and Units", toggle=False)
col = box.column(align=True, heading="Scenes Settings")
col.prop(w_mgr, "update_scn_settings", text="Update Viewport Shading", toggle=False)
col.prop(w_mgr, "update_viewport", text="Update Camera and Units", toggle=False)
col.prop(w_mgr, "scene_scale", text = "")
l.operator('refresh.alldaz', icon='BOIDS')
l.operator('remove.alldaz', icon='BOIDS')


class DTB_PT_COMMANDS(View3DPanel, bpy.types.Panel):
Expand Down Expand Up @@ -246,6 +247,9 @@ def draw(self, context):
row.prop(w_mgr, "choose_daz_figure", text = "")
row.operator('refresh.alldaz', text = "" ,icon='FILE_REFRESH')
box.operator("rename.morphs", icon = "OUTLINER_DATA_MESH")
l.operator('refresh.alldaz', icon='BOIDS')
l.operator('remove.alldaz', icon='BOIDS')


class DTB_PT_MORE_INFO(View3DPanel, bpy.types.Panel):
bl_idname = "VIEW3D_PT_info_daz"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,51 @@ def load_morph_link_list(self):
# Read all the morph links from the DTU
return self.morph_links_dict

def add_main_control(self,
key_block,
mesh_obj,
morph_label,
shape_key_min,
shape_key_max,
driver):
# Skip Basis shape key
if key_block.name == "Basis":
return

# Create a custom property and set limits
mesh_obj[morph_label] = 0.0
rna_ui = mesh_obj.get('_RNA_UI')
if rna_ui is None:
mesh_obj['_RNA_UI'] = {}
rna_ui = mesh_obj.get('_RNA_UI')
rna_ui[morph_label] = {
"min": shape_key_min,
"max": shape_key_max,
"soft_min": shape_key_min,
"soft_max": shape_key_max
}

# Add variable
link_var = driver.variables.new()
link_var.name = self.get_next_var_name()
link_var.type = 'SINGLE_PROP'

# Set variable target
target = link_var.targets[0]
target.id_type = 'OBJECT'
target.id = mesh_obj
rna_data_path = "[\"" + morph_label + "\"]"
target.data_path = rna_data_path

# Set the Limits for Shapekey
key_block.slider_min = shape_key_min
key_block.slider_max = shape_key_max

# Add to the Global list, so it can be used in the Daz To Blender Panel
Global.load_shape_key_custom_props(mesh_obj.name, morph_label)

return "(" + link_var.name + "*1)"

def add_custom_shape_key_prop(self, key_block, mesh_obj, morph_label, shape_key_min, shape_key_max):
# Skip Basis shape key
if key_block.name == "Basis":
Expand Down Expand Up @@ -339,8 +384,9 @@ def combine_target_expression(self, exp, morph_links, link_index):
return exp + ")"

elif (link_type in second_stage) and (link_index > 0):
return "*" + exp

return "*" + exp
elif (link_type in second_stage) and (link_index == 0):
return "0 *" + exp
elif (next_index == len(morph_links)) and (len(morph_links) > 1):
return exp + ")"

Expand Down Expand Up @@ -380,9 +426,12 @@ def make_body_mesh_drivers(self, body_mesh_obj):

morph_label = morph_links_list[key_name]["Label"]
morph_links = morph_links_list[key_name]["Links"]
morph_hidden = morph_links_list[key_name]["isHidden"]

shape_key_min = float(morph_links_list[key_name]["Minimum"])
shape_key_max = float(morph_links_list[key_name]["Maximum"])


# If morph_links is empty add a custom property
if not morph_links:
# Create custom property for this shape key and drive it
Expand Down Expand Up @@ -434,7 +483,26 @@ def make_body_mesh_drivers(self, body_mesh_obj):
# break when the limit is reached to avoid errors
break
expression += self.combine_target_expression(exp, updated_morph_links, link_index)


# Trim the extra chars
if expression.endswith("+"):
expression = expression[:-1]
if expression.startswith("*"):
expression = expression[1:]
if expression.endswith("))") and var_count == 1:
expression = expression[:-1]

if not morph_hidden:
expression = "(" + expression + ") +"
expression += self.add_main_control(
key_block,
body_mesh_obj,
morph_label,
shape_key_min,
shape_key_max,
driver
)

# Delete the driver and continue if there are no variables
if var_count == 0:
key_block.driver_remove("value")
Expand All @@ -447,14 +515,6 @@ def make_body_mesh_drivers(self, body_mesh_obj):
shape_key_max
)
continue

# Trim the extra chars
if expression.endswith("+"):
expression = expression[:-1]
if expression.startswith("*"):
expression = expression[1:]
if expression.endswith("))") and var_count == 1:
expression = expression[:-1]

driver.expression = expression

Expand All @@ -463,6 +523,7 @@ def make_body_mesh_drivers(self, body_mesh_obj):
key_block.slider_max = shape_key_max

def make_other_mesh_drivers(self, other_mesh_obj, body_mesh_obj):
other_mesh_name_shape = other_mesh_obj.name
other_mesh_name = other_mesh_obj.data.name
body_mesh_name = body_mesh_obj.data.name

Expand All @@ -484,6 +545,20 @@ def make_other_mesh_drivers(self, other_mesh_obj, body_mesh_obj):
if not other_key_name:
continue

# Continue if other_key_name not found in morph_links_list
if other_key_name not in morph_links_list:
other_mesh_obj.shape_key_remove(other_block)
continue

morph_label = morph_links_list[other_key_name]["Label"]
morph_links = morph_links_list[other_key_name]["Links"]
shape_key_min = float(morph_links_list[other_key_name]["Minimum"])
shape_key_max = float(morph_links_list[other_key_name]["Maximum"])
controled_meshes = morph_links_list[other_key_name]["Controlled Meshes"]
if other_mesh_name_shape not in controled_meshes:
other_mesh_obj.shape_key_remove(other_block)
continue

body_key_name = self.get_control_shape_key(
other_key_name,
body_mesh_name,
Expand All @@ -507,14 +582,7 @@ def make_other_mesh_drivers(self, other_mesh_obj, body_mesh_obj):
rna_data_path = "key_blocks[\"" + block_id + "\"].value"
target.data_path = rna_data_path
else:
# Continue if other_key_name not found in morph_links_list
if other_key_name not in morph_links_list:
continue

morph_label = morph_links_list[other_key_name]["Label"]
morph_links = morph_links_list[other_key_name]["Links"]
shape_key_min = float(morph_links_list[other_key_name]["Minimum"])
shape_key_max = float(morph_links_list[other_key_name]["Maximum"])


# If morph_links is empty add a custom property
if not morph_links:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,10 @@
from . import Global
from . import Util
#BV
if bpy.app.version == (2, 79, 0):
BV = 2.79
elif bpy.app.version == (2, 80, 0):
BV = 2.80
elif bpy.app.version == (2, 81, 0):
BV = 2.81
elif bpy.app.version == (2, 82, 0):
BV = 2.82
elif bpy.app.version == (2, 83, 0):
BV = 2.83
elif bpy.app.version == (2, 90, 0):
BV = 2.90
elif bpy.app.version == (2, 91, 0):
BV = 2.91
elif bpy.app.version == (2, 92, 0):
BV = 2.92
else:
BV = 2.93
def get_version():
return bpy.app.version[0] + (bpy.app.version[1]/100)

BV = get_version()

my_local_language = 'en_US'

Expand Down Expand Up @@ -444,7 +430,7 @@ def get_language():
return 'ho_GE'
else:
return 'en_US'
elif BV<2.83:
elif BV < 2.83:
if bpy.context.preferences.view.use_international_fonts:
return 'ho_GE'
else:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bl_info = {
"name": "DazToBlender",
"author": "Daz 3D | https://www.daz3d.com",
"version": (2, 3, 7),
"version": (2, 3, 9),
"blender": (2, 80, 0),
"location": "3DView > ToolShelf",
"description": "Daz 3D Genesis 3/8 transfer to Blender",
Expand Down Expand Up @@ -301,8 +301,9 @@ def init_props():
w_mgr.ifk3 = BoolProperty(name="fik3", default=False, update=DtbIKBones.ifk_update3)
w_mgr.new_morph = BoolProperty(name="_new_morph",default=False)
w_mgr.skip_isk = BoolProperty(name = "_skip_isk",default = False)
w_mgr.update_viewport = BoolProperty(name="update_viewport", description ="Updates the Viewport, Scene Settings, and Camera for your Scale", default=True)
w_mgr.quick_heavy = BoolProperty(name="quick_heavy", default=False)
w_mgr.update_scn_settings = BoolProperty(name="update_viewport", description ="Updates the Render Engine, Shading Type, and Using Depth Under Mouse", default=True)
w_mgr.update_viewport = BoolProperty(name="update_viewport", description ="Updates the Viewport, and Camera for your Scale", default=True)
w_mgr.morph_prefix = BoolProperty(name="morph_prefix", default=True)
w_mgr.combine_materials = BoolProperty(name="combine_materials", default=True)
w_mgr.add_pose_lib = BoolProperty(name="add_pose_lib", default=True)
figure_items = [("null" , "Choose Character", "Select which figure you wish to import")]
Expand Down Expand Up @@ -331,12 +332,10 @@ def init_props():


classes = (

DtbPanels.DTB_PT_MAIN,
DtbPanels.DTB_PT_RIGGING,
DtbPanels.DTB_PT_POSE,
DtbPanels.DTB_PT_MORPHS,
DtbPanels.DTB_PT_MATERIAL,
DtbPanels.DTB_PT_GENERAL,
DtbPanels.DTB_PT_COMMANDS,
DtbPanels.DTB_PT_UTILITIES,
Expand Down
Loading

0 comments on commit 4c3dcbf

Please sign in to comment.