### Keep up-to-date with Free tutorials!!

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

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

By Johnny Z
| 58103 Views
| 0
Software used:

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;

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

vector \$sun_position = <<0,0,0>>;

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

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;
}

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;
}

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.

Fig. 18

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

vector \$jupiter_position = <>;

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

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

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))>>;

Fig.19 illustrates how the expression works.

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))>>;

< previous page continued on next page >

1 | 2 | 3 | 4 | 5 | 6
Related Tutorials

Tutorial

FX particles and dynamics in 3ds Max

Keywords: 3ds max, water, animation, particles

(3)
0 22230

Tutorial

Creating and animating bubbles

Keywords: Bubbles, 3ds Max, Particle Flow, Frost

4 21034

Tutorial

Creating a Smoke-Based Explosion in Fume FX

Keywords: explosion, smoke, particle, technique,

2 159285

Tutorial