My project was to create a hierarchically modeled figure that walks in a dimly lit forest scene. I worked on camera angle and lighting to invoke a eerie theme in my scene. The character is controlled by the user and the camera follows behind the character in an over-the-shoulder style a-la Resident Evil.
The model is created from some simple geometric meshes loaded from six different object files. Each piece is hierarchically modeled off of the body.
I wrote the code to import the model from a (stripped-down)
.obj file that I generated using the open-source Blender modeling program. I had to
manually remove many of the "extra" parts of the object files
because my importer only supports a very small subset of the
.obj file format.
I wrote the
.obj importer myself based on the
.m importer that we used in the labs. It ended up
working just as well as long as I deleted comments and unused
features from the object file and triangulated all of the edges.
My scene was lit with a firelight that flickers as time goes by. The dim firelight along with the flicker were added to enhance the mood of the scene.
The main difficulty with this was making sure that the flicker looked realistic. I ended up going with a couple of factors in the light, a base level of light, a sine wave and some random jitter. This created a light that looks much like a weak firelight.
In order to incourage exploration, I allowed the user to "pick up" the light or "drop" it by pressing the space bar. This means that even with a dark scene like this one, the user can explore the whole thing.
In total, there are ten different rotating joints that move when the character starts to run. This includes the shoulders, elbows, hips, knees, and ankles on each side. The movement is modeled using dampened sine waves, so the character appears to run. The right and left sides of the body are offset using a π offset in the angle drives the sine wave.
The hip rotates at an angle of
while the knee is rotated at
-abs(sin(TIME+offset))+M_PI. The foot has to be
rotated in the oposite direction to keep it relatively flat with
respect to the ground so that when the foot strikes it looks
The arms were simpler, the shoulder rotates at
-abs(sin(TIME-offset)) and the elbow rotates at
-abs(sin(TIME+offset)). This gives the arms a natural
look. The other thing that I had to do with the arms was increase
their range of motion in the negative direction on the shoulder
because rotating only forward gave an unrealistic look.
The camera is modeled after games like Resident Evil where the character obscures much of the scene and the camera doesn't allow you to check behind you easily. This was done to add a creepy feel to the experience.
I achieved this effect by having the camera always look at the head of the model from a few units away. I left the code in from the first-person click-and-drag assignment because the idea is that even though the angle is over-the-shoulder to show the body, the intent is to get the player into the model's head.