03 March 2013 | |
![]() |
|
Veteran
portfolio
Corey Kaliszewski
Erie,
USA
|
Freezing transforms doesn't freeze pivot?
So basically I created a script that moves the pivot to various parts of the object. Everything works fine until I freeze the transforms of the object. Here is what I have:
I'm still a beginner with MEL, any ideas why freezing the transforms messes up the code? |
03 March 2013 | |
![]() |
|
Expert
portfolio
franky****inFourFingaz
-
Dresden,
Germany
|
Can you explain what you mean with "messing up the code" and "doesnt freeze pivot"?
|
03 March 2013 | |
![]() |
|
Veteran
portfolio
Corey Kaliszewski
Erie,
USA
|
It doesn't really mess up the code, it just acts differently when the transforms of the object are frozen. If I run that bit of code with a newly created object it will put the pivot point at the top (Y) most point of that object. If I then freeze the transforms of that object and run the code again, it will put the pivot point for that object no where near the object in XY or Z.
So I'm guessing when click free transforms something is changing with the pivot location or the pivot location isn't "freezing". |
03 March 2013 | |
![]() |
|
Expert
portfolio
franky****inFourFingaz
-
Dresden,
Germany
|
As long as you do not freeze objects their bounding box matches the objects local transformation. Freezing then resets the transformation relative to the parents space, so a new, axis aligned bounding box will be the result, all former object transformations go into the vertices/control points. Just put your viewport shading into bounding box mode, create a poly box, rotate it and group it, then rotate the group. Now freeze the cube and after that freeze the group and look what happens. Your script just behaves as it is supposed to be.
|
03 March 2013 | |
![]() |
|
neglostyti
portfolio
Viktoras Makauskas
Vilnius,
Lithuania
|
why not just query worldspace bounding box coordinates with "xform -q -boundingBox -worldSpace", calculate object "top" from that bounding box (no center pivot shenanigans) and set pivot position with "xform -rotatePivot"? Not at maya right now so can't give exact code for that, but should be pretty straightforward.
|
03 March 2013 | |
![]() |
|
Veteran
portfolio
Corey Kaliszewski
Erie,
USA
|
Ok I did what you suggested and everything is working. I have another procedure within the script that I can't figure out when the transforms are frozen. I am trying to center only X and Z, what I have now is:
Which it does center X and Z, but Y keeps moving and I understand why. I have tried to calculate the center of X and Z and leave Y at 0 when moving the pivot but that didn't work. What I did was:
What would be the best way of centering just X and Z after the transforms are frozen? |
03 March 2013 | |
![]() |
|
Expert
portfolio
franky****inFourFingaz
-
Dresden,
Germany
|
If you really only want to center XY in your new bounding box the math you use is wrong. The center is (bbMin + bbMax) * .5 . Also the positioning of the pivot you do is just adding the new values relative on top of your current position. Try this
|
03 March 2013 | |
![]() |
|
Expert
|
Thread automatically closed
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.
__________________
CGTalk Policy/Legalities Note that as CGTalk Members, you agree to the terms and conditions of using this website. |
Thread Closed share thread |
«
Previous Thread
|
Next Thread
»
|
|
|