Introduction to Maya - Modeling Fundamentals Vol 1
This course will look at the fundamentals of modeling in Maya with an emphasis on creating good topology. We'll look at what makes a good model in Maya and why objects are modeled in the way they are.
# 1 08-10-2002 , 09:50 PM
Darkware's Avatar
Subscriber
Join Date: Oct 2002
Location: USA
Posts: 1,172

Expression Editor Q about rotation increase

1. create cylinder, name it "Coin"
2. scale so it's like a coin
3. Choose Window>Animation Editors>Expression Editor

Now, in this window, we can do all kinds of things to "Coin." I had planned on making it spin faster and faster as time went on, but I can't seem to get it right.

I thought that you could write something like the following, but it won't accept it. (this is roughly what the values would be)

if (time = 1) Coin.rotateY = time * 10;
if (time = 2) Coin.rotateY = time * 100;

and so on. I can get it to spin continuously with this expression -
Coin.rotateY = time * 100;
I just need it to increase over time.

# 2 08-10-2002 , 10:15 PM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Try this:

Coin.rotateY = time * 100 * time;


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
# 3 08-10-2002 , 10:53 PM
Darkware's Avatar
Subscriber
Join Date: Oct 2002
Location: USA
Posts: 1,172
It works. I like Coin.rotateY = time * 50 * time; better, though. It has the right speed pick-up for what I'm doing. I'm going to sustain it's speed with this script: if (time > 20) Coin.rotateY = time * 1150; Otherwise, after 500 frames or so, it slows back down and begins to rotate the other way.

Does anyone know where to find some sample expressions? I'd like to look at some to get the feel for it since I'm just starting out. I want to figure out how to make things do something, adjust the speed for a given amount of time, and then slow it down. Stuff like that. I figure that if I can see a few simple samples here and there, I can grasp it.

*edit* one more thing, why does Coin.rotateY = time * 50 * time; work? I don't see the logic in the equation.


Last edited by Darkware; 08-10-2002 at 10:55 PM.
# 4 09-10-2002 , 02:09 AM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Well, the value of the time variable increases constantly over time (boy, didn't that sound stupid user added image) So if you write an expression like this:

Coin.rotateY = time;

The coin would be rotated 0 degrees at 0 seconds and 1 degree at 1s and so on...

But if you write it like this:

Coin.rotateY = time * 50;

The coin would be still rotated 0 degrees at 0 secs but 50 degrees at 2 secs, 100 deg @ 3s, 150 deg @ 4s...

And the final expression Coin.rotateY = time * 50 * time; would do this:

time = 0s -> 0 * 50 * 0 -> 0 degrees.
time = 1s -> 1 * 50 * 1 -> 50 degrees.
time = 2s -> 2 * 50 * 2 -> 200 degrees.
time = 3s -> 3 * 50 * 3 -> 450 degrees.

See, the speed increases over time.


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
# 5 09-10-2002 , 02:09 AM
adldesigner's Avatar
Registered User
Join Date: Sep 2002
Location: CCS, Venezuela
Posts: 3,363
whoa .. nice logic ..

# 6 09-10-2002 , 02:15 AM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
The function could be written like this too:

Coin.rotateY = pow(time, 2) * 50;

From MEL command reference:
"(pow) raises the first argument to the power of the second argument and returns the result."


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
# 7 09-10-2002 , 02:49 AM
Darkware's Avatar
Subscriber
Join Date: Oct 2002
Location: USA
Posts: 1,172
So why, after 500 or so frames, does the coin slow down and begin to spin the other way? Is it because the rotate Y value goes past 360 and increases until the value is so high that the digits exceed the alloted space provided? R-Y could go from 0-360, then back to 0 and so on, or it could go from 0-360-720-etc. See what I mean? Anyway......

# 8 09-10-2002 , 03:50 AM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Yeah...didn't think of that. It might be an overflow issue. I'll get back when I have a solution.

*edit* It also might be because the acceleration increases so much that the coin rotates several rounds between two frames and looks like the direction is reversed...


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!

Last edited by kbrown; 09-10-2002 at 03:53 AM.
# 9 09-10-2002 , 04:35 AM
mtmckinley's Avatar
The Maya Mountain
Join Date: Aug 2002
Location: Seattle, WA
Posts: 8,245
yeah, much like the optical illusion seen in car wheels and such. The mountain bike rider that I'm currently animating produces this effect... I thought I might have accidently reversed the rotation direction, but it's rotating correctly... just has the illusion of reversing direction.

# 10 09-10-2002 , 08:58 PM
Darkware's Avatar
Subscriber
Join Date: Oct 2002
Location: USA
Posts: 1,172
Yep, you're right. It was an illusion. I selected the coin as it spun around and the green outline of the edges flickered. Well, now that I have got it to slowly speed up and the hold it's rotation 20 seconds into the animation, I want to slow it back back down. Here's what I have so far:

Coin.rotateY = time * 50 * time;
if (time > 20) Coin.rotateY = time * 1150;

Now, I have worked with an expression several times, but cannot get it to work to slow it down. The expression would start out like this - if (time > 40) Coin.rotateY = ?

Basically, the coin is spinning around 1150 degrees per second. To make it gradually slow down, we must subtract a given amount from the equation. I thought of "reversing time * 50 * time thinking it would work, but I can't figure out a way. If it is possible to divide in expressions, that might work.
if (time > 40) Coin.rotateY =
time * 1150 (divided by) <an increasing number here>
If the last number is not an increasing number, it will not slow down. (I think) So, the only increasing number I know of to stick in here is "time." If there is a way to insert a number you want and have it increase however many numbers you prefere, that would work, too. *sigh*

# 11 09-10-2002 , 09:02 PM
mtmckinley's Avatar
The Maya Mountain
Join Date: Aug 2002
Location: Seattle, WA
Posts: 8,245
you could try multiplying by a negative number...

# 12 09-10-2002 , 09:47 PM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Hehe...this wasn't as easy as it first sounded but here's one solution:

Code:
if (time == 0)
{
	//initialize
	Coin.rotateY = 0;
}
else if (time < 3)
{
	// accelerate to 3 secs of time
	Coin.rotateY = Coin.rotateY + time * 10;
}
else if (time < 6)
{
	// maintain constant speed while time is less than 6 secs
	Coin.rotateY = Coin.rotateY + 30;
}
else if (time >= 6 && time < 9)
{
	// decelerate back to zero speed between 6 and 9 secs
	Coin.rotateY = Coin.rotateY + 30 - 10 * (time - 6);
}

//this is just to prevent overflows
while (Coin.rotateY > 360)
	Coin.rotateY = Coin.rotateY - 360;
the deceleration equation might seem like a quick hack but it has a purpose if you think it over. I'll leave it to you to figure it out user added image Feel free to ask, if you don't understand...


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!

Last edited by kbrown; 09-10-2002 at 09:59 PM.
# 13 09-10-2002 , 09:50 PM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Btw, a cleaner way for doing this would be to add few attributes to the Coin which would control when to accelerate and decelerate and so on...Anyway, wouldn't simple keyframes do the job? =)


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
# 14 09-10-2002 , 10:18 PM
Darkware's Avatar
Subscriber
Join Date: Oct 2002
Location: USA
Posts: 1,172
Wow. Quite impressive. I'm just trying to learn a little more about expressions, that's all. Keyframing probably would work. How on earth can you think this stuff up so quick? You just pull it out of thin air? Are you human? Oh no, I'm sorry. I didn't mean to insult you. I know you're made of nurbs. :p

# 15 10-10-2002 , 07:01 AM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Hehe, the code is not actually that complex after you've read it with thought user added image


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads