Skip to content

Commit

Permalink
G9, IK hotfixes
Browse files Browse the repository at this point in the history
This commit incorporates some code from https://github.com/babebridou/DazToC4D
==================================

commit 1fef0bd7ca3e902f339ddb3a85b1cb5af332d6e2
Author: danielbui78 <danielbui78@gmail.com>
Date:   Tue Mar 14 01:36:35 2023 -0400

    code and file cleanup

commit f870589c7f6980037ab7a67be7295a879b004160
Author: danielbui78 <danielbui78@gmail.com>
Date:   Tue Mar 14 01:09:52 2023 -0400

    two twist bones

commit df4596be28f49d6183f639b61c10c72485e0bfd2
Author: danielbui78 <danielbui78@gmail.com>
Date:   Tue Mar 14 00:16:48 2023 -0400

    one forearm twist bone (distal)

commit c32db76209ba281244efff2544f98612a539f0a0
Author: danielbui78 <danielbui78@gmail.com>
Date:   Mon Mar 13 20:55:11 2023 -0400

    fix g9 eyes ik

commit ae27212e5f7279fcd014d415bb7f63bcdd8f684d
Author: danielbui78 <danielbui78@gmail.com>
Date:   Fri Jan 27 11:39:22 2023 -0800

    dev-2-hotfix-package (g9 support, prelim autoik)

commit 85773881b6e4249c93d3625fa2d289fb1a59990f
Author: danielbui78 <danielbui78@gmail.com>
Date:   Wed Jan 25 19:40:09 2023 -0800

    g9 autoIK support, part 1

commit 1a691362d7ee9ca5ac987fbfca0c1d075d610715
Author: danielbui78 <danielbui78@gmail.com>
Date:   Tue Jan 24 09:59:09 2023 -0800

    g9 support, part 2

commit 9c0a37ea935202eee1189bedda983851b400bff4
Author: danielbui78 <danielbui78@gmail.com>
Date:   Tue Jan 24 09:58:32 2023 -0800

    crashfixes: better error handling

commit 44d4b82b3d8f2b0c1e578582f33dec34aed0b2a5
Author: danielbui78 <danielbui78@gmail.com>
Date:   Tue Jan 24 09:56:14 2023 -0800

    g9 database updates, part 1

commit b93a0e0f5f4157f3e803f531a04b61446fdf8539
Author: danielbui78 <danielbui78@gmail.com>
Date:   Tue Jan 24 09:54:16 2023 -0800

    dev-1 hotfix package

commit 1e829ed9961247037e28302385a845ee9281aad6
Author: danielbui78 <danielbui78@gmail.com>
Date:   Mon Dec 5 12:19:02 2022 -0800

    GUI Bugfix: "fix bone orientation" prompt

Co-Authored-By: Thomas Philipakis <415308+babebridou@users.noreply.github.com>
  • Loading branch information
danielbui78 and babebridou committed Mar 14, 2023
1 parent d5d27f4 commit 89d4459
Show file tree
Hide file tree
Showing 11 changed files with 314 additions and 88 deletions.
4 changes: 2 additions & 2 deletions Cinema 4D/appdir_common/plugins/DazToC4D/DazToC4D.pyp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
DZBRIDGE_VERSION_MAJOR = 2022
DZBRIDGE_VERSION_MINOR = 2
DZBRIDGE_VERSION_REVISION = 12
DZBRIDGE_VERSION_BUILD = 24
DZBRIDGE_VERSION_REVISION = 13
DZBRIDGE_VERSION_BUILD = 26
DZBRIDGE_VERSION_STRING = "v%s.%s.%s.%s" % (DZBRIDGE_VERSION_MAJOR, DZBRIDGE_VERSION_MINOR, DZBRIDGE_VERSION_REVISION, DZBRIDGE_VERSION_BUILD)
##
## DazToC4D
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,23 +152,30 @@ def genesis_import(self, file_path, dtu, sss_value, normal_value, bump_value):
# pose.clear_pose(var.c_joints)
# pose.fix_offset(var.c_joints, var.c_skin_data)

#print(f"DEBUG 0: is_anim={is_anim} is_posed={is_posed}")
if (is_anim == False and is_posed == False) or override_pose:
fix_bone_rotations == gui.QuestionDialog(
fix_bone_rotations = gui.QuestionDialog(
"Would you like to fix bone orientations?",
)
#print(f"fix_bone_rotations={fix_bone_rotations}")
if fix_bone_rotations:
#print(f"DEBUG 1: fix_bone_rotations={fix_bone_rotations} is_posed={is_posed}")
jnt_fixes.store_joint_orientations(dtu)
jnt_fixes.fix_joints(var.c_skin_data, var.c_joints, var.c_meshes)
c4d.EventAdd()
dzc4d.deselect_all()
#print(f"DEBUG 2: fix_bone_rotations={fix_bone_rotations} is_posed={is_posed}")
if is_posed:
pose.restore_pose(var.c_joints)
#print(f"DEBUG 3: fix_bone_rotations={fix_bone_rotations} is_posed={is_posed}")
make_tpose = gui.QuestionDialog(
"Would you like to Convert\nthe Base Pose to a T-Pose?",
)
#print(f"DEBUG 4: make_tpose={make_tpose}")
if make_tpose:
pose.preAutoIK()
c4d.EventAdd()
#print(f"DEBUG 5: make_tpose={make_tpose}")

else:
gui.MessageDialog(
Expand Down
153 changes: 111 additions & 42 deletions Cinema 4D/appdir_common/plugins/DazToC4D/lib/Database.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import c4d

"""
Storing the AutoIK Hardcoded values to be replaced later down the road
Storing the AutoIK Hardcoded values to be replaced later down the road
so this isn't necessary
"""

Expand Down Expand Up @@ -104,6 +104,40 @@
["Thumb3", "jThumb3"],
]

constraint_joints_g9 = [
["_shoulder", "jCollar"],
["_upperarm", "jArm"],
["_forearm", "jForeArm"],
#["_forearmtwist1", "ForearmTwist_ctrl"],
["_hand", "jHand"],
["hip", "jPelvis"], ## shared
["pelvis", "jPelvis"], ## shared
["spine1", "jSpine"],
["spine2", "jAbdomenUpper"],
["spine3", "jChest"],
["spine4", "jChestUpper"],
["neck1", "jNeck"],
["head", "jHead"], ## shared
["_thigh", "jUpLeg"],
["_foot", "jFoot"],
["_shin", "jLeg"],
["_toes", "jToes"],
["_index1", "jIndex1"],
["_index2", "jIndex2"],
["_index3", "jIndex3"],
["_mid1", "jMiddle1"],
["_mid2", "jMiddle2"],
["_mid3", "jMiddle3"],
["_ring1", "jRing1"],
["_ring2", "jRing2"],
["_ring3", "jRing3"],
["_pinky1", "jPink1"],
["_pinky2", "jPink2"],
["_pinky3", "jPink3"],
["_thumb1", "jThumb1"],
["_thumb2", "jThumb2"],
["_thumb3", "jThumb3"],
]

rig_joints = [
["Collar", "jCollar"],
Expand Down Expand Up @@ -146,53 +180,83 @@
["Thumb3", "jThumb3"],
]

rig_joints_g9 = [
["_shoulder", "jCollar"],
["_upperarm", "jArm"],
["_forearm", "jForeArm"],
#["_forearmtwist1", "ForearmTwist_ctrl"],
["_hand", "jHand"],
["hip", "jPelvis"], ## shared
["pelvis", "jPelvis"], ## shared
["spine1", "jSpine"],
["spine2", "jAbdomenUpper"],
["spine3", "jChest"],
["spine4", "jChestUpper"],
["neck1", "jNeck"],
["head", "jHead"], ## shared
["_thigh", "jUpLeg"],
["_foot", "jFoot"],
["_shin", "jLeg"],
["_toes", "jToes"],
["_index1", "jIndex1"],
["_index2", "jIndex2"],
["_index3", "jIndex3"],
["_mid1", "jMiddle1"],
["_mid2", "jMiddle2"],
["_mid3", "jMiddle3"],
["_ring1", "jRing1"],
["_ring2", "jRing2"],
["_ring3", "jRing3"],
["_pinky1", "jPink1"],
["_pinky2", "jPink2"],
["_pinky3", "jPink3"],
["_thumb1", "jThumb1"],
["_thumb2", "jThumb2"],
["_thumb3", "jThumb3"],
["_midtoe2", "jToes_end"],
]

""" [ Guide, joint ]
"""
guides_for_rig = [
["Collar", "lCollar", "chest"],
["AbdomenUpper", "abdomenUpper"],
["ChestUpper", "chestUpper"],
["Shoulder", "lShldr"], # Genesis 2
["Elbow", "lForeArm"], # Genesis 2
["Shoulder", "lShldrBend"],
["Elbow", "lForearmBend"],
["Hand", "lHand"],
["Index1", "lIndex1"],
["Index2", "lIndex2"],
["Index3", "lIndex3"],
["Index_end", "lIndex3"],
["Middle1", "lMid1"],
["Middle2", "lMid2"],
["Middle3", "lMid3"],
["Middle_end", "lMid3"],
["Ring1", "lRing1"],
["Ring2", "lRing2"],
["Ring3", "lRing3"],
["Ring_end", "lRing3"],
["Pinky1", "lPinky1"],
["Pinky2", "lPinky2"],
["Pinky3", "lPinky3"],
["Pinky_end", "lPinky3"],
["Thumb1", "lThumb1"],
["Thumb2", "lThumb2"],
["Thumb3", "lThumb3"],
["Thumb_end", "lThumb3"],
["LegUpper", "lThighBend"],
["LegUpper", "lThigh"],
["Knee", "lShin"],
["Foot", "lFoot"],
["Toes", "lToe"],
["Toes_end", "lSmallToe2_2"],
["Toes_end", "lSmallToe2"],
["Collar", "l_shoulder", "lCollar", "chest"],
["AbdomenUpper", "spine2", "abdomenUpper"],
["ChestUpper", "spine4", "chestUpper"],
["Shoulder", "l_upperarm", "lShldrBend", "lShldr"],
["Elbow", "l_forearm", "lForearmBend", "lForeArm"],
#["ForearmTwist", "l_forearmtwist1"],
["Hand", "l_hand", "lHand"],
["Index1", "l_index1", "lIndex1"],
["Index2", "l_index2", "lIndex2"],
["Index3", "l_index3", "lIndex3"],
["Index_end", "l_index3", "lIndex3"],
["Middle1", "l_mid1", "lMid1"],
["Middle2", "l_mid2", "lMid2"],
["Middle3", "l_mid3", "lMid3"],
["Middle_end", "l_mid3", "lMid3"],
["Ring1", "l_ring1", "lRing1"],
["Ring2", "l_ring2", "lRing2"],
["Ring3", "l_ring3", "lRing3"],
["Ring_end", "l_ring3", "lRing3"],
["Pinky1", "l_pinky1", "lPinky1"],
["Pinky2", "l_pinky2", "lPinky2"],
["Pinky3", "l_pinky3", "lPinky3"],
["Pinky_end", "l_pinky3", "lPinky3"],
["Thumb1", "l_thumb1", "lThumb1"],
["Thumb2", "l_thumb2", "lThumb2"],
["Thumb3", "l_thumb3", "lThumb3"],
["Thumb_end", "l_thumb3", "lThumb3"],
["LegUpper", "l_thigh", "lThighBend", "lThigh"],
["Knee", "l_shin", "lShin"],
["Foot", "l_foot", "lFoot"],
["Toes", "l_toes", "lToe"],
["Toes_end", "l_midtoe2", "lSmallToe2_2"],
["Toes_end", "l_midtoe1", "lSmallToe2"],
["Pelvis", "hip"],
["Spine_Start", "abdomenLower"],
["Chest_Start", "chestLower"],
["Neck_Start", "neckLower"],
["Spine_Start", "spine1", "abdomenLower", "abdomen"],
["Chest_Start", "spine3", "chestLower", "chest"],
["Neck_Start", "neck1", "neckLower", "neck"],
["Neck_End", "head"],
["Spine_Start", "abdomen"],
["Chest_Start", "chest"],
["Neck_Start", "neck"],
["Head_End", "head_end"], # Labeled temp...
]

Expand All @@ -218,6 +282,7 @@
"Thumb3",
"Thumb1",
"Hand",
#"ForearmTwist",
"Elbow",
"Shoulder",
"Toes_end",
Expand Down Expand Up @@ -285,6 +350,10 @@
["Chest_ctrl", "jChest", "spine"],
["Neck_ctrl", "jNeck", "neck"],
["Head_ctrl", "jHead", "head"],
["ForearmTwist_ctrl", "l_forearmtwist1", "twist"],
["ForearmTwist_ctrl___R", "r_forearmtwist1", "twist"],
["ForearmTwist2_ctrl", "l_forearmtwist2", "twist"],
["ForearmTwist2_ctrl___R", "r_forearmtwist2", "twist"],
]

ik_tags = [
Expand Down
10 changes: 9 additions & 1 deletion Cinema 4D/appdir_common/plugins/DazToC4D/lib/DazRig.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ def find_matching_joint(self, joint):
suffix = ""

mesh_name = Utilities.get_daz_name() + "_"
constraints = Database.rig_joints
## TODO: REPLACE WITH TRUE GENERATION TEST
if doc.SearchObject("l_thightwist1"):
constraints = Database.rig_joints_g9
else:
constraints = Database.rig_joints
for joints in constraints:
if dz_jnt_name == joints[0]:
return doc.SearchObject(mesh_name + joints[1] + suffix)
Expand Down Expand Up @@ -322,6 +326,10 @@ def protectTag(obj, protectPreset):
r_eye = doc.SearchObject("rEye") # Genesis2
l_eye = doc.SearchObject("lEye") # Genesis2

if r_eye is None or l_eye is None:
r_eye = doc.SearchObject("r_eye") # Genesis9
l_eye = doc.SearchObject("l_eye") # Genesis9

if r_eye is None or l_eye is None:
return
headJoint = doc.SearchObject("head") # Genesis2
Expand Down
23 changes: 22 additions & 1 deletion Cinema 4D/appdir_common/plugins/DazToC4D/lib/DazToC4DClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from . import Utilities as util
from .CustomIterators import ObjectIterator
from .Utilities import dazToC4Dutils
from .Utilities import dazToC4Dutils, is_genesis9
from .IkMax import applyDazIK, ikmaxUtils
from .AllSceneToZero import AllSceneToZero

Expand Down Expand Up @@ -70,6 +70,19 @@ def freezeTwistBones(self):
nullForeArmR.SetRelPos(c4d.Vector(0, 0, 0))
nullForeArmR.SetRelRot(c4d.Vector(0, 0, 0))

nullForeArm = doc.SearchObject(dazName + "ForearmTwist2_ctrl")
nullForeArmR = doc.SearchObject(dazName + "ForearmTwist2_ctrl___R")
if nullForeArm:
nullForeArm.SetFrozenPos(nullForeArm.GetAbsPos())
nullForeArm.SetFrozenRot(nullForeArm.GetAbsRot())
nullForeArmR.SetFrozenPos(nullForeArmR.GetAbsPos())
nullForeArmR.SetFrozenRot(nullForeArmR.GetAbsRot())

nullForeArm.SetRelPos(c4d.Vector(0, 0, 0))
nullForeArm.SetRelRot(c4d.Vector(0, 0, 0))
nullForeArmR.SetRelPos(c4d.Vector(0, 0, 0))
nullForeArmR.SetRelRot(c4d.Vector(0, 0, 0))

def lockAllModels(self):
doc = documents.GetActiveDocument()
obj = doc.GetFirstObject()
Expand Down Expand Up @@ -108,6 +121,9 @@ def protectTwist(self):
dazName = util.get_daz_name() + "_"

def addProtTag(obj):
if obj is None:
print("DEBUG: addProtTag: unsupported figure crashfix")
return
xtag = c4d.BaseTag(c4d.Tprotection)
xtag[c4d.PROTECTION_P] = 1
xtag[c4d.PROTECTION_S] = False
Expand All @@ -123,6 +139,11 @@ def addProtTag(obj):
nullForeArmR = doc.SearchObject(dazName + "ForearmTwist_ctrl___R")
addProtTag(nullForeArm)
addProtTag(nullForeArmR)
if is_genesis9():
nullForeArm = doc.SearchObject(dazName + "ForearmTwist2_ctrl")
nullForeArmR = doc.SearchObject(dazName + "ForearmTwist2_ctrl___R")
addProtTag(nullForeArm)
addProtTag(nullForeArmR)

def protectIKMControls(self):
def protectTag(jointName, protectPreset):
Expand Down
Loading

0 comments on commit 89d4459

Please sign in to comment.