This project was designed to include hierarchical modeling and also animation. The hope was to have something that looked fairly impressive, and make its motions customizable with minimal effort from the user.
Design of the project began with a simple stick figure with nine joints. By selecting various actions, the stick figure and it's joints would behave accordingly. It would interpolate between where it began, and where it will need to be. Each move was seperated into multiple checkpoints, and each move would be able to move seemlessly from any other existing move.
The end goal of the project was to have an interactive, complex hierarchical model that would behave as the user wanted it to. The user would be able to link together a list of the things that they wanted the model to do in succession. After forming the list, the user would hit play, and then the figure would do the actions requested, one after another.
Another goal was to make it as easy as possible to add additional moves. The idea was that it would be nice to be able to say, "this is how long the move will take, this is where I want him at points A,B..." and then just being able to do that.
The end result was a stick figure that was able to do five different animations, all of which blended seemlessly together. I was able to also maintain the primary design goal, which was to make additions very easy.
This wasn't as flashy as I wanted. Most of the time was spent trying to get it functional. It ended up being very time consuming coming up with the angles that I wanted for all of the motions. As I got more frustrated with it, I decided to add in some functionality to make it possible to set the stick figure in a desired position, and then print out all of the angles. This ended up being helpful, but it also made my standards a lot higher, and it made me focus more on making the positions look better and better. Like trying to make it more fluid and natural.
It took pretty much up until the night before in order to get it functioning as intended. At this point, it was just a stick figure dancing in purgatory basically. Due to some issues however, I was not able to get the flashy backdrop working without futsing over the program, and so I scrapped it for a very basic rectangle to be considered as a platform for the stick figure.
All problems aside though, it was pretty successful. I had a stick figure that could throw his own arm and then make a dejected body expression. He could do a full flip kick, and jump a little too. I wish I had more time to make more moves and to make the stick figure something a little more impressive.
The program basically consists of three primary hurdles. The first is making sure that the program would be modular, the second is to make a way to have the stick figure perform actions that took a set amount of time, and the third was to make a simple menu that made selecting moves easy.
To make the program modular, I had to make it so the boxes which had each menu option, were placed with an equation. This is an example model of one of the boxes.
The button selected would bounce left and right. Pressing 'return' would make the figure proceed with doing the move. The arrows would browse through the decisions. Basically, placing the boxes was put into a for loop, and the y offset of each box was incremented every box. After that, the entire stack of boxes was translated either up or down, to make the selected option always in the same spot. After that, all that was left was just making it so if the index in the for loop was equal to the index of the selected box, make it bounce.
By making the boxes placed with an equation, I could just very easily add another index to the array and title it whatever I wanted the name of the box to be. It would print that title on the new box, and with just a few simple tweaks it was very easy to make as many boxes as I wanted. In addition, I added another array of ints to be hashed into, which contained the number of frames each animation would be.
To restrict animation to be only a certain number of frames, I used the
glutTimerFunc instead of the passive one. I had an int called 'animated' and
another called 'frame'. Animated was set as the index of the animation, and
frame would begin at 0 and increment every time the timerfunc was called. Inside
the glutTimerFunc it would call a function based on whatever 'animated' was
equal to. Inside that function, based on the frame it was, it would interpolate
between the current position and the next checkpoint. This made it pretty
easy to script moves, because you could just set checkpoints, then set the frames
you want it to apply to, and it would just interpolate from there.