View Full Version : Alignin Object Axis with Vector

01 January 2013, 02:51 PM
Hi guys,

i want to align the up-vector of created object to the surface normal vector. Is there an elegant way to do it? or a node which already exists. Otherwise i have to create a lookAt() function.

thank you very much

01 January 2013, 08:33 PM
In python OpenMaya the MQuaternion constructor accepts two vectors.

01 January 2013, 07:31 PM
The angleBetween mel command may help you out. In this example, v1 is the up vector of your newly created object, and v2 is the normal of the surface you want to align to.
float $angleBtwnNode[] = `angleBetween -euler -v1 0 1 0 -v2 $normal[0] $normal[1] $normal[2]`;
rotate -a $angleBtwnNode[0] $angleBtwnNode[1] $angleBtwnNode[2] $newObjectName;

01 January 2013, 10:09 PM
you can also try using the Aim and Orient animation constraints for a node-based solution.

CGTalk Moderation
01 January 2013, 10:09 PM
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.