@m_magalhaes @zipit
I managed to flip the mesh (not necessarily a pose morph target since I'd have to know the API).
Anyhow, here is a demo of it working:
https://www.dropbox.com/s/bh4p26s4m9qwljw/c4d272_flip_miror_mesh.mp4?dl=0
Here is wip script. It only works if the x-axis is dead set on 0.
Also, it is slow since it has to loop within a loop.
import c4d
from c4d import gui
# Main function
def main():
neutral_geo = doc.SearchObject('neutral_geo')
posed_geo = doc.SearchObject('posed_geo')
neutral_world_matrix = neutral_geo.GetMg()
posed_world_matrix = posed_geo.GetMg()
neut_lcl_pnts = neutral_geo.GetAllPoints()
neut_gbl_pnts = [point * neutral_world_matrix for point in neut_lcl_pnts]
posed_lcl_pnts = posed_geo.GetAllPoints()
posed_gbl_pnts = [point * posed_world_matrix for point in posed_lcl_pnts]
match_pnts = []
left_pnts = []
right_pnts = []
for idx, point in enumerate(neut_gbl_pnts):
if point[0] == 0.0: # ignore points at the world x axis
continue
if point[0] > 0.0:
left_pnts.append((idx,point))
if point[0] < 0.0:
right_pnts.append((idx,point))
for left in left_pnts:
for right in right_pnts:
if left[1][1] == right[1][1]: # check if Y pos match
if left[1][2] == right[1][2]: # check if Z pos match
if left[1][0] == -1 * (right[1][0]):# check if X pos are inverse
match_pnts.append((left[0],right[0]))
for pnt in match_pnts:
reversed_left = posed_lcl_pnts[pnt[1]]
reversed_left[0] = reversed_left[0] * -1
reversed_right = posed_lcl_pnts[pnt[0]]
reversed_right[0] = reversed_right[0] * -1
posed_geo.SetPoint(pnt[0], reversed_left)
posed_geo.SetPoint(pnt[1], reversed_right)
posed_geo.Message(c4d.MSG_UPDATE)
c4d.EventAdd()
# Execute main()
if __name__=='__main__':
main()