CSC 471 Final Project - Gambit Animation

by Erik Kitson

 

 

 

 

Modeling Gambit

Hierarchical modelling allows a three dimensional model to be broken up into a tree where parts of the model are organized into branches. When a transformation is applied to one part of the model, all other parts on that branch are affected. For instance, if you are modelling a leg, a rotation on the thigh will also affect the knee, calf, and foot. However, a rotation to the calf will only affect it and the foot.

I used a modeling program called Wings3D to create my model of Gambit. As a reference, I used
this image of Gambit. I used hierarchical modeling to create an animation  of Gambit walking.




Figure 1: Gambit model in Wings3D



Figure 2: Model without trench coat



Figure 3: Model rendered in my program



Figure 4: Model rendered with trench coat

 


Collision Detection

Modeling Gambit’s trench coat would turn out to be the bulk of this entire project. In order to create  realistic motion for the coat, I would have to detect whenever any of Gambit’s limbs collided with the coat, and then animate the correct coat vertices. For the detection, I created bounding cylinders around the thighs and calves and bounding spheres around the knees. I ran out of time to do collision detection for the arms. As an example, consider Gambit’s left thigh. Every time the thigh moves, it must check to see if it has collided with any trench coat vertices.

 

  

Figure 5: Coat vertices before collision

 

  

Figure 6: Coat vertices after collision

 

First, I calculate its Y and Z range to weed out all vertices that it cannot possibly touch. Then I iterate through all of the remaining vertices and calculate if they are within the cylinder’s radius.  If the thigh was not  being rotated, I could choose an X-Z coordinate at the center of the radius and choose a Y coordinate equal to the vertex’s Y coordinate. However, because the thigh is being rotated, I must calculate a different Y, so that the normal at that X-Y-Z will strike the trench coat vertex being examined. I then calculate the distance between these two vertices and see if it is less than the bounding cylinder’s radius.

 

  

Figure 7: Top-down view of collision detection for thigh

 

  

Figure 8: Side view - Y value is the same

 

  

Figure 9: Side view - Use the vertex whose normal hits the coat vertex

 

Cloth Motion

The collision detection for Gambit’s walking animation only moved the vertices that directly collided with  the model’s legs. In order to create a more realistic look for the trench coat, I simulated the motion of cloth. Whenever a vertex is moved due to collision detection, it “pulls” all neighboring vertices in the same direction as it was moved. Each of these vertices in turn pulls its neighbors and so on. As the pull passes from one neighbor to the next, it becomes exponentially weaker until it is small enough to be ignored.  Every vertex of the cloth also has a “home”, which is the X-Y-Z coordinates it was initially placed at.  Whenever a vertex is not at its home, it moves towards that home. The magnitude of this motion decreases as the vertex gets closer to its home, to make it come to a more realistic stop.

 

  

Figure 10: Cloth animation

 

  

Figure 11: Cloth animation - bottom view

 

  

Figure 12: Cloth animation - front view

 

Issues

Due to time constraints, I was not able to get all aspects of this project functioning correctly. The collision detection for Gambit’s calves appears to be off some. This is most likely a result of the complexity of doing collision detection that is relative to the thigh’s rotation/position. Also, some of the cloth vertices have slightly strange behavior. In the front, some vertices shoot out, creating spikes in the coat. This is most likely a result of having being close to several vertices that were displaced due to collision. All of their pulls are probably accumulating on the vertex and causing its motion to be exaggerated. As I stated above, I ran out of time to do collision detection for the arms, so there is only a basic animation in place for the sleeves which allows the arms to pass through them.

 

Installing

I used an open source API for reading in files in 3D Studio format and converting them into usable vertices and faces. This must be installed in order to run the program.

 

1. Download the source code here.

2. Download the API from http://lib3ds.sourceforge.net/ .

3. Extract the lib3ds-1.2.0 directory to your project directory.

4. Open the lib3ds workspace in the msvc directory and build it to build all projects in the folder. Ignore the include file error.

5. In lib3ds-1.2.0/msvc/Build/Debug, there will be a .dll and a .lib. Copy the .dll to the directory the project will run from or to your Windows/system32 directory. Link the .lib in your project (already done in the project files I provide).

6. Build the gambit project from the source code.

7. Make sure the gambit.3ds file (included in gambit.zip) is in the directory the project will run from.

 

User Controls

The program has only a few basic controls. The user can control the viewing camera or turn a few features on/off.

mouse - click and drag to change where the camera is pointing

w -  Move the camera forward

s -  Move the camera back

a -  Move the camera to the left

d -  Move the camera to the right

c -  Hide/Show Gambit’s trench coat

p -  Render the trench coat as polygons/points

q - Exit the program.

Resources

I used very few references when making this project, as most of them were either too complex for my time frame or too simple to be of much use. However, I did receive some inspiration from these, and they may be of further use to others.

Simplistic cylinder-based collision detection:

http://spiritking.tripod.com/cdtut.htm

 

Very interesting (and very complex) paper on cloth motion:

http://graphics.snu.ac.kr/publications/journals/cloth.pdf

 

For all of your X-men trivia needs:

http://www.uncannyxmen.net




About the Project

My desire for this project was to create and animate a model of Gambit, undeniably the most suave of all X-men. The project had three major aspects: hierarchical modeling, collision detection, and cloth motion.