View Full Version : Expression for windshield wipers

 mehdift11 November 2012, 08:45 PMhello my fellow artists!!! guys i am stuck with a car rig i am doing, everything is working good so far, but i can't figure a way out to fix the WIND SHIELD wipers. i tried using an expression and even some other expressions, but it keeps going inside the window(wind shield)... and how can i limit its rotations, by the way, i have already freezed T,R,S of the wipers object, and i am thinking that is the reason why this expression is not working. This is the expression i have tried on so far: Wiper_left01.rotateZ = (sin (5 * time) * 50) + 325 i did try blendshapes as well, but that is a PAIN IN THE NECK!!! Any tips? help?
Nyro
11 November 2012, 10:05 PM
I dont know much about your particular setup, but if I had to set this up, I'd do it with Set Driven Keys.

Basically I'd create an attribute, say 'Wipe', as float between -1 and 1. I'd set a driven key between Wipe and my wipers Z and X axes (or whatever they rotate along) so that when Wipe = -1 the wipers are in idle position (horizontal), and at 1 they'd be at their maximum rotation (vertical). Maybe I'd set a key somewhere inbetween those to values too. Then I'd go into the graph editor and edit the resulting curves so that the wipers travel as accurately as possible over the windshield without penetrating.
After that, write an expression to control the Wipe attribute (sin shoud give you nice values between -1 and 1).

mehdift
11 November 2012, 05:11 AM
that sounds like a method of doing it man...

ok i will try that, in the end will make switch for it, i will update you once i have results.

by the way just to let you know, i am rigging a mini cooper austin.

thanks again

mehdift
11 November 2012, 04:00 PM
dear nyro

thanks for the tip man... i did what you suggested me to do, so far there is no problem, but i can't figure a way to write the expression without any problems.

this is the expression i wrote:

// wind shield wipers

if(TopControl_mini01.wipers == 1){

Wiper_right01.wiperright = TopControl_mini01.wipers (sin * time);

}else if(TopControl_mini01.wipers == 0){

Wiper_left01.wiperleft = TopControl_mini01.wipers (sin *time);

}

TopControl_mini01.wipers is the attribute that i have added for controlling the wiper movement. i hid and freezed the translation and scaling of both wipers, made an attirbute on both of them. which means i made a new attribute on the wipers itself to control the rotation axis and i named it as wiperright wiperleft.

but i can't set a condition where if the main controller is set to 1, the wiperleft and wiper right starts rotating the wipers.

it did work once, but the wiper was in the middle of the place!!!

HHEELLPPP :D?

Nyro
11 November 2012, 09:40 PM
I'm a bit confused at your explanation, I'll be honest, but I believe you didn't actually use Set Driven Keys, did you?

mehdift
11 November 2012, 06:25 AM
yes i did use set driven keys, for instance if the geometry is named wiper_left01, i added the new attribute to the wiper_left01, which means the driver and driven are both in the same geometry attribute channel. so the whole set of attribute channel for wiper_left01 is as follows:

Rotate X
Rotate Y
Rotate Z
Wiper: which controls all the rotation axis

i hope this time is more clear..

thanks for following up on me.

mehdift
11 November 2012, 02:36 PM
hey man

i finally fixed it... thanks a lot for the earlier tips, it is working like a charm with an on/off switch. i will soon upload a feature presentation of the car rig.

this is the final expression:

// wipers

if(TopControl_mini01.wipers_on_off == 0){

Wiper_right01.wiperright = 0 * (cos (9.5 * time));
Wiper_left01.wiperleft = 0 * (cos (9.5 * time));

}else if(TopControl_mini01.wipers_on_off == 1){

Wiper_right01.wiperright = -1 * (cos (9.5 * time));
Wiper_left01.wiperleft = -1 * (cos (9.5 * time));
}

CGTalk Moderation
11 November 2012, 02:36 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.

1