Keep up-to-date with Free tutorials!!

 

Sign up to our twice-monthly newsletter today for the latest tutorials, interviews and product information.

Sign me up to receive third-party emails from 3dtotal's partners, too!

- Latest news
- Exclusive Shop Offers
- Preview early content
- Plus much more

 

Not Ready to take that step? OK, Why not just Subscribe to the RSS Feed

 
submit tutorial
1 | 2 | 3 | 4 | 5 | 6
Creating Orbiting Planets with Maya's Particle Instancer

By Johnny Z
| Your Rating:
rating star fullrating star fullrating star fullrating star fullrating star full
(1 Votes)
| 42974 Views
| 0 Comments
| Comments 0
Date Added: 30th December 2010
Software used:
Maya

The first variable we will define is for the position of the Sun. This is easy to define since we do not need the Sun to move or rotate at all. To define a variable in an expression we need to do 3 things:

  1. Tell Maya what type of data it is
  2. Name the variable
  3. Assign a value to the variable.

An example of a variable would be:

data type $variable_name = value;
 
Click Here To Download Code

So a variable for the position of the sun could look like:

vector $sun_position = <<0,0,0>>;
 
Click Here To Download Code

Type this into your expression editor and click create (Fig.17).

1369_tid_figure17.jpg
Fig. 17

Vectors are surrounded by "<<  >>" to tell Maya it is a vector. Each value is separated by a comma.

The zero's in our variable represent position of our particle system or <>.

The Sun is the only celestial body in this scene that will not be moving so we need a way to tell Maya that only the particle associated with the Sun will receive the $sun_position variable. To do that we will use an "if" statement.

"If" statements test your scene based on criteria defined by the user. They run commands if the test is passed or do nothing if the test fails. The syntax of an "if" statement looks like this.

 
if(criteria)
           {
             command;
             command;
           }
 

Click Here To Download Code

We know that the Sun is associated with the particle that has the ID of 0. So we can type:

 
if (particleShape1.id == 0)
           {
             particleShape1.position = $sun_position;
           }
 

Click Here To Download Code

Note the double "=" sign after  particleShape1.id!

This tells Maya that if particle1 has a particle with the id of 0, then Maya should apply the variable $sun_position to that particle and move it accordingly. If you hit play nothing will have changed because we assigned a variable that tells the Sun not to move.

So, how do we get Jupiter to move in a circle? Or more accurately, an ellipse? If you go back to your expression editor and change the $sun_position variable to <<5,5,5>> click edit and hit play you'll notice the sun moves 5 units in each X,Y and Z and then stops. We want Jupiter to move continually. Maya has a few terms that will do just that. One of them is "time." Time is a value that continually changes so it would make sense that we use it to move an object continually. Change the $sun_position variable to <> click edit and hit play. Now the sun moves continually but it's still not a circle or ellipse. Set the $sun_position variable back to <<0,0,0>>  for now.

So we know how to get a particle to move continuously, but we want it to go in a circle first. We'll get to an ellipse later.

We are going to use simple trigonometry to get these planets to move in an orbiting way. You don't have to know much about math because Maya has built in functions that will do everything for you. You just need to know where and when to use the functions. The two functions we are going to use are sine and cosine. Long story short, sine will give us a wave one way, cosine will give us a wave the other way (Fig.18) and when we combine them into the X and Z values of our variable we get a circle. From there it's a simple step to get an ellipse.

1369_tid_figure18.jpg
Fig. 18


Let's write the variable for Jupiter under the Sun variable:

vector $jupiter_position = <>;
 
Click Here To Download Code

Under the sun's "if" statement, type:

 
if (particleShape1.id == 1)
          {
             particleShape1.position = $jupiter_position;
           }
 

Click Here To Download Code

If you switch to wireframe display (4 on the keyboard) you will see Jupiter moving in a circle, but it's still inside of the sun. We will have to scale our $jupiter_position variable with a little math to get the circle to be bigger.

Change the Jupiter variable to read:

vector $jupiter_position = <<100*(sin(time)),0,100*(cos(time))>>;
 
Click Here To Download Code

Fig.19 illustrates how the expression works.

1369_tid_figure19.jpg
Fig. 19

This will move the center of Jupiter 100 units away from the origin, giving us a nice circular orbit. To get an ellipse just change your variable to read something like:

vector $jupiter_position = <<100*(sin(time)),0,150*(cos(time))>>;
 
Click Here To Download Code





< previous page next page >
 
1 | 2 | 3 | 4 | 5 | 6
Related Tutorials

Tutorial

Gallery Image.



Keywords: painting, planets, photoshop,

Go to tutorial
rating star nonerating star nonerating star nonerating star nonerating star none (0)
Comments 0 Views 69977

Tutorial

Gallery Image.



Keywords: 3ds Max, Interface, Tutorial, Workflow, Particle Flow

Go to galleries 1
rating star fullrating star fullrating star fullrating star fullrating star full
Comments 0 Views 6008

Tutorial

Gallery Image.



Keywords: particle, system, foliage, max,

Go to galleries 1
rating star nonerating star nonerating star nonerating star nonerating star none
Comments 0 Views 11369

Tutorial

Gallery Image.



Keywords: advanced, particles, glu3d, teapot, animation,

Go to galleries 1
rating star nonerating star nonerating star nonerating star nonerating star none
Comments 0 Views 22240
Readers Comments (Newest on Top)
no comments!
No comments yet. Be the first to comment!
Add Your Comment