One of the major gaming projects I worked on was building a custom game engine. It involved creating various components that could finally be used
together to make a working engine to display and simple animation of models. It involved making a various systems and making them work together for the engine to work.
PCS Tree
Root Node : Consisting of a child and sibling. It will encapsulate methods like create(), destroy(), insert(), dumpTree(), getInfo().
A normal node (if not a root) will comprise of getName(), setName(), getParent(), getChild(), getSibling(), dumpChild(), dumpSibling(), etc
The PCSInfo module will comprise of number of nodes (numNodes), number of levels of the tree (numLevel) and maximum Node Count (maxNodeCount).
The PCS Tree is used to create a hierarchical model for the animation system. For graphic transformations for the bone animations.
Memory System
The memory management system was to overload and wrap the existing memory operations. Memory system must support multiple heaps - ability to create and destroy heaps. Using a singleton memory manager to create and destroy heaps Must be able to walk through and dump a list of every allocation - per heap/entire engine.
Memory Manager - A global singleton that has a reference to list of allocations and heap headers. Also contains data like total allocations and such.
Heap Header - A header for each heap! Each heap has one and it keeps track of the heap and all allocations within it.
Allocation Header - A header block that sits directly on top of each allocation. Mainly used for linking. Has next and previous links for both global and heap.
Memory - Not really a class but this is where I put my global operator overloads for new and delete.
Math Library
The math engine was pretty simple to put together for the most part. It basically was operator overloads for a Vector and Matrix class. I started with the vector class and the most difficult thing was probably just getting used to forgetting about the fourth homogeneous coordinate. Added a few extra functions for magnitudes, normal, cross, dot, etc but for the most part most of the functionality comes from math operator overloads. Once I had all the functionality I needed, I realized that I was getting several returning local variable warnings. Moving on to the Matrix class was a lot more of the same operator overloads. Especially doing the determinate and inverse matrix.
File System
The file system was to get a glimpse into the win32 API. The function calls were fairly simple to find by name, and I only created a very basic read, write, and read/write file open and closing system. I had a bit of trouble figuring out which of the methods to call for the tell function which returns where in the file the handle is currently. Just to keep all the calls simple as possible, I had to make a few design decisions. When opening files, the user can open for read, write or both, however it is set to OPEN_ALWAYS so files will be opened and if it doesn't exist will be created and opened. The seeking gives the user the ability to seek from the beginning, current position, or end of a file.
my wrapping functions: open, close, write, read, seek, tell, flush
FBX Importer
I used the ImportScene file from the FBX examples to read the fbx model data and make a composite list of all the data to be used. Then I make a list of polygons with access to the vertex list. To make the list I had to extract the data from the existing file. If everything is stored in the polygons I create an empty vertex list using only the vertex coordinates and then I extract the normals and UVs from the polygons and put them in the list. The model normals are stored in control points I just store this normals next to the vertices.
Sometimes the UVs in the polygons can change even if the vertices and coordinates are the same, if this happens I add a new element at the end of the list with this new information. All this is done in the DisplayControlPoints call from the ImportScene example in the DisplayMesh.cxx file. In my Game Engine I made a new GraphicObject called polygonmodel and I load the created file and extract the data and load the VBOs.
Animation
I made changes to my game engine to add a simple 2-Bone animation. I added a time class and the game loop. I then modified the pyramid class and use it as a bone. I added a direction and length to the pyramid object to the pyramid object to be able to change the animation with respect to their parents. After that I had to create a relation between the bones in order for them to work together. For this I added the PCS system from last quarter, I changed the graphic manager to support the PCS system and draw objects as it walks the tree via DFS.
For the animation I had added anim.cpp, where the necessary structs to start processing an animation and how to play. I take my array of bones and use their data to create the animation the engine will play. This is called in each time in the main game loop . But to set the data it is stored in the 2boneanimation file .The animation data is currently just set in this file I have not yet added a way to read from any specific animation file. The hierarchy of the animation and set the root bone and the respective node bones. I set the start ,middle and end frame of the animation. I set the data for each of the key frame , and from this data I can interpolate depending on the current time and the closest key frame.