Skip to content

Commit

Permalink
Code Refactor + Version Added
Browse files Browse the repository at this point in the history
  • Loading branch information
samjay3d committed May 31, 2021
1 parent f79ca28 commit 3d9a300
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def buttonBC(self, tooltipText="", presetLook=""):
return bc

def CreateLayout(self):
self.SetTitle("DazToC4D v1.2.0 Beta")
self.SetTitle("DazToC4D v1.2.1 Beta")
self.AddSeparatorH(c4d.BFV_SCALEFIT) # Separator H

bc = c4d.BaseContainer() # Create a new container to store the button image
Expand Down
47 changes: 47 additions & 0 deletions Cinema 4D/appdir_common/plugins/DazToC4D/lib/MaxonTracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,50 @@ def add_head_tracking(face_capture):
node_master, c4d.GV_DEGREE_, 400, 0
)
degrees_to_rad[c4d.GV_DEGREE_FUNCTION_ID] = c4d.GV_RAD2DEGREE_NODE_FUNCTION

@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):
"""Connects to the Move By Maxon Animation"""
doc = c4d.documents.GetActiveDocument()
morph_obj = doc.SearchObject("Daz Morphs Controller")
morph_tag = morph_obj.GetTag(c4d.Tposemorph)
face_morph_tag = face_capture.GetTag(c4d.Tposemorph)
xpresso_tag = morph_obj.GetTag(c4d.Texpresso)
node_master = xpresso_tag.GetNodeMaster()
morph_master_output = Tracking.create_node(node_master, morph_tag, -1000, 100)
facial_node = Tracking.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 = Tracking.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)

return morph_master_output, facial_node

@staticmethod
def disconnect_face_morphs(face_node, morph_node):
"""Remove the Connection to the Move By Maxon Animation"""
face_node.Remove()
morph_node.Remove()
c4d.gui.MessageDialog(
"Face Capture Has been Successfully Removed!", type=c4d.GEMB_OK
)
48 changes: 2 additions & 46 deletions Cinema 4D/appdir_common/plugins/DazToC4D/lib/Morphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(self):

@staticmethod
def create_null_for_morphs(body):
"""Create a null to hold the Morphs for the Daz Pose Morph"""
doc = documents.GetActiveDocument()
morph_tag = body.GetTag(c4d.Tposemorph)
xpresso_tag = body.GetTag(c4d.Texpresso)
Expand All @@ -29,54 +30,9 @@ 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)

return morph_master_output, facial_node

@staticmethod
def disconnect_face_morphs(face_node, morph_node):
face_node.Remove()
morph_node.Remove()
c4d.gui.MessageDialog(
"Face Capture Has been Successfully Removed!", type=c4d.GEMB_OK
)

@staticmethod
def move_poses_under_morphs(group, poses):
"""Move the Poses (Morphs) to the Morph Group"""
for pose in poses:
if pose and group:
pose.InsertUnder(group)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2102,7 +2102,7 @@
}
/*********************************************************************/

// Array : Find if Bone Exists on Children Objects
// Array : Find if Morph Exists on Children, Useful for FACS
function checkForMorphOnChild( oNode, aControlledMeshes, sMorphName )
{
for ( var i = 0; i < oNode.getNumNodeChildren(); i++ ){
Expand Down

0 comments on commit 3d9a300

Please sign in to comment.