I feel I am trying to do something that is fairly straight forward but am hitting some walls with Maya.
This is not an aimVector question.
I am trying to setup a simple light aim constrained to a locator so I can move the locator and the light is always looking at the locator. Simple enough. This can be done 2 ways, niether of which is working how I want:
Aim Constraint
- When looking through the light and orbiting, the light will often gimbal lock and flip. this makes it very difficult to 'nudge' a light just a little.
- Dollying is not possible when looking through the light camera as you can with a lookAt node.
lookAt node (This is what is used when you do a 'Create -> camera -> Camera and Aim')
- Dollying (alt MMB) possible when looking through light
- No gimbal lock when orbiting about locator and looking through light camera.
- When the locator is moved, and then you orbit while looking through the light camera, you now get an annoying 'snap' every time you move the light. The light is looking at the old location of the locator until you mouse up.
I would love to be able to set it up so that it acts like a lookAt node, but without the snapping. This is killing me and I would love any ideas....
In case you are interested here is some mel for creating each version:
CODE
global proc string[] createAimLocator(string $xform)
{
string $locatorShapeList[] = spaceLocator -p 0 0 0
;
string $locatorShape = $locatorShapeList[0];
// Make sure we are operating on the transform
if ( "transform" != nodeType $xform
) {
string $parents[] = listRelatives -parent $xform
;
$xform = $parents[0];
}
string $aimList[] = aimConstraint -offset 0 0 0 -weight 1 -aimVector 0 0 -1 -upVector 0 1 0 -worldUpType "vector" -worldUpVector 0 1 0 $locatorShape $xform
;
return {$locatorShape, $aimList[0]};
}
string $light = spotLight
;
createAimLocator($light);
CODE
string $light = spotLight
;
if ( "transform" != nodeType $light
) {
string $parents[] = listRelatives -parent $light
;
$light = $parents[0];
}
string $locatorShapeList[] = spaceLocator -p 0 0 0
;
string $locatorShape = $locatorShapeList[0];
string $target = $locatorShape;
string $lookAt = createNode -name ($light+"\_group") "lookAt"
;
setAttr ".aimVector" -type double3 0 0 -1;
connectAttr ($target+".tx") ($lookAt+".target[0].targetTranslateX");
connectAttr ($target+".ty") ($lookAt+".target[0].targetTranslateY");
connectAttr ($target+".tz") ($lookAt+".target[0].targetTranslateZ");
connectAttr ($target+".rp") ($lookAt+".target[0].targetRotatePivot");
connectAttr ($target+".rpt") ($lookAt+".target[0].targetRotateTranslate");
connectAttr ($target+".pm") ($lookAt+".target[0].targetParentMatrix");
connectAttr ($light+".pim") ($lookAt+".constraintParentInverseMatrix");
connectAttr ($light+".t") ($lookAt+".constraintTranslate");
connectAttr ($light+".rp") ($lookAt+".constraintRotatePivot");
connectAttr ($light+".rpt") ($lookAt+".constraintRotateTranslate");
connectAttr ($lookAt+".constraintRotateX") ($light+".rotateX");
connectAttr ($lookAt+".constraintRotateY") ($light+".rotateY");
connectAttr ($lookAt+".constraintRotateZ") ($light+".rotateZ");
connectAttr ($lookAt+".distanceBetween") ($shapes[0]+".centerOfInterest");