5 minute read

Stamp-o-matic by Base80

Stamp-o-matic Stamp-o-matic

By Base80 By Base80

Advertisement

Stamp-o-Matic Tutorial and a working file for xpressophobes

Ever wanted to leave footsteps in sand or bullet holes or a stamp on an envelope?

Well here is the solution. The Stamp-o-Matic xpresso.

What does it do? The Stamp-o-Matic creates an instance of an object on

impact of two other objects. In english; when a foot hits the ground it leaves a mark. Click once on the XPresso tag to drop the necessary objects in the appropriate user-data fields.

You need a foot object (a polygon at the bottom of the foot), a footprint object (this can be whatever you want) and a floor (polygonal object or group of polygonal objects). Now you can animate the foot and it will leave a print every time the foot collides with the ground. Cool.

How does it work?

This xpresso is built around the fantastic "instance-Maker-Node". This node was commissioned by me and is made by Majoul of France. The node can make an instance of an object when-ever needed. In this case an instance is created on collision. Easy.

The XPresso part

Part 1 - Create instances on collision.

Start by making an xpresso tag on a null-object. Add 3 user-data fields to the tag, the data type set on "link". Give them a name like; foot, footstep and floor.

Now open the xpresso editor by double clicking the tag. Drag the tag with the user data in the editor and open the 3 link output ports. Next we create a bunch of nodes. Acollision node, a mono-flop, a time and a compare node.

The first thing we do is detect a collision of the foot and the floor. Connect the foot and the floor userdata to the collision-node. This node gives a "True" on collision. This true can trigger the making of an instance. Check the Include children and use deformed points boxes.

What we want is to count the number of times the foot has hit the ground. We can do this with a mono-flop node. Every time the mono-flop is triggered by the collision it will add 1 to the count port. Now connect the count port of the mono flop to the instance-maker (this node is provided in the file in the goodies folder of the mag)

So we have: User-data--> Collision--> Mono-flop--> Instance-maker.

Now we can connect the user-data containing the link of the footstep to the Object port of the instance maker so it can make the instances of that object.

The instance maker needs an empty null-object to put the instances in, the "container", just drag an empty null-object in the xpresso editor and connect the object-port to the container port of instance maker. Well this works fine but the footsteps are all in the same place.

Part 2 - Placing the objects

What we will do here is pass the position of impact to the instance created by the collision.

So we need a Hierarchy node. Connect the container null object to the hierarchy node and set the node to go down to the last instances in

the container. So set it to D (down) for the start path and L(last) for the iteration path, easy does it.

Stamp-o-matic Stamp-o-matic

By Base80 By Base80

Connect the hierarchy node to an object node. The object node will be representing the last instance in the container, but actually this is not a transparent part of xpresso. I am never sure this actually works so to be sure I open the name-port of the object node to a result-node set to "string" now you can read the name of the selected object here.

Create another object node and connect its object input port to the user-data with the foot link. Open the global matrix out-port of this object node and connect it to the global matrix in-port of the instance object node.

Actually a funny thing happens. The position is passed to the instance on impact and another object is created at the exact same moment so the global matrix stays with the last object it was passed to just before the new one is made. That means it stays where we want it.

Part 3 Debugging.

You must have noticed the whole thing doesn't work at all. One thing that goes wrong is the hierarchy node, it stops the xpresso from working when it doesn't define an object (when the container is empty) So what we need is that there is always at least one instance in the container-null so that the hierarchy works. So lets go to the first part of the xpresso and add a Math-node set to Add and with 1 in the second field. Squeeze the node between the mono-flop and the instance node. Now at least the thing works but for a reason that is beyond my understanding the first step is not being made, but if you put 2 in the math node this is solved and all goes fine. The last thing we need in this part of the xpresso is to reset the mono-flop at the start of the animation. We do that with a time-node connected to a compare node. Set the compare node to == and enter 0 in the second field. Now the node will give a "True" when the timeline is a frame 0. Connect the output to the reset-port of the mono-flop. There is another bug at least for the stamp example and that is that the instances are positioned slightly off

the floor, they are floating. So I made a copy of the hierarchy setup and modified it to D-LP(down, last, previous) as to select the previous object. I feed the position Yof the selected object whit a 0 to stick the object to the floor.

How to customize it?

To make footsteps in sand you could do that by subtracting the step object from the floor object using a Boolean object, or try a proximal shader to get a bump footstep.

You can also make an xpresso that creates an instance of a spline object with a loft nurb as the container this is really fun. I made a few of these variations in one of them I create an instance of a spline at every frame as to produce a trail behind my object. This is the toothpaste xpresso.

Have Fun! And show me your variations in the forum.

Areminder: Do NOTdistribute the instance node, it is only for readers of the magazine. This is important to me and I hope you respect that.

This article is from: