4.
Methods
There
are two different methods I could have used to complete this brief I set myself.
The first is geometry. Using Mel to control the actual objects
by writing a script. The other is using particles. If I used particles
a lot of things would already be set up for my convenience.
I
had to make the choice. I spent time on both of the different methods and
realized that they both had their own positive and negative sides.
Why
particles? I considered particles because they have some very useful built
in functions that I could have inserted straight into my scripts to do my
hard work. There are loads of different expressions that are particle specific.
I
started off with trying to learn about particles because I too didn’t have
much knowledge of the particle side of 3d graphics.
I
decided to check the Maya help files and learn as much as I could. I found
out about instancing geometry so that the dynamic effects of the particles
could be instanced to geometry. This allowed for a crowd control of particles
to be utilized to the full. I managed to build in quite a large amount of
complexity into the particle script. I found a collision script on the Internet
that allowed full collision detection in 3D, however
the script had problems in 2D. This affected my requirements because I needed
to have my troop stuck to the ground so my crowd didn’t have to be so dynamic.
I
found when executing the script that even though the goal of the crowd was
set almost directly in front of them it made the troop start to fly! This
was obviously no good unless of course the troop grew wings! So the fact that
the collision script fell down in 2D made it unsuitable.
Although
the geometry was more awkward, it did have a lot of flexibility for what I
wanted to do, bearing in mind the fact that I wanted a simple crowd system
that could walk past the camera. Because my brief was in fact now a lot less
complicated it enabled me to use the simpler but far more robust method of
implementing my brief.
I started with
uprooting the script Adam Vanner showed us last year Behaviour.mel (Adam Vanner
2001). When I first looked at the script I could I say quite confidently that
I had almost no idea what was going on, so I needed to understand the script
first before I could start putting in the changes that I wanted. Once again
I spent some time looking at the Maya help files. After a while I found that
I was in fact starting to understand what I was reading!
The way this script
works is:
- First it takes in the all of the selected
objects and puts them into an array.
- Then a for loop is used to loop through
all the elements in the array
- A function call is made in each iteration
of the loop to a global function This function
executes an expression that randomly changes the translate and rotation
x y z values. The global function contains the following variables:
- Turnspeed
- Speed
- Angle
- A wait variable.
- All the variables are given a starting
value which in turn changes randomly and then is multiplied into the attribute
of the object’s x y and z values via an expression.
This is the part
of the project that interested me the most. I found that from researching
this project I learnt a great deal about expressions. I now use expressions
quite confidently whereas before I didn’t touch the programming side of Mel.
I find myself thinking “I’m sure there’s a way I cam simplify this with a
script or an expression”.
So this second
approach seemed like the best way to attack my brief.