DeFi
11-12-2006, 01:00 PM
Hi, everybody.
I have a little rigging problem. Since a sphere-look-at + fdd solution wasn't applyable for my new comic character, I tried to develop an eye control system that realizes eye movements by altering the uv coordinates of the eye materials. I ended up with a custom attribute driven script controller system that uses the following parameters to drive both eyes(Paul Neale's excellent attribute_holder script helped a lot with this, so: Thanks! :D ):
left/right: moves the eyes left and right
up/down: moves the eyes up and down
center: determines the eye crossing factor
size: the size of the pupil
squeeze: squeeze the pupil horizontally or vertically
This works fine but it would also be nice to have the possibility to drive the eyes by an object they always look at. So I placed two point helpers behind each eye. A zero-direction helper that always looks at a default position target for the eyes and a direction helper parented to the zero helper that always looks to the actual position target for each eye. Now my idea is, to get the angles between the x and y components of the rotation of the the direction helpers relative to the zero-direction helpers and drive the uv coordinates with this. So if you get an x angle of, lets say, 60° and x corresponds to up/down movements you make a linear contraint between the angle and the desired uv-offset.
So next thing I tried was, to wire the rotation components of the direction helpers in their parent space(they are linked to the zero-direction helpers) to the uv-coordinates. Unluckily the look-at controllers of the direction helpers had no values that contained these relative angles and the Euler-XYZ controller thats below it in the rotation list controller has some rotation values, but they would obviously not contain what I was looking for.
So I thought about using a script controller on the uv-coordinates as I did earlier for connecting them to the custom attributes. Digging the maxscript reference brougt out a nice piece of code that should be able to determine the angle differences between two objects. I modified the code a little bit and came up with this(eyeZeroDirection and eyeDirection contain the nodes to the two helper objects):
dParent = inverse eyeZeroDirection.transform;
dChild = eyeDirection.transform;
dResult = dChild * dParent;
rotQuat = dResult.rotation;
rotEuler = quatToEuler rotQuat order:1;
up_down = rotEuler.x;
up_down = up_down / 60.0;
Evaluate => no errors => Halleluja! But the strange thing is: Not only that nothing happens with the uv-coordinates while moving the eye targets now and thus changeing the direction of the direction helpers. In addition the track view and max now freeze for 30 seconds every time the new script controller is selected in the trackview. I spent the last three hours on fiddeling around with this, but the error successfully managed to hide from me. :sad:
So my question is: Does anybody see my error or has a solution for my problem? It would be very nice if you would sacrifise a little bit of time to help me on this.
Thanks
DeFi
I have a little rigging problem. Since a sphere-look-at + fdd solution wasn't applyable for my new comic character, I tried to develop an eye control system that realizes eye movements by altering the uv coordinates of the eye materials. I ended up with a custom attribute driven script controller system that uses the following parameters to drive both eyes(Paul Neale's excellent attribute_holder script helped a lot with this, so: Thanks! :D ):
left/right: moves the eyes left and right
up/down: moves the eyes up and down
center: determines the eye crossing factor
size: the size of the pupil
squeeze: squeeze the pupil horizontally or vertically
This works fine but it would also be nice to have the possibility to drive the eyes by an object they always look at. So I placed two point helpers behind each eye. A zero-direction helper that always looks at a default position target for the eyes and a direction helper parented to the zero helper that always looks to the actual position target for each eye. Now my idea is, to get the angles between the x and y components of the rotation of the the direction helpers relative to the zero-direction helpers and drive the uv coordinates with this. So if you get an x angle of, lets say, 60° and x corresponds to up/down movements you make a linear contraint between the angle and the desired uv-offset.
So next thing I tried was, to wire the rotation components of the direction helpers in their parent space(they are linked to the zero-direction helpers) to the uv-coordinates. Unluckily the look-at controllers of the direction helpers had no values that contained these relative angles and the Euler-XYZ controller thats below it in the rotation list controller has some rotation values, but they would obviously not contain what I was looking for.
So I thought about using a script controller on the uv-coordinates as I did earlier for connecting them to the custom attributes. Digging the maxscript reference brougt out a nice piece of code that should be able to determine the angle differences between two objects. I modified the code a little bit and came up with this(eyeZeroDirection and eyeDirection contain the nodes to the two helper objects):
dParent = inverse eyeZeroDirection.transform;
dChild = eyeDirection.transform;
dResult = dChild * dParent;
rotQuat = dResult.rotation;
rotEuler = quatToEuler rotQuat order:1;
up_down = rotEuler.x;
up_down = up_down / 60.0;
Evaluate => no errors => Halleluja! But the strange thing is: Not only that nothing happens with the uv-coordinates while moving the eye targets now and thus changeing the direction of the direction helpers. In addition the track view and max now freeze for 30 seconds every time the new script controller is selected in the trackview. I spent the last three hours on fiddeling around with this, but the error successfully managed to hide from me. :sad:
So my question is: Does anybody see my error or has a solution for my problem? It would be very nice if you would sacrifise a little bit of time to help me on this.
Thanks
DeFi
