Maya Training

Introduction to Hard Surface Modeling

Maya Training

Interiors and Furniture Vol 1 & 2 - Modeling & Cloth

Maya Training

Shading, Lighting and Rendering the Bedroom in MR

Maya Training

Robot volume one - Modeling with animation in mind

Maya Training

Spach-Alspaugh House the complete courseware

Maya Training

Burt The Cartoon Dinosaur Vol 01 - Modeling

New Maya Training

Robot Volume 02 - Hybrid Rigging
You are here > Home > SimplyMaya Community Forums
Loading

Welcome to Simply Maya

Please Sign in or Sign up for an account

Member Login

Lost your password?

Not a member yet? Sign Up!

Old 04-10-2003, 10:17 PM   #1
nspiratn
Registered User
 
nspiratn's Avatar
 
Join Date: Dec 2002
Location: CA
Posts: 211
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
nspiratn is offline   Reply With Quote
Old 04-10-2003, 10:47 PM   #2
kbrown
Moderator
 
kbrown's Avatar
 
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Thanks: 0
Thanked 8 Times in 8 Posts
Default

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!
kbrown is offline   Reply With Quote
Old 04-10-2003, 10:58 PM   #3
kbrown
Moderator
 
kbrown's Avatar
 
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Thanks: 0
Thanked 8 Times in 8 Posts
Default

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, 43 views)
__________________
Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
kbrown is offline   Reply With Quote
Old 04-10-2003, 10:58 PM   #4
mtmckinley
The Maya Mountain
 
mtmckinley's Avatar
 
Join Date: Aug 2002
Location: Seattle, WA
Posts: 8,245
Thanks: 1
Thanked 25 Times in 25 Posts
Default

I agree.
__________________
-Mike
www.mtmckinley.net
The Maya Toolbelt
mtmckinley is offline   Reply With Quote
Old 14-10-2003, 12:53 AM   #5
mark_wilkins
Registered User
 
mark_wilkins's Avatar
 
Join Date: Jan 2003
Posts: 161
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
mark_wilkins is offline   Reply With Quote

A little bit about who we are
Links you might find useful
Catch up with SimplyMaya
SimplyMaya specialises in Maya tutorials. We offer over 1,000 individual Maya training videos, ranging from basic Maya tutorials through to intermediate Maya tutorials. Our tutorials are created by instructors with industry experience and are designed to get you up and running in Maya quickly without making it seem like hard work.

Copyright © 1999-2015 SimplyMaya - vBulletin® Copyright © 2000-2015, Jelsoft Enterprises Ltd.