tesh – mocap
For this project I worked in Autodesk Maya and used Python to create a Maya script that takes motion capture data and triangulates it into an animated origami-esque pattern based on the way the bodies move.
The hardest part of this project was definitely getting used to scripting in Maya. I am familiar with the Python side but Maya has some unique quirks when it comes to script formatting, parenting objects to other objects, etc. I had a lot of trouble originally trying to parent vertices of the triangulated faces onto the joints in the mocap data.
I eventually moved over to frame-based rendering and calculated the positions of all the vertices to generate new faces every frame rather than trying to get them to move and change with the body through parenting. While this took longer to generate and render, it gave much better results.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | import maya.cmds as cmds #change this based on number of frames in your mocap data nFrames = 166 cam = cmds.camera() #generate every frame for i in range (0,nFrames): cmds.currentTime(i) #right hand RHand_Origin = cmds.joint( 'rfingers_end', q=True, p=True ) RHand_OriginX = RHand_Origin[0] RHand_OriginY = RHand_Origin[1] RHand_OriginZ = RHand_Origin[2] #left hand LHand_Origin = cmds.joint( 'lfingers_end', q=True, p=True ) LHand_OriginX = LHand_Origin[0] LHand_OriginY = LHand_Origin[1] LHand_OriginZ = LHand_Origin[2] #right tibia RTib_Origin = cmds.joint( 'rtibia', q=True, p=True ) RTib_OriginX = RTib_Origin[0] RTib_OriginY = RTib_Origin[1] RTib_OriginZ = RTib_Origin[2] #left tibia LTib_Origin = cmds.joint( 'ltibia', q=True, p=True ) LTib_OriginX = LTib_Origin[0] LTib_OriginY = LTib_Origin[1] LTib_OriginZ = LTib_Origin[2] #right elbow RElb_Origin = cmds.joint( 'rradius', q=True, p=True ) RElb_OriginX = RElb_Origin[0] RElb_OriginY = RElb_Origin[1] RElb_OriginZ = RElb_Origin[2] #left elbow LElb_Origin = cmds.joint( 'lradius', q=True, p=True ) LElb_OriginX = LElb_Origin[0] LElb_OriginY = LElb_Origin[1] LElb_OriginZ = LElb_Origin[2] #right shoulder RShould_Origin = cmds.joint( 'rhumerus', q=True, p=True ) RShould_OriginX = RShould_Origin[0] RShould_OriginY = RShould_Origin[1] RShould_OriginZ = RShould_Origin[2] #left shoulder LShould_Origin = cmds.joint( 'lhumerus', q=True, p=True ) LShould_OriginX = LShould_Origin[0] LShould_OriginY = LShould_Origin[1] LShould_OriginZ = LShould_Origin[2] |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | #right foot RFoot_Origin = cmds.joint( 'rtoes_end', q=True, p=True ) RFoot_OriginX = RFoot_Origin[0] RFoot_OriginY = RFoot_Origin[1] RFoot_OriginZ = RFoot_Origin[2] #left foot LFoot_Origin = cmds.joint( 'ltoes_end', q=True, p=True ) LFoot_OriginX = LFoot_Origin[0] LFoot_OriginY = LFoot_Origin[1] LFoot_OriginZ = LFoot_Origin[2] #back Back_Origin = cmds.joint( 'lowerback', q=True, p=True ) Back_OriginX = Back_Origin[0] Back_OriginY = Back_Origin[1] Back_OriginZ = Back_Origin[2] #neck Neck_Origin = cmds.joint( 'lowerneck', q=True, p=True ) Neck_OriginX = Neck_Origin[0] Neck_OriginY = Neck_Origin[1] Neck_OriginZ = Neck_Origin[2] #head Head_Origin = cmds.joint( 'head_end', q=True, p=True ) Head_OriginX = Head_Origin[0] Head_OriginY = Head_Origin[1] Head_OriginZ = Head_Origin[2] #======================================================= #Create triangulated mesh for each frame cmds.polyCreateFacet( p=[(RFoot_OriginX, RFoot_OriginY, RFoot_OriginZ), (LFoot_OriginX, LFoot_OriginY, LFoot_OriginZ), (RTib_OriginX, RTib_OriginY, RTib_OriginZ)] ) cmds.polyCreateFacet( p=[(RTib_OriginX, RTib_OriginY, RTib_OriginZ), (LFoot_OriginX, LFoot_OriginY, LFoot_OriginZ), (LTib_OriginX, LTib_OriginY, LTib_OriginZ)] ) cmds.polyCreateFacet( p=[(RTib_OriginX, RTib_OriginY, RTib_OriginZ), (LTib_OriginX, LTib_OriginY, LTib_OriginZ), (LHand_OriginX, LHand_OriginY, LHand_OriginZ) ] ) cmds.polyCreateFacet( p=[(RHand_OriginX, RHand_OriginY, RHand_OriginZ), (RTib_OriginX, RTib_OriginY, RTib_OriginZ), (LHand_OriginX, LHand_OriginY, LHand_OriginZ)] ) cmds.polyCreateFacet( p=[(RHand_OriginX, RHand_OriginY, RHand_OriginZ), (LHand_OriginX, LHand_OriginY, LHand_OriginZ), (Back_OriginX, Back_OriginY, Back_OriginZ)] ) cmds.polyCreateFacet( p=[(RHand_OriginX, RHand_OriginY, RHand_OriginZ), (Back_OriginX, Back_OriginY, Back_OriginZ), (RElb_OriginX, RElb_OriginY, RElb_OriginZ)] ) cmds.polyCreateFacet( p=[(LHand_OriginX, LHand_OriginY, LHand_OriginZ), (LElb_OriginX, LElb_OriginY, LElb_OriginZ), (Back_OriginX, Back_OriginY, Back_OriginZ)] ) cmds.polyCreateFacet( p=[(RElb_OriginX, RElb_OriginY, RElb_OriginZ), (Back_OriginX, Back_OriginY, Back_OriginZ), (LElb_OriginX, LElb_OriginY, LElb_OriginZ)] ) cmds.polyCreateFacet( p=[(RElb_OriginX, RElb_OriginY, RElb_OriginZ), (LElb_OriginX, LElb_OriginY, LElb_OriginZ), (Neck_OriginX, Neck_OriginY, Neck_OriginZ)] ) cmds.polyCreateFacet( p=[(RElb_OriginX, RElb_OriginY, RElb_OriginZ), (Neck_OriginX, Neck_OriginY, Neck_OriginZ), (RShould_OriginX, RShould_OriginY, RShould_OriginZ)] ) cmds.polyCreateFacet( p=[(LElb_OriginX, LElb_OriginY, LElb_OriginZ), (LShould_OriginX, LShould_OriginY, LShould_OriginZ), (Neck_OriginX, Neck_OriginY, Neck_OriginZ)] ) cmds.polyCreateFacet( p=[(RShould_OriginX, RShould_OriginY, RShould_OriginZ), (Neck_OriginX, Neck_OriginY, Neck_OriginZ), (LShould_OriginX, LShould_OriginY, LShould_OriginZ) ] ) cmds.polyCreateFacet( p=[(RShould_OriginX, RShould_OriginY, RShould_OriginZ), (LShould_OriginX, LShould_OriginY, LShould_OriginZ), (Head_OriginX, Head_OriginY, Head_OriginZ) ] ) #render each frame cmds.render() |
And a huge thanks to the CMU Graphics Lab Motion Capture Database for all the base motion capture files!