Tuesday, April 26, 2011

Of engines and models... a little sample for you guys!

As I mentioned yesterday in my post, work is complete for the First Milestone. In order to do a little summary about the experience so far, I can say that the work done can be divided in two phases: creating the FBX Converter and refactoring the Engine to add the model loading capability.

The first part, which involved around 80% of the total time employed, was mostly about figuring out how to read the internals of the FBX Model. This was facilitated by using the supplied program as a starting point. With this program already displaying on screen the desired information (polygons and vertices), the following task was to reduce the code to what was actually necessary, eliminating from the code all other unnecessary functions. Finally, the code was refactored for storing the information in data structures instead of displaying it on screen, and then the File System built last quarter was integrated in order to write all the data into a single file using the archiver format.

The second part consisted of integrating the File System into the Engine in order to be able to read the file back. After this, there were some minor tweaks done here and there in the Engine for interpreting the data accordingly, but in general the code was not changed in a significant way.

I have to mention that it is an awesome feeling when you glue all the pieces together and they work flawlessly from the beginning, especially when I am talking about code that I did not spent too much time testing, but its design has proven to be well-thought and bullet-proof so far. Of course I am speaking about the File System, which was incorporated into the rest of the code quiet easily and trouble-free, saving quite a few hours of extra work.

My fellow readers, here you have a little taste of the Updated Engine I just submitted:


Well, FBX models can be converted into my own file format now, and the engine can interpret and render them on screen. Next stop is Quaternions and Animations. See you soon!

Adios!

Monday, April 25, 2011

Here is the story of how this two dudes met: the FBX Converter and Diego's 3D Model!

Hello you all! I am back from a weekend of intense work, code tuning and wrapping things together for milestone submission. That’s right! Yesterday I submitted the first milestone for my updated Graphics Engine including the first version of the FBX Converter.

Let’s get down to business. I will use this post to talk about the final details of the FBX Converter and the File Format used to store the models. Since I previously talked about the logic behind the FBX Converter, and taking into account that it has not changed, I will proceed to explain how the program can be used. The syntax for using it is the following:

                FBX_Converter.exe infile.fbx outfile.d3m [options]

There are two (2) possible options or arguments that can be passed to the program:

                -notexture
                -addtexture texture.tga

The first option simply omits any texture contained inside the FBX file, so the converter only extracts vertex and triangle data. The second option tells the converter to use an external texture instead of the one contained inside the FBX, therefore the final model file contains the texture supplied by the user.

Regarding the File Format (Diego’s 3D Model), it is composed of three big chunks of data (Vertices, Triangle Indices and Texture) accompanied by their respective type-specific headers and chunk headers.

At the beginning of the file is the File Header, which contains descriptive information for reading the rest of it like the number of Chunks and total size. Next are the Chunk Headers: these specify the size of each chunk and its respective type, this way the engine is able to interpret the data back.

Finally we have all the actual data needed for rendering the model. First we have the Vertex Array with its respective header which specifies the number vertices and the individual size of each one (this is used for the Vertex Buffer Objects calls). Next we have the Triangle Indices Array, and once again in the header we have the total number of triangles and the size of each one. At last we have the Texture with its header containing the dimensions (width and height), number of colors per pixel (depth), size of texture data array and two (2) values that are necessary for rendering the texture in OpenGL (format and components).

There you have it! I will be back really soon, probably later tonight or tomorrow at the latest, with a video of my updated Graphics Engine.

Adios!

Monday, April 18, 2011

Let the models show you the way! This is the story of a baby engine trying to become a big boy!

What’s up you all? I am back with some updates regarding my progress. This was quite a productive and happy weekend. First of all, the Bulls won on Saturday, so let’s go Bulls! And second, I made huge advancements building the FBX Converter and modifying the Engine.

Regarding the FBX Converter, I (as the rest of the class) used a program provided by the SDK as my starting point. Basically this program goes through the internal structure of the FBX file, exploring its components and printing them out to a console window in an easy-to-understand way.

So, in order to get my first functional draft of the converter I just commented all the calls to functions that were printing stuff that I didn’t require. In the end, for this assignment all I need is Vertex information (position, color, normal and UV) and Texture data. Therefore, I ended just using a couple of functions from the original program, DisplayPolygons(KFbxMesh* pMesh) and DisplayTexture(KFbxGeometry* pGeometry), that provide me with all the stuff I require.

The first function (DisplayPolygons) goes through the list of polygons that form the whole mesh, showing all the information I need, so instead of printing it to the console, I am storing the info in a Vertex structure I created and pushing all those vertices into a STL Vector. After all the polygons are covered, I download all this data to a file using my File System from last quarter (I still cannot believe that it worked so flawlessly). I call this file format D3M, which stands for Diego’s 3D Model, sexy or what?

The second function (DisplayTexture) gives me the path to load the corresponding texture for the model. For the time being I am just uploading the texture manually in the engine and binding it to the model. The next step should be to actually store the texture data inside the D3M file, so I can load the complete model in one shot. Will see how that goes when I try it.

In regards to the Engine, well I just modified it to integrate my File System in it and be able to read/interpret the data inside the D3M file. So, as people usually say “a picture is worth a thousand words”, let the pictures speak for myself instead. Here is what I have right now:

Front View
Diagonal View from behind

You have no idea (or maybe you do?) how much joy I felt when I got the first model rendered. Right now I am so proud of my little baby engine, making its first steps to become a grown-up boy. 

So, for the time being I will say bye, but I will be back soon with more updates. Stay tuned!

Adios!

Thursday, April 14, 2011

A new adventure has begun… The wrath of Khan!

Welcome back you all! Spring break is over, and I am already two weeks into the quarter. This time I will use this blog to talk about the second Game Engine Programming class (GAM575). Same professor (Ed Keenan) and same students (well, actually only the ones the survived the first class, some were lost in combat … minute of silence … ), but new cool and interesting adventures. Let the fun start!

First assignment is up! I started working on it yesterday, so let me use this post to introduce you to how this quarter is going to be distributed. There are going to be 3 big programming assignments in total. According to Keenan they require less code than the previous quarter, but a more intelligent design and approach. Here you have a little description for each assignment:
  • Assignment #1 – FBX Converter: during this quarter we will be using standard format FBX for loading complex models into our engine. Therefore, this assignment is about building an offline format converter to read FBX files and extract all the vertex and polygon information to create a run-time file format that can be loaded directly in the engine without using any type of conversion (array of vertex, normals, UV coordinates and triangle indices).
  • Assignment #2 – Animation Engine: once again we will build an offline converter that extracts Animation data from an FBX file (Skeleton and Animation) and stores it in a run-time file format. In addition, we have to create the functionality in our engine to support animation running. Finally, we have to be able to do interpolation between animations (transitions in-between).
  • Assignment #3 – Skinning:  we have to extract Skin and Bone information from an FBX file (another offline converter) and display the animation of the rigid body. We are going to learn to ways of doing this: EA technique and Midway technique (don’t ask me what are they about, don’t know yet).

That’s about it, three (3) assignments; they look really interesting and should be great bullet points for my resume. I will be back soon with more information regarding Assignment #1. 

Adios!

P.S.: I also have another blog for the Multiplayer Game Development class I am taking. Enjoy it!