For my final project, I decided to add support for animations to the Engine. I wanted to do this as a first step to learning animation programming. Ever since playing Dark Souls I have been intrigued by animation systems and have been on a quest to learn how they work.
My first step was to extend the Math class and add Lerp functions to it. My second step was to add the Animation class which would handle the animation data and perform animation updates. The animation class holds an array of key frames which are defined by a “KeyFrame” struct which consists of a position and timestamp. I also added support for looping animations, controlling the playback rate and the ability to reverse animations by setting a negative playback rate.
Once the basic framework was in, I was able to render cubes on the screen which move according to preset key frames.
The hardest part was coming up next: understanding splines. Spline interpolation took my quite some time to wrap my head around but when I did understand what it meant to do spline interpolation in real time, I was quite disappointed. Spline interpolation involved a bunch of matrix math and solving equations which is not possible in real time while the game is running. Luckily I found a very helpful article that was able to explain cubic spline interpolation in simple terms but it would work only between four points. I decided that something would be better than nothing and implemented cubic spline interpolation support for four key frames. It worked out pretty well.
Now, the final would not be complete if I didn’t make use of the build system. I created a human readable lua file which would represent the animation data.
I added a new builder project that will build the human readable file into a binary that can get loaded at run time.
This class has been interesting in that it has made me think about readability of code more than anything else. Usually engineering classes teach you how to write code but rarely do they make you think about how others perceive the code you’ve written.
I think the objective of the assignments was to teach us how to write good interfaces, working with large code bases, the importance of human readable files and how to keep things efficient when reading files off the disk (using binary files).
The things I learn about binary files has really opened my eyes to a new way of dealing with loading files at run time. I was always comfortable dealing with data driven code and all the times I did implement data driven code, I was using text files to make it easy for designers to control but I now see that loading text files at run time is not always the best idea.
I’ve always tried to think about software architecture in terms of what it means to achieve. I tend to design architecture based on a mix of short term and long term goals. I try to walk the line between generic and specific, you can say it is just generic enough that you can easily extend it but I will not go out of the way to make things too abstract. Time is a very important factor to help me decided how high level the architecture will be, if I have a lot of time I may create more generic interfaces but when the timelines are short, I build systems that do exactly what they need to.
I judge good software architecture by how easy it is to use. I have worked on systems that are so tightly knit that to extend them to do anything other than what they were designed to is a monumental task, and on the other end of the spectrum there have been systems where to add a new features requires configuring a large number of files. In my opinion good software is one that is easy to use: to a user, a programmer or in games, for a designer. Off late I’ve been mostly designing game architecture keeping in mind the designer and the way that they think and use it to design games.
You can move the camera using the following controls:
The spline cube can be viewed by rotating the camera 90 degrees to the left.