Uniquely Color Clones for a Matte with Cinema 4D's Python Effector

Photo of Rick Barrett

Instructor Rick Barrett

Share this video
  • Duration: 02:24
  • Views: 2374
  • Made with Release: 17
  • Works with Release: 17 and greater

Use a Python Effector to color clones based on UVW coordinates.

In this Quick Tip, you'll create a Python Effector to create an RGB matte that uniquely colors clones based on their original relative position in the MoGraph object. The technique is basically the same as Uniquely Color Clones for a Matte with Cinema 4D's Formula Effector, the previous Quick Tip using the Formula Effector and MoGraph UVW coordinates, but simplifies the setup to a single Python effector.

show less

Transcript

- In a prior Cinema 4D quick tip, we looked at how to use three formula effectors to uniquely color the clones of a grid array, based on their original position in the grid. In this quick tip, what we're going to do is actually simplify this, and instead of using three individual formula effectors, we're going to use one Python effector. With the same five by five by five grid selected, what we're going to go into the MoGraph menu and add a new Python effector. For this, what we're going to do is turn off the position transform and we're going to switch the transform to color mode on. Then we're going to open the Python editor. Normally, if you're going to build a Python effector, you're going to need to refer to the documentation that's available on Developers.maxon.net. If you look in the Python section, under modules, under MoGraph and MoData, you'll find most of the appropriate methods here. But I'm just going to shortcut and tell you exactly what we need to put in here. By default, the Python effector pulls in the MoData and it gets the current index of the clone that it's acting upon, and the current mode that's being acted on. In this case, it's going to be color. But by default, it only affects positions. So we're going to go ahead and switch this first to color. If we compile and execute, which you'll see is all the clones turn gray, because what's currently being output is a vector that's 0.5 or half gray on each dimension. What we're going to do now is actually pull the UVW coordinates that we can use as an input for this. We're just going to create a new variable, uvw = md.GetArray(c4d.MODATA_UVW). Now what we have is a Python list that relates to the UVW coordinates of each clone. Now, instead of outputting this standard vector, what we can do is instead output UVW index. We're getting the value of the list at the index that relates to the current clone ID. So now we'll hit compile and execute, and here we have our matte colors with a unique color for each individual clone. That is a Python effector that will matte your clones based on UVW.
Resume Auto-Scroll?