netPivotShift

|_

*object* |_ pivot_loc

|_ object_rotInstead of step by step tutorial, I will try to describe main logic of how it works. First, let's examine our goal and see what kind of result we are looking for. Here is an image that shows the initial status and what we expect after rotating the cube.

If we rotate the cube right now in our current initial state, then what we get is shown in the image below. It's what you would expect since our pivot is parented under the cube. But this is not what we want.

So how do we go from our initial state to the final result? There are different ways to solve this problem. Here, we look at one way to do it, which may not necessarily be the easiest.

First thing we need to keep in mind is that our pivot is parented under the cube, that means our pivot is operating under cube's coordinate space (

**V.IMP.**). Now, let's see the steps to get the final result.

**#1**) We move the pivot point so that it lies on the origin. (Keep in mind, this origin is in our cube's space)

Why do we do this? So we can apply rotation matrix which always rotates around (0,0,0)

**#2**) Now, we apply the rotation, which will be around the origin by default.

See it already looks closer to the result we want!

**#3**) Then we reverse the first step. We move everything back so that pivot goes to it's original location.

And we have our final result!

The matrix equation to get the above result is:

shift = pivot_loc.inverseMatrix * object_rot.matrix * pivot_loc.matrix

(this can be a bit confusing if compared to original equation in first post, because we are taking a bit different approach here)Now prepare the network to calculate the object movement around pivot using above matrix equation. Plug object's rotation into

*object_rot*which will be our rotation matrix. Once you have the matrix calculation network ready, plug the final

*.matrixSum*to a

*decomposeMatrix*node's

*.inputMatrix*attribute. What we will get here (in

*.outputTranslate*) is the translation value that the

*object*should move to get the pivoting movement around pivot_loc. Just to test the result you can plug

*.outputTranslate*attribute of decomposeMatrix node to

*netPivotShift*node and see how it works. Give it a try, it's fun! :)

Phew! That took the whole brain out of me! Now, remains the offsetting logic. Let's keep it for the next post to give my brain processor some rest :)

Hey, amazing solution for the animatable pivot, this is the one I've liked the most. Thanks for sharing it:)

ReplyDeleteDid you ever find a way to solve the offsetting issue?

Thanks again:)

I did find it but never got around to post it since I moved on to other things :)

ReplyDeleteThis something that's plagued me for a while....I can't wait to see part 3!!!

ReplyDeleteIt took me some time to figure out how to build animatable offsets in Maya. I did build such a system but never got around to post about it.

DeleteHey there, awesome materials on matrices, i didn't manage to recreate the network though, according to your equation, i'm definately missing something. Would you mind giving a few more hints on how you achieved it, thx.

ReplyDeleteHello Sir,

ReplyDeleteI am facing problem creating an animateable pivot, whenever i try and translate the pivot the object starts sliding in the worldspace can you suggest a solution for that

Thank You.