Skip to content

Commit

Permalink
Initial Testing for Face Capture through Move By Maxon
Browse files Browse the repository at this point in the history
- Found error with CBS Setup need to redefine setup in optimizer.
  • Loading branch information
samjay3d committed May 31, 2021
1 parent b097c24 commit 995bcd6
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 1 deletion.
59 changes: 59 additions & 0 deletions Cinema 4D/appdir_common/plugins/DazToC4D/lib/Database.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,67 @@
import c4d

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

"""Face Capture
"""
facial_morphs = [
c4d.FACECAPTURE_BLENDSHAPE_LEFTEYE_BLINK,
c4d.FACECAPTURE_BLENDSHAPE_LEFTEYE_LOOKDOWN,
c4d.FACECAPTURE_BLENDSHAPE_LEFTEYE_LOOKIN,
c4d.FACECAPTURE_BLENDSHAPE_LEFTEYE_LOOKOUT,
c4d.FACECAPTURE_BLENDSHAPE_LEFTEYE_LOOKUP,
c4d.FACECAPTURE_BLENDSHAPE_LEFTEYE_SQUINT,
c4d.FACECAPTURE_BLENDSHAPE_LEFTEYE_WIDE,
c4d.FACECAPTURE_BLENDSHAPE_RIGHTEYE_BLINK,
c4d.FACECAPTURE_BLENDSHAPE_RIGHTEYE_LOOKDOWN,
c4d.FACECAPTURE_BLENDSHAPE_RIGHTEYE_LOOKIN,
c4d.FACECAPTURE_BLENDSHAPE_RIGHTEYE_LOOKOUT,
c4d.FACECAPTURE_BLENDSHAPE_RIGHTEYE_LOOKUP,
c4d.FACECAPTURE_BLENDSHAPE_RIGHTEYE_SQUINT,
c4d.FACECAPTURE_BLENDSHAPE_RIGHTEYE_WIDE,
c4d.FACECAPTURE_BLENDSHAPE_JAW_FORWARD,
c4d.FACECAPTURE_BLENDSHAPE_JAW_LEFT,
c4d.FACECAPTURE_BLENDSHAPE_JAW_RIGHT,
c4d.FACECAPTURE_BLENDSHAPE_JAW_OPEN,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_CLOSE,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_FUNNEL,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_PUCKER,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_LEFT,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_RIGHT,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_SMILELEFT,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_SMILERIGHT,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_FROWNLEFT,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_FROWNRIGHT,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_DIMPLELEFT,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_DIMPLERIGHT,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_STRETCHLEFT,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_STRETCHRIGHT,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_ROLLLOWER,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_ROLLUPPER,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_SHRUGLOWER,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_SHRUGUPPER,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_PRESSLEFT,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_PRESSRIGHT,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_LOWERDOWNLEFT,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_LOWERDOWNRIGHT,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_UPPERUPLEFT,
c4d.FACECAPTURE_BLENDSHAPE_MOUTH_UPPERUPRIGHT,
c4d.FACECAPTURE_BLENDSHAPE_BROW_DOWNLEFT,
c4d.FACECAPTURE_BLENDSHAPE_BROW_DOWNRIGHT,
c4d.FACECAPTURE_BLENDSHAPE_BROW_INNERUP,
c4d.FACECAPTURE_BLENDSHAPE_BROW_OUTERUPLEFT,
c4d.FACECAPTURE_BLENDSHAPE_BROW_OUTERUPRIGHT,
c4d.FACECAPTURE_BLENDSHAPE_CHEEK_PUFF,
c4d.FACECAPTURE_BLENDSHAPE_CHEEK_SQUINTLEFT,
c4d.FACECAPTURE_BLENDSHAPE_CHEEK_SQUINTRIGHT,
c4d.FACECAPTURE_BLENDSHAPE_NOSE_SNEERLEFT,
c4d.FACECAPTURE_BLENDSHAPE_NOSE_SNEERRIGHT,
c4d.FACECAPTURE_BLENDSHAPE_TONGUE_OUT
]

""" [ ctrl_joint, joint ]
"""
constraint_joints = [
Expand Down
78 changes: 77 additions & 1 deletion Cinema 4D/appdir_common/plugins/DazToC4D/lib/DtC4DDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .CustomColors import randomColors
from .DtC4DPosing import Poses
from .Definitions import RES_DIR
from .Morphs import Morphs

dazReduceSimilar = True

Expand Down Expand Up @@ -685,7 +686,11 @@ class EXTRADialog(c4d.gui.GeDialog):
BUTTON_BIGIMG = 241798008

IDC_LINKBOX_1 = 241798000

IDC_LINKBOX_2 = 341798000
BUTTON_CONNECT_MORPH = 341798001
BUTTON_DISCONNECT_MORPH = 341798002
BUTTON_CONNECT_HEAD = 341798003
BUTTON_DISCONNECT_HEAD = 341798004
BUTTON_START = 241798011

BUTTON_UNDO = 241798012
Expand Down Expand Up @@ -862,6 +867,16 @@ def buttonBC(self, tooltipText="", presetLook=""):
return bc
# Logo Image #############################################################

def find_face_captures(self):
obj = self.face_link.GetLink()
if obj.GetType() == 1040464:
c4d.MessageDialog(
"Do not connect the Face Capture\nCreate Pose Morphs first.",
type=c4d.GEMB_ICONEXCLAMATION,
)
if obj.GetTag(1040839):
self.face_link.SetLink(obj)

def open_support(self, message):
gui.MessageDialog(message, c4d.GEMB_OK)
new = 2 # open in a new tab, if possible
Expand Down Expand Up @@ -904,6 +919,49 @@ def CreateLayout(self):

self.GroupEnd()

self.GroupBegin(
11, c4d.BFH_SCALEFIT, 1, 1, title="Moves By Maxon: "
)
self.GroupBorder(c4d.BORDER_GROUP_IN)
self.GroupBorderSpace(10, 5, 10, 5)

self.face_link = self.AddCustomGui(
self.IDC_LINKBOX_2,
c4d.CUSTOMGUI_LINKBOX,
"Face Capture:",
c4d.BFH_SCALEFIT,
350,
0,
)
self.GroupBegin(
11, c4d.BFH_SCALEFIT, 8, 1, title="Connect Face Capture: "
)
self.GroupBorder(c4d.BORDER_GROUP_OUT)
self.GroupBorderSpace(10, 5, 12, 5)

self.connect_morphs = self.AddButton(
self.BUTTON_CONNECT_MORPH,
c4d.BFV_TOP,
name="Connect Morphs"
)
self.disconnect_morphs = self.AddButton(
self.BUTTON_DISCONNECT_MORPH,
c4d.BFV_BOTTOM,
name="Disconnect Morphs"
)
self.add_head_rotation = self.AddButton(
self.BUTTON_CONNECT_HEAD,
c4d.BFV_TOP,
name="Connect Head Rotation"
)
self.disconnect_head_rotation = self.AddButton(
self.BUTTON_DISCONNECT_HEAD,
c4d.BFV_BOTTOM,
name="Disconnect Head Rotation"
)
self.GroupEnd()
self.GroupEnd()

self.GroupBegin(
11, c4d.BFH_CENTER, 1, 1, title="AAAAAA"
) # -----------Main Group
Expand Down Expand Up @@ -1178,9 +1236,25 @@ def Command(self, id, msg):
self.dazIkmControls = getJointFromConstraint(self.jointPelvis).GetUp()
IKMAXFastAttach.jointPelvis = self.jointPelvis

if id == self.BUTTON_CONNECT_MORPH:
face_capture = self.face_link.GetLink()
Morphs.connect_face_morphs(face_capture)

if id == self.BUTTON_DISCONNECT_MORPH:
face_capture = self.face_link.GetLink()
Morphs.connect_face_morphs(face_capture)

if id == self.BUTTON_CONNECT_HEAD:
face_capture = self.face_link.GetLink()


if id == self.IDC_LINKBOX_2:
self.find_face_captures()

# GUIDES
if dzc4d.findIK() == 1:


if id == self.BUTTON_RESET:
caca = ikmaxUtils().removeStuff()
if caca == 1:
Expand Down Expand Up @@ -1510,3 +1584,5 @@ def makeChild(child, parent):
)

return True


Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class guiDazToC4DMain(gui.GeDialog):
import_vars = []

BUTTON_CONFIG = 923123
BUTTON_MORPHS = 923113
BUTTON_AUTO_IMPORT_FIG = 923124
BUTTON_AUTO_IMPORT_PROP = 923131
BUTTON_CONVERT_MATERIALS = 923126
Expand Down
43 changes: 43 additions & 0 deletions Cinema 4D/appdir_common/plugins/DazToC4D/lib/Morphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from .CustomIterators import TagIterator
from . import ErcExpressions as erc
from .Database import facial_morphs


class Morphs:
Expand All @@ -27,6 +28,48 @@ def create_null_for_morphs(body):
c4d.EventAdd()
return null


@staticmethod
def find_facial_morph(face_morph_tag, morph_name):
morph_amount = face_morph_tag.GetMorphCount()
for x in range(morph_amount):
face_morph_tag.SetActiveMorphIndex(x)
morph = face_morph_tag.GetActiveMorph()
face_morph_name = morph.GetName()
if set(face_morph_name.split(" ")) == set(morph_name.split(" ")):
return face_morph_tag.GetMorphID(x)
@staticmethod
def connect_face_morphs(face_capture):
doc = documents.GetActiveDocument()
morph_obj = doc.SearchObject("Daz Morphs Controller")
morph_tag = morph_obj.GetTag(c4d.Tposemorph)
face_morph_tag = face_capture.GetTag(c4d.Tposemorph)
print(face_morph_tag)
xpresso_tag = morph_obj.GetTag(c4d.Texpresso)
node_master = xpresso_tag.GetNodeMaster()
morph_master_output = Morphs().create_node(node_master, morph_tag, -1000, 100)
facial_node = Morphs().create_node(node_master, face_morph_tag, -1200, 100)
if morph_tag:
morph_amount = morph_tag.GetMorphCount()
for x in range(morph_amount):
morph_tag.SetActiveMorphIndex(x)
morph = morph_tag.GetActiveMorph()
morph_name = morph.GetName()
blend_shape = Morphs.find_facial_morph(face_morph_tag, morph_name)
if blend_shape:
morph_num = morph_tag.GetMorphID(x)
morph_input = morph_master_output.AddPort(
c4d.GV_PORT_INPUT, morph_num
)
facial_output = facial_node.AddPort(
c4d.GV_PORT_OUTPUT, blend_shape
)
facial_output.Connect(morph_input)





@staticmethod
def move_poses_under_morphs(group, poses):
for pose in poses:
Expand Down

0 comments on commit 995bcd6

Please sign in to comment.