Limited Push Modifier
While the Push Modifiers in 3ds Max and Genome are among of the simplest deformation modifiers possible, the following example will alter the Genome version to do something 3ds Max cannot do out of the box.
In the case of the Limited Push Modifier, the displacement along the normal will be limited by an external object's surface using ray intersection techniques.
Genome provides accelerated ray casting and nearest point lookup operators and allows a lot of powerful workflows involving mesh to mesh interaction.
Creating The Base Scene
- Start a new 3ds Max scene.
- Create a Teapot with Radius of 30.0 and 32 segments.
- Create a Box with Length of 100.0, Width of 120.0 and Height of -10.0 at World Coordinates [0,0,0]
- Create another Box with Length of 10.0, Width of 120.0 and Height of 50.0 at [0.0,45.0,0.0]
- Copy the second Box to [0.0,-45.0,0.0]
Implementing The Limited Push
- Select the Teapot and add a Genome Modifier.
- Set it to VERTEX iteration mode and press "Open Magma Editor"
- Press Ctrl+[O] to create a new Output node and make sure it is set to Position channel.
- Press SHIFT+[P] to create a new Position InputChannel.
- Press [+] to insert an Add operatror.
- Press SHIFT+[N] to create a new Normal InputChannel.
- Press [*] to insert a Multiply operator
- Press Ctrl+ (zero on the top row of the keyboard) to create a Float InputValue of 0.0
At this point, we have the regular Push modifier implementation. Now let's limit it to the Boxes.
- Press Ctrl+[D] to Deselect All.
- Press [O] and [R] to create a new IntersectRay operator.
- Drag a wire from the Geometry input socket to an empty area of the editor to create an InputGeometry node.
- Press the "Get by Name..." button, then select and add the three Boxes.
- Connect the existing Position InputChannel node into the Ray Origin (WS) socket of the IntersectRay operator.
- Select the wire connecting the Position with the Ray Origin (WS) socket and press [T] and [R] to insert a ToWorld operator. We have to do this because the Vertex Positions in Genome are in object space, but the IntersectRay wants a World Space position (WS).
- Connect the existing Normal InputChannel node into the Ray Direction (WS) socket of the IntersectRay operator.
- Select the wire connecting the Normal with the Ray Direction (WS) socket and press [T] and [R] to insert a ToWorld operator. Swtch its type to "Normal" instead of "Point" since we are converting a Normal to World Space and we want no scaling or translations to be applied to it.
- Drag a wire from the Distance output socket of the IntersectRay operator and select Arithmetic > Absolute operator from the menu. This is necessary because the Distance value is signed depending on whether it hits the geometry from the front or at the back.
- With the Absolute operator selected, press [L] and [S] to create a Logic > Less operator.
- Connect the InputValue node defining the push value with the Right Scalar input socket of the Less operator.
- Select the Less operator and press [L] and [A] to create a new LogicalAnd operator.
- Connect the IsValid output socket of the IntersectRay to the second input of the LogicalAnd operator. Press Ctrl+[W] to swap the sockets order so IsValid is evaluated first.
- Select the LogicalAnd operator and press [L] and [W] to add a new Switch operator - the LogicalAnd will connect to its third slot.
- Connect the Distance output socket of the IntersectRay operator into the If True socket of the Switch.
- Connect the InputValue node to the If False socket of the Switch.
- Select the wire connecting the InputValue node with the Multiply node after the Normal InputChannel and press [Del] to delete it.
- Now connect the output socket of the Switch operator to the Right Value socket of that same Multiply operator.
RESULT: At this point, we shoot a ray from the non-pushed vertex position along the vertex normal and compare the distance of the intersection with the push distance. If there is a valid intersection and the distance is closer than the desired push distance, we pass the distance value (which is our Limit, the Maximum distance we want to push before stopping) to the Normal's Multiplier. If the intersection is not valid or the distance was greater than the requested push, we just pass the original Float value.
Now you can play with the Push value by setting it to 10.0, 20.0, 30.0 etc. and see how the teapot interacts with the obstacles, stopping the push as it hits the "walls" around it: