RSS< Twitter< etc

<< Back To Deformation Modifiers

Genome Screw Deformation Modifier

A slight variation of the Bulge modifier described in the previous topic, the Screw Modifier displaces an object along a radial vector based on the Z coordinate of the vertex. The main difference is that instead of using a simple sine function to calculate the displacement, a circle function (cos for X, sin for Y) is used to build a new vector and calculate the dot product with the displacement vector.

First, let's take a look at the basic form of this function. After that, we will insert this functionality as an option into the Bulge Modifier developed in the previous topic.

Basic Screw Modifier Using Vertex Normals

  • Open the scene from the previous topic, disable the existing Genome modifiers.
  • Add a new Genome modifier to the Cylinder, set to "VERTEX" mode and open the Editor.
  • Press Ctrl+[O] to create a new Output node, set to Position channel.
  • Select the Output node and press SHIFT+[P] to create and connect a Position InputChannel to it.
  • Press [+] to insert an Add operator.
  • Press SHIFT+[N] to create and connect a Normal InputChannel (this is the basic Push setup so far).
  • Select the Position inputChannel again and press the [Ins] key once to switch from [INSERT 1] to [CONNECT 1] mode (see title bar of the Editor). 
  • Now press [C] and [B] to split a flow with a Breakout operator.
  • With the Breakout operator selected, press [Ins] key twice to highlight the Z socket, then press [/] to connect a Divide operator to the third output.
  • With the Divide operator selected, press Ctrl+[3] to connect a new Float InputValue to the Divisor socket. Rename the InputValue node to "Wave Length" and check the "Exposed" option.
  • Select the Divide operator again and press []] (closing recrangular bracket) to connect a Cos operator. Alternatively, you can use [R] and [O] to use the Trigonometry > Cos menu approach.
  • Select the Divide again, press [Ins] once to switch to [CONNECT 1] mode and press the [[] key (opening rectangular bracket) to connect a Sin operator. Alternatively, you can access it via [R] and [I].
  • Hold down Ctrl and click the Cos operator to add to the selection. With both Cos and Sin selected, press [C] and then [V] to Convert > ToVector.
  • With the ToVector operator selected, press [.] (period on the bottom row of the keyboard) to create a VectorDot operator. 
  • Hold down Ctrl and click the Normal InputChannel node to add to the selection, then press [SPACEBAR] to connect the Normal channel into the Right Vector socket of the VectorDot.
  • Select the VectorDot again and press [*] to connect a Multiply operator. 
  • Press Ctrl+[5] to create a Float InputValue and connect to the Right Value socket of the Multiply. Rename the InputValue to "Amplitude" and check the "Exposed" option.
  • Select the Multiply operator again and press [*] to connect another Multiply operator to it.
  • Press Ctrl+W to swap the first and second input sockets.
  • Click the Wire connecting the Normal InputChannel with the Add operator, hold Ctrl key and click the last Multiply operator to add to the selection. Now press [SPACEBAR] to insert the Multiply operator into the selected connection between the Normal and the Add.

RESULT: The basic Screw Modifier is now complete (left image). 

Other than the previous example of the Bulge Modifier which normalized the Z value according to the Bounding Box, this modifier uses absolute world units for the Wave Length value. Changing the height of the Cylinder to 100.0 does not scale the effect, it is fixed in object space (right image):


Adding the Phase Offset

Just like with the Bulge modifier, we can add a Phase parameter very easily. 

  • Select the Breakout operator and press [+] to insert an Add operator.
  • Press Ctrl+[0] (zero to top row) to connect a Float InputValue node to the Add. Rename the node to "Phase" and check the "Exposed" option. 

RESULT: Changing/animating the Phase will shift the thread along the Z axis. The Phase is also in World Units, it simply shifts the Z component of the Vertex Position.

Creating a BLOP Compound Operator

The code functionality of this modifier is very similar to the Bulge modifier discussed in the previous topic. The main difference is the curcular motion vector calculation using the Cos and Sin operators and the VectorDot product of it with the displacement vector.

Since we want to transfer this algorithm to the Bulge modifier while keeping the flow complexity from exploding, we can combine the relevant operators into one compound operator, called a BlackOp, or BLOP for short. 

  • Select the Cos operator.
  • Hold down the Ctrl key and click the Sin operator, the ToVector operator and the VectorDot operator to add them to the selection.
  • Right-click with the mouse and select [BlackOp] From Selection from the context menu. 

RESULT: A new BLOP node will replace the selected nodes, which will be moved into it. The existing connections will be preserved as input sockets - the first socket taking the Z position, the second socket getting the displacement vector.

We can now rename the BLOP and its sockets and save it to disk for future use. 

  • Select the BLOP node and rename it to "ScrewDisplacement".
  • In the BLOP rollout, rename "Input 1" to "Z Position".
  • Highlight the "Input 2" entry on the Input Sockets list and rename it to "Disp.Vector".
  • Scroll down and rename the "Output 1" socket to "Disp.Factor".
  • Press the SAVE BLOP... button and save the file ScrewDisplacement.MagmaBLOP to disk.
  • If you would press the [B] key to open the BLOP operators menu, you will see new "ScrewDisplacement" operator on the list - you can now insert it in other flows as a regular operator.
  • To see what is going on inside the BLOP, select it and press the EDIT BLOP... button, or alternatively right-click with the mouse and select "Edit BlackOp" from the context menu: 

  • To return to the top-level flow, press the "Exit BLOP Editing" button.

Adding Screw Functionality To The Bulge Modifier

Now let's use the new BLOP compound operator in the previously developed Bugle modifier.  

  • Disable the Screw Genome modifier and enable again the Bulge modifier lower on the modifier stack. (if you used a separate scene, be sure to save the Screw Modifier scene to a new .MAX file and open the scene with the Bulge modifier development)
  • Open the Magma editor of the Bulge modifier.
  • Locate the Sine Wave operator and select it.
  • Press [L] and then [W] to insert a new Switch operator. 
  • Rename the Switch operator to "Sine Wave" in order to display this name in the Wave Type list box in the exposed UI.
  • Press Ctrl+[W] to swap the first and second input sockets of the Switch.
  • Click outside the nodes to deselect all, then press [B] and select the ScrewDisplacement BLOP saved in the previous step.
  • Drag a connection from the Disp.Factor output socket of the BLOP to the first (If True) socket of the Switch.
  • Drag a connection from the output of the Multiply operator that connects into the Sine Wave operator and wire to the Z Position input socket of the ScrewDisplacement BLOP.
  • Drag a connection from the output of the older Switch operator that controls the Use Vertex Normals behavior and wire to the Disp.Vector input socket of the BLOP.
  • Select the new Switch operator and press [1] to create and connect a new Integer InputValue node. Rename it to "Create Screw" and check the "Exposed" option. 

RESULT: The former Bulge modifier will now have the option to create a Screw thread instead. Note that all previous options still work, allowing various types of screws to be created with either Normal or Horizontal displacement.

The left image shows a Bulge modifier with Amplitude of 20.0, Wave Count of 3.0 and Phase of 0.0, Wave Type set to "Sine Wave", Use Vertex Normals unchecked, Create Screw unchecked. The right image shows the same with "Create Screw" checked:


Here is Amplitude 5.0, Wave Count 10.0, Phase 0.0, Sine Wave, Create Screw unchecked vs. checked:


And here are the Absolute Wave and Clamped Positive Wave versions of the same setup:



Note that since we inserted the functionality into a modifier where the Z value is being normalized, changing the height of the cylinder will actually scale the threading, while in the basic Screw modifier the step was fixed in world units!

Flipping the Threading Direction

Changing the spiral motion between clockwise and counter-clockwise is very easy - it involves simply negating the Z vertex position value going into the calculation of the wave. 

  • Select the Add operator for the Phase offset.
  • Press [L] and [W] to insert a new Switch operator.
  • Hold down Ctrl and click the Add operator to add to the selection, then press [SPACEBAR] to connect to the second socket.
  • Deselect all, then select the Switch again and press [0] to create an Integer InputValue. Rename to "Flip Direction" and check the "Exposed" option.
  • Select the first wire going from the Add to the Switch operator and press [A] and [N] to insert a Negate operator. 

RESULT: Checking and unchecking the new >Flip Direction checkbutton while in >Create Screw mode will flip the direction of the thread.


Related Video: