Animated Pivot in Maya


#1

Here is a little tutorial show casing two basic methods of creating a pivot controller for animation. Hope you like it!

http://suchanspot.blogspot.com/2011/04/animated-pivot-in-maya.html


#2

Second method requires a bit more complicated setup if you want to create a true animatable pivot. You have to also calculate rotatePivotTranslate on the fly to compensate for extra movement when you change the pivot of already rotated object. I believe Jason’s pivot solution was to find this offset and run the script to fix it.

I did a setup some time back which was to use the nodes to do this calculation. Here is the result VIDEO (it doesn’t show much).


#3

@theflash … very interesting. yes once the pivot has been rotated, and then translated, there is some weird transformation, that is a real pain. can be fixed with some script job just the way Jason did.

Anyways, i looked at your video; it is really cool. I would love to achieve this solution. If you are willing, can you enlighten me with some logic to your setup. I would love to try it out for myself. Thanks for the share man :cool:


#4

hmmm i think i have a little lead in here. seems like if you want a realtime pivot control solution you gotta dig in the maths behind the connection of rotatePivot and rotatePivotTranslate … Let’s see what I can do!? it sure is a tough cookie :wip:


#5

That’s the right track. If you look at Jason’s solution, he does the same but with a script that you run from shelf. The calculation I posted on my blog lets you calculate the actual movement that you can use to negate shifting of the object.
Posting the link here again, might be helpful to someone.
http://leftbulb.blogspot.com/2011/04/making-animatable-pivot-part-1.html


#6

Thanks for the share Maulik! The post you posted is surely very helpful :smiley:


#7

I have implemented the second method in my rigs also, would you be able to post the script please?


#8

I am following this thread, and looking forward to your next blog-post Maulik :slight_smile:


#9

Nice approach Suchan,
It remember me Jason´s AFR pivot technique… Do you know that one ??

Maulik
I´m going to read your blog post, thanks for sharing.

I´m following this thread guys !!

cheers,


#10

pritishd, GabrielPettersson & polimeno … well thank you all for following the thread. It has always been a real challenge to actually create a animatable pivot controller. Well, Maulik is sharing his knowledge on a solution for that and I thank him for doing such a nice thing for the community.

As far as the scripts goes :
You can download all of the Jason’s AFR scripts from here … one of them is the pivot tool … all of his scripts are wonderful and a special thanks goes to him as well :wink:

Click here :beer:


#11

I am working on the next post. I started writing it but I realized I need to take time to explain it well as I needed to understand few things myself first :slight_smile:


#12

Well, would you look at that! :slight_smile: I made a version of Jason’s approach just a few hours ago!
As for the math, it is very simple yet very confusing at the same time, since you are essentially swapping transform spaces with one another.

Have a look.

"""
  	Author: Marcus Ottosson
  	Mail: konstruktion@gmail.com
  	Date: 2011-04-14
  	
  	Adjustable Pivot Control
  	
  	DESCRIPTION
  		Creates and controls a movable pivot for any controller.
  	
  	USAGE
  		1. Place loc_anim where you want your pivot to start out, e.g. frame 1.
  		2. Key loc_anim and original controller
  		3. Animate, e.g. frame 10, and key both the controler and loc_anim
  		4. On the next frame, move the loc_move to where you'd like the pivot to end up next.
  		5. Key loc_anim and ctrl
  		6. snapPivot()
  
  """
  
  import pymel.core as pm
  
  anim_ext = '_loc_anim'
  move_ext = '_loc_move'
  
  def createMovablePivot():
  	sel = pm.ls(sl=1)
  	if not sel: return
  	
  	for ctrl in sel:
  		ctrl_pos = ctrl.rotatePivot.get() # The controller pivot
  		
  		loc_anim = pm.spaceLocator(n=ctrl + anim_ext)
  		loc_move = pm.spaceLocator(n=ctrl + move_ext)
  		
  		pm.parent(loc_move, ctrl)
  		pm.parent(loc_anim, ctrl)
  		
  		loc_move.t.set(ctrl_pos) # Match the pivots to the current pivot
  		loc_anim.t.set(ctrl_pos)
  		
  		loc_move.v.set(0) # Hide the movable pivot
  		
  		objs = [loc_anim, loc_move]
  		for obj in objs:
  			obj.t.set( ctrl_pos )
  			
  			obj.r.lock()
  			obj.s.lock()
  			obj.v.lock()
  		
  		loc_anim.t >> ctrl.rotatePivot # Hook it up.
  
  def snapPivot():
  	sel = pm.ls(sl=1)
  	if not sel: return
  	
  	for ctrl in sel:
  		if pm.objExists(ctrl + anim_ext): loc_anim = pm.PyNode(ctrl + anim_ext)
  		else: break
  		if pm.objExists(ctrl + move_ext): loc_move = pm.PyNode(ctrl + move_ext)
  		else: break
  		
  		new_loc_pos = loc_move.t.get()
  		
  		# Main line of math. Put the cube where the movable pivot is in WORLD SPACE,
  		# then compensate for the movement (cause of the way the hierarchy is setup)
  		# by subtracting the same position from the ctrl. 
  		new_cube_pos = loc_move.worldPosition.get() - new_loc_pos
  		
  		# Apply
  		loc_anim.t.set(new_loc_pos)
  		ctrl.t.set(new_cube_pos)
  

#13

:beer::cool::wavey::bowdown:


#14

Hey Marcus, this looks nice and easy. I was testing how it works, but I didn’t manage to get it work properly, when I run snapPivot my pivot resets to object’s center point. May be I didn’t follow everything right?


#15

I wasn’t able to finish the whole article, but here is part 2 of making animatable pivot.
Let me know your feedback.


#16

Hi maulik,
Nice work :). I have created a little different setup, it is based on expression but there it have some problems, which I can’t fix, yet. Animation works fine, but after every play, initial position of the object is not the same as when played first time. No matter, I’ve done this with step back or just slide time slider back to the beggining oth the time range.
Here is the code :


float $ltx = `getAttr pivot_Ctrl.tx`;
float $lty = `getAttr pivot_Ctrl.ty`;
float $ltz = `getAttr pivot_Ctrl.tz`;

xform -rp $ltx $lty $ltz object;

It’s very simple :).
pivot_Ctrl = locator
object = pCube
locator is a child of pCube
Here is the video of animated cube.
Pivot Point Animation VIDEO
any suggestions to solve this?


#17

I wasn’t able to finish the whole article, but here is part 2 of making animatable pivot.
Let me know your feedback.

Keep it coming Maulik … really appreciate your good work :beer:


#18

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.