Post
by Matic » 25 May 2013, 02:28
I don't know that there is any simple way to explain it, but I'll try...
Look at the first video. There is a core concept here that he cleverly uses... I mentioned it in the update to the whirlpool deformer in the resource dump area here on si-community. You can use an inverse of an objects transformation matrix to calculate what the point positions of an object would be if it were at the origin.
In this case, instead of taking the transformation matrix of the object, Paul builds a transformation matrix for the object based on the point reference frame of the point closest to the null. When he multiplies all of the points of the sphere by the inverse of this matrix he is effectively moving those points such that the sphere is centered at the origin and rotated so that the "trigger" point is topmost. He then raycasts down to the face, looks at the length of the vectors which intersect the face, displaces those points by that amount, and then finally multiplies the new point positions by his constructed matrix to move the sphere back to where it was.
This general idea of moving points to be relative to the origin, doing something, and then moving them back is really useful, and not just for deformations.
For instance, I have a compound which moves particles in a pointCloud to the origin based on where a null is, imagine if the null was a parent of all the particles and you move it to the origin. I can then do interesting things, like measure the distance between the particle and the null on say the x axis and use that distance to color the particles.
In actuality I haven't moved the points, just calculated where they would be and used that to color them. The result is basically a directional light, any points close to the nulls x-axis get one color, say white, which falls off to another, black, the further those points are from the nulls x axis. You move the null around, rotate it etc and the particles color is updated correctly.
Hmmm. See what I mean? It's hard to explain simply, even though actually doing it is easy enough and very useful. If it helps, I've been meaning to try to tackle the subject in a blog post and I have some example scenes which may help when I do, but unfortunately I'm about to get busy on a big job and it may be 2 months before I can write anything up. Until then, look at the whirlpool example and see if you can puzzle it out, I believe I encapsulated the part where I move points to the origin and back in a compound. It will take a bit for the concept to become clear but when it does its really empowering. Cheers.