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 04-10-2003 , 09:17 PM
nspiratn's Avatar
Registered User
Join Date: Dec 2002
Location: CA
Posts: 211

make the moon revolve around the earth

Hi,

I'm trying to write a basic script to make
1)the earth revolve around the sun

2)the moon revolve around the earth

At this point, I have both the earth and the moon revolving around the sun.

This is the script -
---------------------

sphere;
select -r nurbsSphere1 ;
addAttr -ln distance -at double -min 1 -max 10 -dv 8 |nurbsSphere1;
setAttr -e -keyable true |nurbsSphere1.distance;
expression -n "xexp" -s "nurbsSphere1.tx = nurbsSphere1.distance * sin(time)";
expression -n "yexp" -s "nurbsSphere1.ty = nurbsSphere1.distance * cos(time)";

sphere -r 0.25 ;
select -r nurbsSphere2 ;
addAttr -ln distance -at double -min 1 -max 10 -dv 10 |nurbsSphere2;
setAttr -e -keyable true |nurbsSphere2.distance;
expression -n "xexp" -s "nurbsSphere2.tx = nurbsSphere2.distance * sin(time)";
expression -n "yexp" -s "nurbsSphere2.ty = nurbsSphere2.distance * cos(time)";

sphere -r 3;
playbackOptions -min 1 -max 300 ;
----------------------------------

The problem I have is :

The moon's x and y co-ordinates have to change to keep up with the earth's orbit around the sun.
BUT, the moon's x, y co-ordinates ALSO have to change locally with respect the earth itself so it can remain in orbit around the earth.

So, how do I animate the moon so that it can do both??
I hope you're getting my drift here.

btw, I have a gut feeling that there is a very simple solution to this but I am just blanking out.


thanks.

Attached Thumbnails

~nspiratn
# 2 04-10-2003 , 09:47 PM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
You need to think of this how would you do it manually. Perhaps by setting the earth's pivot in the middle of the sun and the moon's pivot in the middle of the earth. Then parent the moon to the earth and create the necessary expressions to rotate everything.


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
# 3 04-10-2003 , 09:58 PM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
here's a quick (maya 4.5) scene file for you to investigate:

Attached Files
File Type: zip earrh_moon_sun.zip (6.4 KB, 290 views)

Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
# 4 04-10-2003 , 09:58 PM
mtmckinley's Avatar
The Maya Mountain
Join Date: Aug 2002
Location: Seattle, WA
Posts: 8,245
I agree.

# 5 13-10-2003 , 11:53 PM
mark_wilkins's Avatar
Registered User
Join Date: Jan 2003
Posts: 161
Why not just parent the objects to each other and rotate the transform? Making additional transforms by grouping can allow you to decouple an object's rotation from its orbital motion (although in real life, rotation to orbit duration ratios of 1:1, 2:1, and 3:1 are common, and 1:1 is what you get with straight parenting... the others can be done with a simple expression.)

-- Mark


Mark R. Wilkins
author of MEL Scripting for Maya Animators
www.melscripting.com
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