Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Slider controler values
PostPosted: Wed Nov 13, 2013 11:44 am 
User avatar
Jedi Master
Offline

Joined: Wed Apr 02, 2008 11:16 pm

Posts: 1007

Location: Kapiti Coast, Wellington
I often make slider controls for various parts of rigs such as a slider to change blendshapes / shapekeys or maybe a slider to affect the size of a character's eye pupils.

For a slider with values from 0 to 1 (bottom to top) the formula / expression to translate this to a numeric action value is easy.

x (slider) y (action)
1 => 1
0 => 0

formula is y = x

...even with abitary values, such as in the case of pupil dilation where the size might go from 0.5 (min size) to 7.0 (max) working out the formula is not hard:


x (slider) y (action)
1 => 7.0
0 => 0.5

formula is y = 6.5x + 0.5

You see, I can always get the linear formula by y = [max(y) - min(y)]x + min(y)

Where I have a problem is that sliders aren't always two points 0 and 1. They are usually three points with a "rested" midpoint. Therefore, the values for a slider would be:

x (slider) y (action)
1 => 2.5
0 => 1.0
-1 => 0.5

If I graph these points out, it forms a curve. I want to make a formula for this curve so that I can plug it in as a driver from slider to action. How do I go about devriving the formula for curves like this? Is there a way I can do this *every* time? I'd like to make a small program to save me time when it comes to making lots of sliders for different actions which aren't always linear through -1, 0, 1 (min, rested, max) but are more often something like 2, 5, 14.

What tool can I use to help me with this kind of maths?


Top
 Profile  
 
 Post subject: Re: Slider controler values
PostPosted: Thu Nov 14, 2013 7:40 am 
User avatar
Ewok
Offline

Joined: Mon Sep 06, 2010 7:19 pm

Posts: 12

Location: New Zealand
If you're not set on needing 'pure' maths, you could always make use of driven keys if you're working in Maya.
http://lesterbanks.com/2012/01/introduc ... s-in-maya/

The animation node created by setting up driven keys is basically the curve you are looking for. As a bonus, if you know your way around Maya nodes you can find the animation node/curve it creates and set it to cycle with offset. Then if your key data is something like..

driver.translateY = 1 : driven.translateY = -1.5
driver.translateY = 0 : driven.translateY = 0
driver.translateY = -1: driven.translateY = 1.5

... and you want to push your driver object past that, the animation curve will figure out the resulting curve for you.

driver.translateY=2 :driven.translateY = -3

I'm basically a straight Maya user but I suspect there's an equivalent in other packages if you use something else.


Top
 Profile  
 
 Post subject: Re: Slider controler values
PostPosted: Thu Nov 14, 2013 3:27 pm 
User avatar
Jedi Master
Offline

Joined: Wed Apr 02, 2008 11:16 pm

Posts: 1007

Location: Kapiti Coast, Wellington
Aha - thank you creature.

I am using Blender, but your Maya solution of modifying the animation curve does indeed translate between softwares. It's the "Graph Editor" in Blender, which is pretty much the same idea of Maya's Curve Editor. There he is...
Attachment:
sliderconversion.png
sliderconversion.png [ 26.64 KiB | Viewed 2703 times ]

:thankyou: Thanks again. Trying to get the function working in pure math every time was doing my head in a bit. :lol:


Top
 Profile  
 
 Post subject: Re: Slider controler values
PostPosted: Thu Nov 14, 2013 5:12 pm 
User avatar
Ewok
Offline

Joined: Mon Sep 06, 2010 7:19 pm

Posts: 12

Location: New Zealand
:bravo: I'm glad you could find an equivalent. Happy rigging.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron

About Us


Contact Us


Advertise on NZCGI

Powered by phpBB® Forum Software © phpBB Group
Logo Design by - Oliver Hilbert Revilo Designs