Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   make the moon revolve around the earth (https://simplymaya.com/forum/showthread.php?t=8256)

nspiratn 04-10-2003 09:17 PM

make the moon revolve around the earth
 
1 Attachment(s)
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.

kbrown 04-10-2003 09:47 PM

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.

kbrown 04-10-2003 09:58 PM

1 Attachment(s)
here's a quick (maya 4.5) scene file for you to investigate:

mtmckinley 04-10-2003 09:58 PM

I agree.

mark_wilkins 13-10-2003 11:53 PM

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


All times are GMT. The time now is 07:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018