PDA

View Full Version : Expression for a new Rotation Attribute


Mickley
02-11-2003, 10:41 AM
I have a joint Lets say Joint01, which is able of rotating on Y and on Z axis (lets say from -30 to 30 deg in each direction).

Now I got in a situation where I need to have a separate atribute for rotation. Which will rotate Joint01 in Y and Z direction simultaneously. Lets say I've created attribute called Rotate_YZ.

Now behold..!!THE QUESTION...!!

How Expression for the new attribute should look, if I want it:

1. to control YZ rotation of the Joint 01 from (0,0,0) to (0,30,30)

2. To be controlled by standard Joint01.rotateY and Joint01.rotateZ attributes.

For example if I type in in a chanel box for rotateZ=20 and rotateY=20. So Rotate_YZ will automatically turn 20 as well. And vice versa.

It didn't seem to me horribly complicated at first.
I dug a documentation for two hours, but my expressions are not doing any good yet. (they stink):shrug: :thumbsdow
Now I'm exausted and asking for your guys (Profi's) help.

Thank you in advance.

P.S. Yep. And another condition: tveaking a single attribute shouldn't make any difference for Rotate_YZ. Like if I do RotateZ=20, RotateY=0, then Rotate_YZ stays unaffected (0)

svenip
02-11-2003, 10:53 AM
you could do it this way:

first create an extra node (locator or transform) and move the pivot (or the object itself) to the joint. then parent your joint under this new node. now simply connect the z rotatio to the y rotation. if you now rotate y the z will go with it, and you still have independend control over your joint.

or create an extra attribute on the new node and write expression :


joint.rotateZ = newNode.newAttribute;
joint.rotateY = joint.rotateY;

Mickley
02-11-2003, 01:43 PM
Thank you svenip.
I'm gonna try this today. But I was hoping there was a "bloodless" method, based only on expression involving the two rotations within the joint only. Without employing additional locators for this.
something like

if ((Joint01.rotateY == 30) && (Joint01.rotateZ == 30))
Joint 01.Rotate_YZ = 30;
else
Joint 01.Rotate_YZ = 0;

Unfortunately this is not working the way I wanted. I was trying diffirent implementations and varyations involving adding 'if else' statements, playing with values and so forth, but its just all wrong.

I was hoping ithat somebody with more Mel experience, (seriously its my first expression), would give me a push in a right direction or correct my 'scribbles' in a proper way.

So if there is a still another way(s) to do this I would be glad to hear it. (I'm sure there are, (assuming the power of Maya)):airguitar

svenip
02-11-2003, 01:47 PM
the problem with joint only is that if you write an expression for the YZ rotation the values will be keyed and not anymore animatable. thats why you're goin through an extra node to compensate this.

Mickley
02-11-2003, 06:25 PM
Ok that explains everything.
I got my "push in a right direction", will work that out.
Thank you very very much man!

CGTalk Moderation
01-14-2006, 09:00 AM
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.