Introduction to Maya - Modeling Fundamentals Vol 2
This course will look in the fundamentals of modeling in Maya with an emphasis on creating good topology. It's aimed at people that have some modeling experience in Maya but are having trouble with complex objects.
# 1 15-02-2010 , 10:51 AM
Registered User
Join Date: Feb 2010
Posts: 4

How are expressions processed?

Hi

I'm currently in a lesson working with basic expressions. The task was to create an expression that would make an oil lamp swing on it's hinge. My original code:

PHP Code:
//values are keyed to Impact=50, Dropoff=200, Amp=30
$angleZ 0;

if (
frame Handle2.Impact){
    
$angleZ = (Handle2.ImpactDropoff frame);
    
$angleZ $angleZ * (Handle2.Amplitude 2);
}

Handle2.rotateZ sin(frame 5) * $angleZ
I put the two $angleZ parts on different lines for readability. It's simply my programming style, however it yields a very strange result: At about frame 66/67 the lamp changes direction for 1 frame. If however, I use the following code:

PHP Code:
$angleZ 0;

if (
frame Handle2.Impact){
    
$angleZ = (Handle2.ImpactDropoff frame) * (Handle2.Amplitude 2);
}

Handle2.rotateZ sin(frame 5) * $angleZ
There are no problems.

I can't see at all how the two expressions could possibly run differently, especially as the variable is modified before the angle in both cases. Can someone please explain what is happening?

# 2 15-02-2010 , 02:16 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
Try switching
Code:
$angleZ = $angleZ * (Handle2.Amplitude / 2);
to
Code:
$angleZ *= (Handle2.Amplitude / 2);


Imagination is more important than knowledge.
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