The core concept of this entire tutorial is very simple, which is the various applications of the motionPath node. The entire rig's structure and all controllers and locators are built around this node.
The final product, as shown in the video below, is a complete bridge rig. I also wrote my own tool to procedural it, which was the most troublesome part. Other than that, the core concepts are very simple.
So let me record the process of proceduralizing this tutorial that I learned and some new things I learned along the way. Some are related to Python, while others are related to the usage of Maya nodes. I hope it will be helpful to anyone reading this article.
This rig is mainly driven by 4 cv curves. The MainCtrl deforms the cv curves through clusters, while the controllers and joints are driven by the cv curves through motionPath nodes.
The following video shows the cluster controlled by MainCtrl. You can see that I use the same cluster to drive the two cv curves below. If you want to be closer to reality, you can use two clusters like the cv curves above.
As for the remaining models and controllers, they are driven by locators.
You can see from the following video that I put the controllers under locators. These locators are driven by motionPath through cv curves, so the controllers will also move accordingly, and the controllers will drive the joints. This completes the entire structure.
motionPath節點的Parametric Length開關/Parametric Length Switch in motionPath Node
In the earlier notes on Track Creator, we mentioned the motionPath node, which is a node that helps objects move along a curve, and keeps the distance between the objects the same when the curve is stretched!
The motionPath node and its Parametric Length switch were the most used nodes in this bridge rig.
The following is the method of using the motionPath node to make an object follow a cv curve.
In the following video, we can see that the locator has different motion paths on the two CV curves, and the only difference between them is the Parametric Length switch in the motionPath node.
If the switch is unchecked, the distance between objects will not change when the cv points move horizontally. If the switch is checked, the distance between objects will change. This is the most important option in the bridge rig, so remember to uncheck it.
Only by doing this can we create a realistic deformation of the bridge!
It can be said that understanding the importance of the Parametric Length option in the motionPath node is the key to completing the Bridge rig. The remaining part is to distribute objects to the CV curve, connect them to the motionPath node, add clusters and controllers to the CV curve, and the rig will be completed with a good effect.
Python zip():將多個list結合起來做迴圈/Combining multiple lists for looping
This is a very useful Python function that can combine different sequence lists together for iteration.
As shown in the video below, we can use the zip function to wrap two lists together. This way, objects at the same index in both lists can be processed together and various operations can be performed. This function is very useful for situations where you want to "use a loop to concatenate different lists."
This is a problem I encountered in my programmatic bridge rig, which is that when we use the cmds.ikHandle() command, Maya actually creates a list that includes both the IK handle and the effector!
So if we want to perform other operations on the objects generated by this command, we need to specify the index, otherwise an error will occur!
As shown in the video below, the ikHandle command generates a list, where the object at IK[0] is the IK handle and the object at IK[1] is the effector. It is important to keep this in mind when using them.
Distance between nodes are also used a lot in bridge rig to measure the distance between joints in order to achieve the stretch IK effect. Here, it is important to avoid using objects with a translate value of 0, such as controllers, for measurement.
The image below shows how I connected two controllers to a distance between node and output it to a multiply node.
Next, if we select the multiply node, we can see that the output value of the distance between node is 0. This is not a good result because if we want to create the stretch IK effect, there must be a set of values for other nodes to work with.
Therefore, if we need to use this technique, we should avoid using objects with a translate value of 0.
The following video shows how I parented two locators to the position of a controller and kept their translate values in a non-zero state, then output them to a distance between node. As a result, we can see that there are values in the output of the multiply node!
I have seen many tutorials use this technique, which is to create empty lists for the objects that will be used before the function starts running. I didn't understand the purpose of doing this before, but after starting to write my own tools, I began to understand its benefits, especially when dealing with large, ordered sets of objects. This method can unify and interact with newly generated objects and can be combined with the zip function mentioned above to satisfy most list processing needs.
Below is a simple example where I created two empty lists, A and B, and used a loop to append a sequence of numbers to both lists. Finally, I used zip to package them together and printed them out. This example may not be easy to understand, but these two lists of numbers can represent any other objects, such as controllers or joints. When we use Maya commands to generate these new objects, we can add them to the pre-arranged empty lists, so we can call them up and use them later!
串聯joint以及子階層所有的joints
如果想要串聯一個joint chain可以這麼做。
If you want to connect a joint chain, you can do it like this.
JNT=cmds.ls(sl=1)
for i in JNT:
Sel=cmds.ls(i, dag=True, type='joint')
for j in Sel:
cmds.connectAttr("locator9.rotate",j+".rotate")
As demonstrated in the video below, I first selected the root of the joint chain, then used the ls command to add them to the list named "JNT". Next, I used two loops to link the rotation of the locators to all the joints!
The thing is, the Maya cmds text field cannot directly display the selected objects using cmds.ls, which may cause errors because the selected items are unicode, not str. Therefore, we need to convert the list to str() before displaying it (this issue may have been resolved in Python versions after MAYA 2022).
This will cause an error when executing the function because the for loop cannot directly read the str() items. Therefore, we need to convert it back to list format using eval().
Here is a simple demonstration. The process is to convert a str back to a list using eval(). If you encounter any unicode errors, you can try this solution.
如果覺得這篇文章有幫助你在動畫之路走得更長遠,可以使用 Google 或 Facebook 帳號快速登入,按Like五下,就可以幫助我從Likecoin得到回饋,完全不用任何費用!
一點點的鼓勵都會成為我寫作的動力,感激不盡!
If you found this article helpful in your journey in animation, you can use your Google or Facebook account to quickly log in and click Like five times to help me earn rewards from Likecoin, without any cost! Your encouragement means a lot to me and will become the motivation behind my writing. Thank you so much!
0 留言