PDA

View Full Version : (Maya) Connection via expressions


artoon
25-02-2005, 07:35 PM
Hi, I am using maya and I don't know much about mel.

I'll give you an example to show what I want to know.

Say I have a cube and a sphere (polys). I created a new attribute for the cube called "Spin" and I want to control the rotation Y of the sphere.
So far so good, all I have to do is open de connection editor and make the connections (or the expression editor - pSphere1.rotatey = pCube1.spin ).

But, I set the min value of the "Spin" to -10 and the max to 10 with defalt 0. If I connect them with those values, the sphere will rotate only 10 degrees in Y in both directions.

What I want to know is: what I have to type in the expression editor to connect the min value of the sphere (-360 degrees) to the min of the "Spin" value (-10) and the positive values as well (360 = 10) and when I scrub the "Spin" value to 10, the sphere rotates its max value (360).

Thanks in advance,

Artur

Black
09-03-2005, 10:38 PM
Artoon;
This may sound a bit too simple... but if I got your wuestion right.. leave the expression editor aside and do it with SetDrivenKeys!

The thing about expresions are they are aLWAYS active and if you have some they are good.. but if you have ALOT of them they are VERY effective in slowing down your scene.
How it works is.. MaYA see's that this scene has an expression. Reads it.. and evaluates the conditions needed to excecute it. So it scans through the whole scene to se if the conditions are met or not.

You do the math!


Well there are alternatives to expressions in many cases. So get yourself used to finding them.
Like in your situation.. just make the one you would like to push and tug the driver and have the other your driven.
if you set key to pSphere1.rotatey=360 with pCube1.spin=10
or likewise;
pSphere1.rotatey=0 with pCube1.spin=-10
This would also get you clean inbetween tweens.

Just let me know if you haven't used SetDrivenKeys before... OR if I totally misundersttod the question.. let me know.

Black

Ps; Another advice is to avoid numbers like '-360' or '-180' in Mel. Preffer to find ways around it to get it to '0' or '180'. Oddly with 90 it's not exactly the same thing.. or to any agnl up to 180...