PDA

View Full Version : Facial slider UI_expression help


doude
05-12-2008, 10:29 AM
Hello everyone,

I have been a maya user for a couple of years now and i'm starting using max also.
Yeah... it's kinda painful:hmm:.

I would like to create the same kind of interface in MAX that i'm using in maya. But the language is slightly different when using expressions in the wire parameters.
I precise that i have looked all tutorials and video tutorial on the topic and I still couldn't find such an example of expression.

What i want is to create a square slider "joystick" (cf Stop starring by J.Osipa) where the four positions or 4 shapes ( ex: R_smile; L_smile; R_frown; L_Frown ) would be at the top corners of the slider. For this, i need obviously to combine the X_position and the Y_position of the circle control (ex: Ctr_circleMouth)

In maya, the expression could be written as following to get the 4 angle positions:
(the good thing with this is that when x=0 and Y=1 both Right andf Left shape are active)
morph.Lsmile = (Ctr_circleMouth.translateX+1) * (Ctr_circleMouth.translateY)
morph.Rsmile = (-Ctr_circleMouth.translateX+1) * (Ctr_circleMouth.translateY)

morph.LFrown = (Ctr_circleMouth.translateX+1) * (-Ctr_circleMouth.translateY)
morph.RFrown = (-Ctr_circleMouth.translateX+1) * (-Ctr_circleMouth.translateY)

I would like to know how to write this in the wire parameter of max. Is it possible to combine the x_position and the y_position in the same expression as above?

I attached a pic to help understanding, i hope it makes sense.
:) if someone can help, i'd be very grateful.
Thanks you.

http://www.aokistudio.co.jp/forum/imagepost/ex_slider_CGtalk.jpg

PEN
05-12-2008, 12:03 PM
Welcome to Max. It is far less pain full if you start by doing tutorials, you are going to soon find out that Max and Maya are two different packages and don't work anything alike when it comes to things like this. The base mathematics are the same in packages as are the over all principals but the way you go about things is completely different.

This might be of some help http://paulneale.com/tutorials/MaxMaya/maxMaya.htm. Also my DVD series will give you want you want.

In Max you are using controllers. Controllers must control the track that they are on. The expressions that you used in Maya were name dependent and as you know could become a complete mess if you start changing names and hierarchies. In Max you have several options. Wires are a system that are similar to stright up connections in Maya as there can be one input and one out. Difference is Max allows for an expression as well when the connection is made. Script controllers are more like Maya's expression controllershow ever they are name independent and work directly on referenced nodes. They will take any number of inputs but like any controller should only control the one out put and that is the track that it is controlling. There is also the expression controller but that is old and not used that much any more but should not be egnored.

My suggestion would be to wire each morph target to the on screen control and use a simple if expressions to determine what to do with the value. Some thing like...

if xPosition>=0 then xPosition else 0

This assumes that you have a morph target wired to the X Position track of the control and you want to only drive it if the value is greater then zero. Please do not assume that Max script is anything like MEL, like any two languages, the same, but differernt. Don't assume Max works anything like Maya either, if it did, well it would be Maya and my days wouldn't go as smooth as they do. ;)

doude
05-12-2008, 01:05 PM
Hello,

Thank you for your reply. I have checked the page you sent, it's useful for a beginner like me on max.

Regarding the picture I posted at first, I tried an expression such as :

if x_position > 0 then abs(x_position) * (CtrCircle.y_position) else 0
This would mean that x_position depends of the Y_position value of the CTR.
(at least in my head:)...)

but unfortunately I get an error message.

I cannot figure out yet how to Combine x and y in only one expression.
Is there a way to call the Y_position by writing the expression on the X_position channel?
Or should i forget this possibility because Max doesn't allow to do it? :surprised
In this case, how could i get the result described on my first post with max?
thanks for the help.

IkerCLoN
05-12-2008, 05:01 PM
I would go for two differents expressions: one for X and one for Y, even if you use WireParameters or Expression/Script controller :)

S-S
05-12-2008, 06:46 PM
Hi doude!

I don't know if you really have to stick with wires, and maybe you already figured it out, but here's my suggestion.

Go for script controllers, that way it's very easy to see both x and y axis of your control joystick in same location (at least for me). I favor script controllers for some reason. At least it's very easy to copy'n'paste them in trackview.


Here's a short how to:

I usually make joysticks so that it goes from -1 to 1 in generic units, and and align it so that up is y and not z. (max up direction).

Go to track view. Browse morpher channel, add float script for up right shape. then In script controller add two variables, controlX and controlY then browse joystick's X axis to "controlX" and then joystick's Y axis to "controlY"

Write a script in field:

a = case of
(
(controlX >= 0.0): controlY
(controlX < 0.0): (1 + controlX) * controlY
)
a *= 100.0

if a < 0.0 then 0.0 else a -- Since there is no clamp, i do it like this...


So this gives you the top right corner control in one package. "Top middle" full, "top right" full and from "top middle" to "top left" corner a ramp from 1.0 to 0.0


Max doesn't have clamp like Maya, but you can just put your calculation "inside" variable, like i put it in "a", and finally the last value of a is output value.

If i remember correctly, Paul also has "Clamp Range" script, which could also be handy.

Hope this helps.



BTW
i have automated this myself, so that i don't have to do it over and over again, here's a old video of my script:
Morph scripter 2 (http://www.cgmill.com/main/?page_id=165&g2_itemId=3277)

PEN
05-12-2008, 09:21 PM
script controller might not help as it still only out puts one value to the controller. If you want to control several targets you will need several script controllers or several wires. The reason that you are getting errors in the wire is they only take one imput value and put put one value.

S-S
05-12-2008, 09:36 PM
Paul:

"Combine x and y in only one expression"

I think doude was after the fact that he wants a single expression which takes x-axis as "left - both - right" type of control, while y-axis of same joystick works as "multiplier" or "volume" of smile. That's how i understood it, since it was the first problem i run into with "Osipa style" rig, if i remember correctly.

This way, one has x and y variables in same location, i think it's bit easier to manage compared to wires - but this is of course my personal taste! But they definitely just control one shape.
Examle is for "upper right" morph shape only, so one should of course do similar scripts for "upper left" and bottom half shapes too, which means copy-pasting of script to other channels, and then modify script a bit.

I'm sorry if i was a bit unclear!

PEN
05-13-2008, 03:06 AM
Agreed if this is the case. Maybe I should read it all again. Script controllers are the way to go then.

doude
05-13-2008, 03:45 AM
Hey S-S,

Thank you so much for your wonderful explanation. it's very kind of you.:wip:
I simply couldn't get better one.

You understood perfectly what was the problem. I realize now that i have to think differently when it comes to combine X and Y. I still don't know exactly what is "script controller" but I will definitly try to go this way since it seems to be the most logical way to achieve this.

Once again thank you very much for your precious help guys.

PEN
05-13-2008, 11:59 AM
A script controller is similar to expression editor in Maya. Difference is script controllers use a system of creating variables and assigning them to tracks and nodes where expression editor in Maya references every thing by name. Also script controllers are assigned directly to the tracks of animation that they control where in Maya expression editor contains all the expressions for the scene.

CGTalk Moderation
05-13-2008, 11:59 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.