Change object pivot axis pointing towards camera view

Hi all, is it possible to modify/grasp the selected object pivot point (transform, rotate and scale) in which the pivots are pointing towards the camera that user selected/ via a list of cameras in the scene?

I tried some constraining, but it does not seems to be working in my cause and I have to manually go into component mode to rotate the axis, though it helps but it is tedious as I have to pretty much do some try and error.

The second attachment is what I am trying to achieve
Basically I create a linear EP curve, snapped each ends to the camera and the object center point. Using the curve as a reference, I go into componenet mode and rotate it to match the x-axis to the line



To actually set the pivot axis (without appearing to rotate the geo) use


example = (10, 10, 10) # 10 degrees on each axis
cmds.xform(ra = example, p=True)

The hard part is getting the right euler angles for your angles. That’s not easy because the .rotateAxis value that would aim one axis at the camera could be any XYZ angle , and XYZ rotation to counteract the change in the .RA is not necessarily just that XYZ * -1, -1, -1.

Maybe it would be easier to try it like this

  1. create a locator
  2. constrain the locator to aim the way you want your axes to go
  3. parent the geo to the locator
  4. copy the rotation value of the geo to it’s rotateAxis, and vice-versa . Object should appear not to move
  5. unparent

Hi Theodox, thanks for getting back to me.
Not sure if I did the 4th step wrong, while the object does not appear to have been rotated, but the axis are not the same as the one in the locator, not pointing towards the camera. It is still in world-axis…

#4 is really two steps; you want to swap the numbers in RO and RA

Correct me if I am wrong in step #4, this is what I did.

Supposedly, from step #1-#3, where my locator values of RotX, RotY and RotZ are -10, -10, 10 respectively and as I parent my geo into the locator and hence inheriting its rotation values 8.29, 11.453, -8.29 (no idea why the rotation is not the same as the locator values…)

Nevertheless, I copied the rotational values of the locator into the Rotate Axis in the geo, however in this case, though the axis is pointing in the right direction, the geo is being rotated. Even so, it is wrong though the axis is right?

Am I doing it wrong somewhere?

Parenting it will put non-zero values into rotate (You may also have non-zero values in RA). You’ll swap the RA and RO values , which should leave the object in the same position but change the local axis orientation. When you unparent the numbers will change, but the axis will still be aligned the way the locator was. You don’t want to zero anything: the swapping is what keeps the alignment consistent.

You may get odd numbers because there are multiple valid euler angles for a given matrix. As long as you swap the values between RO and RA you should get a new local axis orientation and the same appearance. You may have issues if the locator orientation is more than 90 degrees off from your box in two axes – I’m not sure what will happen if the rotations gimbal out.

[QUOTE=Theodox;25269]Parenting it will put non-zero values into rotate (You may also have non-zero values in RA). You’ll swap the RA and RO values , which should leave the object in the same position but change the local axis orientation. When you unparent the numbers will change, but the axis will still be aligned the way the locator was. You don’t want to zero anything: the swapping is what keeps the alignment consistent.

You may get odd numbers because there are multiple valid euler angles for a given matrix. As long as you swap the values between RO and RA you should get a new local axis orientation and the same appearance. You may have issues if the locator orientation is more than 90 degrees off from your box in two axes – I’m not sure what will happen if the rotations gimbal out.[/QUOTE]

Doesn’t seems to work for me at all, for some reasons.
Regardless if what I did, if I do the method of what I mentioned above, my geo will nonetheless got rotated despite the axis is correct.

I have sort of found a way that is after parenting the geo to the locator, Freeze Transform on the geo and unparent it. This way not only it will not rotate the geo but at the same time it is pointing towards the camera.

However I do know that this is totally not a practical method, I guess. where it has to Freeze Transform every other time if I am going to use this method.
Perhaps are there any other better solutions that it can perhaps be implemented to improve it?

You could just create constrained locators and parent to those, and use them for the camera-relative moves only. That would be more flexible, but you’d have to remember when to use the locators and when to use the geo

Sure then, I shall tried it out and see how it goes.
Thanks again!

By the way, I came upon manipMoveContext command in which it has this custom axis orientation.

I tried it out and it seems to be manipulating the Rotate Axis despite me choosing Mode 6 - Custom Axis Orientation.

Just wondering if this command will helps in any way relating to this axis issue that I am trying to achieve? Otherwise is it similar to the method posted above?

Here’s something I use every once in a while. I don’t think this is exactly what you were asking about, but you may find it useful. It doesn’t change the rotation of the objects, but it will adjust your manipulator to orient the x axis right at the camera.

import pymel.core as pm
pm.manipMoveContext('Move', e=1, mode=6, orientTowards=pm.modelEditor(pm.playblast(activeEditor=1), q=1, camera=1).getTranslation(space='world'))

Hihi, I actually have managed to get it solved and I am using manipMoveContext as well as the position of the camera (that I would like it to point it to)
Basically, it will be creating a custom axis.

It is somewhat similar to what you may need