Hi,
I have a mesh that needs a corrective pose.
Rather than creating it within C4D, I export an uncorrected pose.
And received a corrected pose, from the modeler.
I now have the task to convert the corrected pose to a corrected shape.
Here is my planned workflow:
- Store points of the corrected pose
- Go to the uncorrected pose. Add a posemorph, while in edit mode
- Restore points from the corrected pose to the uncorrected pose.
It works as you can see here:
https://www.dropbox.com/s/fkqndj892z3jlt2/c4d276_python_setallpoints_on_skin01.mp4?dl=0
Both mesh should match 1 to 1. But not where the mesh is with Posemorph and Skin:
https://www.dropbox.com/s/qufqggqo295atuo/c4d276_python_setallpoints_on_skin02.mp4?dl=0
You can check the illustration file here: (Animated from 0 to 10)
https://www.dropbox.com/s/5s9xlgujfw5ga42/c4d276_python_setallpoints_on_skin.c4d?dl=0
Here is the working script so far:
import c4d
from c4d import gui
# Select Corrective Pose
# Select Base Pose
# Execute Script
def main():
doc = c4d.documents.GetActiveDocument()
obj_sel = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER)
driver = obj_sel[0]
driven = obj_sel[1]
driven_world_matrix = driven.GetMg()
driver_world_matrix = driver.GetMg()
driver_points = [point * driver_world_matrix for point in driver.GetAllPoints()]
new_points = [point * ~driven_world_matrix for point in driver_points ]
driven.SetAllPoints(new_points)
driven.Message (c4d.MSG_UPDATE)
print driver_points
print new_points
c4d.EventAdd()
# Execute main()
if __name__=='__main__':
main()