Hi,

Im not sure what you mean by " i need the one on the object to remain at the
bottom" , are you saying that you need to force the locator and/or sphere to
remain lower than the plane ? If so it would depend on what is driving the
sphere's animation.

In regards to calculating how far the sphere's locator goes through the
plane's locator, what i would do is get the worldspace position of the
locators. I would then set up a statement to check when the sphere loc's
position is higher than the plane's loc's position. When the sphere's loc
has registered as being higher, subtract the worldspace position of the of
the plane loc from the worldspace position of the sphere loc. This will give
you the difference between the two, as a vector. You then calculate the
length of that vector by using the following formula:

length = (vector[0]*vector[0] + vector[1]*vector[1] + vector[2]*vector[2])
** 0.5


This will give you in units how far the sphere's loc has gone "through" (or
above) the plane's locator.

for example ( evaluated on a per frame basis ) -

sphereLoc = cmds.xform("sphereLocator", q=1,ws=1,t=1)
planeLoc = cmds.xform("planeLocator", q=1,ws=1,t=1)

if (sphereLoc[1] > planeLoc[1]):
    difVector = [sphereLoc[0] - planeLoc[0],sphereLoc[1] -
planeLoc[1],sphereLoc[2] - planeLoc[2]]
    length = (difVector[0]*difVector[0] + difVector[1]*difVector[1] +
difVector[2]*difVector[2]) ** 0.5
    print "sphereLocator is %s unit above  the planeLocator" % length


Cheers,
Beau
-- 
http://groups.google.com/group/python_inside_maya

Reply via email to