View Full Version : Rotate a spot light
cppgraphics 10092011, 06:56 AM hello folks,
I need to rotate a spotLight towards a locator, how to do it in MEL? I xform command by querying locator's ws rotation and applying for the light. But not working as I expected.
Tried aim constriant, its working but how to calculate aim vector?
Someone please give me suggestion.
Cheers :)


NaughtyNathan
10092011, 02:42 PM
aimConstraint IS the way to do it in MEL. Doing stuff with nodes is almost always more efficient than doing it with pure maths in MEL. If you don't want to keep the constraint, delete it, if you do need a vector for some reason, do the constraint and then get the Z vector from the light's worldMatrix.
Mathematically, if you subtract the lights world position from the locators world position you'll get an aim vector, but you'll still need to cross this with something else to get anything meaningful from it. Getting X,Y,Z rotations from an aim vector is the hardest bit, is that what you want to calculate here?
:nathaN
cppgraphics
10092011, 05:42 PM
aimConstraint IS the way to do it in MEL. Doing stuff with nodes is almost always more efficient than doing it with pure maths in MEL. If you don't want to keep the constraint, delete it, if you do need a vector for some reason, do the constraint and then get the Z vector from the light's worldMatrix.
Applying Z vector is working for me Nathan, from any place of my scene spotLights look the locator. :)
Thanks.
CGTalk Moderation
10092011, 05:42 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.
vBulletin v3.0.5, Copyright ©20002015, Jelsoft Enterprises Ltd.