PDA

View Full Version : Linking A Custom Attribute to Another Custom Attribute


Nefertari
11-27-2005, 11:06 PM
Hi guys, long time reader first time poster. I have a pair of eyes with a modeled pupil, iris etc. Now I wanted to control the size of the pupil with a linked xform parented to a point helper, but this didn't work out. I then decided to use an xform modifier on the faces that built up the pupil and control the gizmo's scale with a wired parameter...needless to say I spent several hours trying to figure out a way of manipulating the gizmo's scale....it didn't work so after searching through the modifiers I thought it would be easier to use the Squeeze modifier and control the squeeze amount with a parameter wired to the point helpers custom attribute.

I've done this for both eyes pupils (left eye/squeeze amount ->Ctrl_Both_Eyes/Left_Pupil and right eye/squeeze amount ->Ctrl_Both_Eyes/Right_Pupil) But I want to be able to control both pupils at the same time aswell, so I added another custom attribute to the Ctrl_Both_Eyes helper but can't figure out how to connect both Left_Pupil and Right_Pupil to Both_Pupils without voiding their previous wirings.

For instance after I wired each eyes pupils, I wired both_Pupils to Left_Pupil and then repeated the process and wired it to Right_Pupil. Now when the slider for both_Pupils is moved...then both pupils contract and expand...but if Left_Pupils or Right_Pupils sliders are manipulated nothing happens as they have been overwritten by the previous wirings....hope that makes sense


So bottom line is. How do you wire one custom attribute to control another but still have it's dependancy. like a parent-child setup with two bones. you can move the child seperatly but if you move the parent then both move. I'd like one controller to be able to be controlled by the other but still be independant.

Nefertari
12-10-2005, 03:58 AM
Just posting because I've left this thread for a while and no-one has replied. Does anyone have a clue how to solve my problem? It's cropped up again as I have created a a distal, middle, primal and curl attribute on a dummy which controls a finger. now the distal, primary and middle fingers work fine, but I want to link the curl attribute to control the rotations of the distal, middle, and primary joints altogether without using the parameter collector.

It may seem trivial...but I like to have all my controls on the dummy helper as it just save time in the short and long run and is neater. Does anyone know how to solve this...or at least write some sort of script where I can control an attribute with another attribute on the same helper?

Kenzor
12-13-2005, 10:02 PM
Just a quick post before I leave..

Generally I have found that a little bit of max scripting goes a long way and is simpler to use than the wire parameters dialog. Have a look at the Max reference and Max script reference on 'script controllers'. (Although I have to say that this might be the one area where the max help isn't that good.)

The script controller is a fantastically powerful tool once you get to grips with it so I recommend learning it.

If you want I try and post an example tomorrow morning (I’m in the UK)

good luck

Kenzor
12-15-2005, 09:40 PM
How's it going Nefertari? Have you figured out a solution?

magicm
12-15-2005, 10:47 PM
Unfortunately, this can't be done through the custom attributes editor.

Here's an example which creates a new custom attribute using maxscript. It has two spinners "Left" and "Right" and a checkbox to link the spinners. The CA is applied to the selected object (see bottom of script).

Cheers,
Martijn

eek
12-16-2005, 05:59 AM
cant you for each ca eg left pupil/right pupil make it a bezier float then add a float list controller on it. Wire it in the first slot then in the available add say a bezier float set that to active.

Its like constraining a point to another point with a pos constraint, but in the available slot add a bezier float so you can still move it around, as well as its being contstrained. So why cant it be done with a ca slider?

Also the way i do iris changes is by wireing the uv coardinates of the iris material to a slider. So essentially it stretches by creating more black.

eek

Nefertari
02-09-2006, 07:56 PM
Hi, sorry I stopped monitoring this post because no one replied, I just so happened to come across it again and noticed there were some responses.

thanks for them by the by. I did look through the max script tutorials and references...but they are rubbish. Unfortunately for someone like me who isn't used to Max's syntax of programming, there really needs to be more info and examples on each function you know?


I do however think you are right in saying that doing this with a wired parameter custom attribute is not the way to go about it. I've finally realised that WP's are just a really bad way to do anything...I mean for something that reset's itself when the syntax is wrong causing you to update every second to save your hard earned typing is just bad programming.


I still personally haven't found out a way of doing this, but I'd imagine that if someone did it would be a very useful tool for rigging. I asked my tutor at uni and he seemed as dumbfounded as me, he said it would have to be done with some form of script....which I have no problem with, I just wouldn't know where to start.

Kenzor
02-09-2006, 11:53 PM
The eyeballs are animated using two slider manipulators.
one for dilation and one for balance.

To look at the script contoller open the dope sheet, navigate to an eye, then
-modified object-morpher-[1]line02- and right click to get the tracks properties.

the 'DependsOn' tells the script controller what objects in the scene to use.

The value of the final equation is passed to the morph target controller.

eek
02-10-2006, 12:06 AM
So bottom line is. How do you wire one custom attribute to control another but still have it's dependancy. like a parent-child setup with two bones. you can move the child seperatly but if you move the parent then both move. I'd like one controller to be able to be controlled by the other but still be independant.

Id look at list_controllers.

Ken T,

Theres some oddness going on with the balance slider, when going from left to right. The eyes dilate weirdly.

You have one slider driving the size of the dillation right? This dillation being a morph target. And im guessing you have each eye treat this eye as a morph, like the value of a morph driving a morph?

So:

eye 1 is a morpher with a target: dillated



eye 2,3 use eye 1 as a morph with update always on. Then you just drive these two morphs with a simple slider. controller.weight[1] = slider1 etc etc

eek

Kenzor
02-10-2006, 10:36 AM
Yes the sliders do behave a bit weirdly. It was ment help to get Nefertari started with script controllers......

I just realised that because i use dual montiors you guys might not of been able to find the script controller code (because it would of appeared off screen). I'll upload a new version of the file to fix this...

The script controller for the left eye looks like this:


dependsOn $SliderDilate $sliderbalance

Dilate = $SliderDilate.value
Balance = $sliderbalance.value
(1-Dilate) *100*(1-abs(balance)) + ((1-Balance) * 50)*(abs(balance))


The script controller for the Right eye looks like this:


dependsOn $SliderDilate $sliderbalance

Dilate = $SliderDilate.value
Balance = $sliderbalance.value
(1-Dilate) *100*(1-abs(balance)) + ((1+Balance) * 50)*(abs(balance))



There is no value of a morph driving a morph. Each eye calculates the value of its morph channel directly from the code above. (you could delete the morph target line02 and it would all still work).

You could do all this with list controllers ..... But some rigging problems can only be solved with script controllers so it worth learning them if you have the time....

Having said that I guess i should of spent more time writing a nicer example function.
I 'll see what i can do tonight to make it smoother.

Kenzor
02-10-2006, 03:30 PM
Ok I've updated the script controllers to give a smooth curve, and it should be much nicer to use.Balance now contols the balance of a gamma curve.

The left Eye script looks like..

dependsOn $SliderDilate $sliderbalance

x = 1 - $SliderDilate.value
b = $sliderbalance.value

(b*x*x + (1-b)*x)*100

The Right Eye script is the same except

b = -$sliderbalance.value



Have a go...

eek
02-10-2006, 04:09 PM
Ok I've updated the script controllers to give a smooth curve, and it should be much nicer to use.Balance now contols the balance of a gamma curve.

The left Eye script looks like..

dependsOn $SliderDilate $sliderbalance

x = 1 - $SliderDilate.value
b = $sliderbalance.value

(b*x*x + (1-b)*x)*100

The Right Eye script is the same except

b = -$sliderbalance.value



Have a go...

Interesting, this is a gamma function you say. Hmmm ill have to look into this. Is this similair to exponential ramp: n^2.618?



eek

Kenzor
02-10-2006, 04:31 PM
To be precise it’s a 2nd order approximation of a gamma curve. A friend of mine did the math to derive the approximation so I can’t claim credit for that.

In my code the gamma value is (1+balance)/2.

It’s loses accuracy when compared to a real gamma curve when ‘balance’ is close to +1 or –1. But mostly we want something that ‘feels right’ and runs fast, so that’s usually fine.

I'm not familiar with an exponential ramp: n^2.618. Could you give me an example eek?

PEN
02-10-2006, 04:52 PM
Hey Ken it looks much like a bezier curve what you have there. Interesting way of dealing with it. Thanks for sharing.

CGTalk Moderation
02-10-2006, 04:52 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.