PDA

View Full Version : Breathing lung using expressions.... HELP!!!


nemirc
04-05-2003, 02:39 AM
Hello everybody.

I created a lung and I also made a "breathing control" to control the breathing rate (using a range from 1 to 4).
The thing is that I made an expression that would control the expansion of the lungs (using blendshapes) by reading the value in the controller attribute.
The expression is as follows:

if (breathing_control.breath_rate = 1)
leftlung_morph.weight[0] = sind(time*90)*0.25;
else if (breathing_control.breath_rate = 2)
leftlung_morph.weight[0] = sind(time*90)*0.5;
else if (breathing_control.breath_rate = 3)
leftlung_morph.weight[0] = sind(time*90)*0.75;
else if (breathing_control.breath_rate = 4)
leftlung_morph.weight[0] = sind(time*90)*1;
else
leftlung_morph.weight[0] = 0;

The problem is that the blendshape attribute is orange (as expected when an attrib is connected to other one) but the locator's attribute is orange as well and I am unable to change it (and that renders my controller useless).
What is the problem with the expression?
The expression was created (for some reason) in both the lungshape and locatorshape nodes. I don't know if that would be the problem...

Thanks

Stahlberg
04-05-2003, 03:50 AM
Sorry I don't know the answer. But it might be easier for you, and give you more control, if you simply animated the motion of the breathing by keyframes. Then, if you don't want to think about it anymore just set it cycling - too slow, scale down the cycle, too fast scale it up, just takes a few seconds to adjust, it's more intuitive too since you can see the cycle graph and exactly how long it takes.

But mainly it adds much more control, because breathing isn't always a simple sequence of sine curves, and you may want to synch it with something.

dmcgrath
04-05-2003, 05:18 AM
I would say just to try it again. You should only have to make the expression in one place like at the lungshape. Have you tried selecting the locator node that is currently keyed and simply break the connection?
That might work, but I am not sure.

Also regarding syntax, did you remember all of your little curly brackets? Sometimes things will get messed up without these.
Your example code you gave us didn't show them, so I am just checking. :)

if (breathing_control.breath_rate = 1)
{
leftlung_morph.weight[0] = sind(time*90)*0.25;
}
else if (breathing_control.breath_rate = 2)
{
leftlung_morph.weight[0] = sind(time*90)*0.5;
}
else if (breathing_control.breath_rate = 3)
{
leftlung_morph.weight[0] = sind(time*90)*0.75;
}
else if (breathing_control.breath_rate = 4)
{
leftlung_morph.weight[0] = sind(time*90)*1;
}
else
{
leftlung_morph.weight[0] = 0;
}

nemirc
04-05-2003, 07:11 PM
Originally posted by dmcgrath
message deleted by me :beer:

I'll try breaking the connection.
Also, the {} aren't necesary but It may make the expression look a little bit clearer.

nemirc
04-05-2003, 08:00 PM
Still not working.
I deleted the expression on the locator and Maya also deleted the lung expression :thumbsdow

Anyone out there has tried to do this? :annoyed:

I think I'll take Stahlberg's idea into consideration

dmcgrath
04-05-2003, 10:56 PM
Stahlberg is on to something, about making it easier for yourself.
You could actually turn the animation into a clip as well. So then the clip has a cycle attribute and a scale attr, start/end frames, etc. It could be another consideration.

nemirc
04-06-2003, 03:09 AM
Hello

I fixed the expression. Since I was using BlendShapes I wanted to have a sort-of automatic way of setting the rate.
What I did:

I added two attributes to a locator (which would be used as a controller), using a range value from 0 to 4.
Then I selected the left lung and wrote the following expression:


//Breathing Rate Control. Controlled by the locator on the back
//Expression by Sergio Rosa. 2003

float $breathing = breathing_control.breath_rate;
float $mult = breathing_control.breath_mult;
leftlung_morph.weight[0] = sind($mult*time*90)*($breathing/4);

//End of Breathing Rate Control


By setting the value of "breath_rate" and "breath_mult" you are able to control the rithm of the characters breathing.
Very nice result indeed :applause: :buttrock:

CGTalk Moderation
01-14-2006, 07:00 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.