Shantanu Pandey
  • Projects
    • Hard Light Vector
    • Memory Manager
    • Samurai Crusader
    • Dyslexia VR
    • Geriatric Depression Suite
  • Prototypes
    • Game Mechanics
    • Diana's Inferno
    • MakeUp & BreakUp
    • 10Pest
    • Ninja Pinball
  • Blogs
    • Sic Parvis Magna
    • Game Engineering - Week 1
    • Game Engineering - Week 2
    • Game Engineering - Week 3
    • Game Engineering - Week 4
    • Game Engineering - Week 5
    • Game Engineering - Week 6
    • Game Engineering - Week 7
    • Game Engineering - Week 8
    • Game Engineering - Week 9
    • Engine Feature - Audio Subsystem
    • Final Project - GameEngineering III
    • AI Movement Algorithms
    • Pathfinding Algortihms
    • Decision Makiing
  • About

Week 8 - 10/17/2018

10/25/2018

1 Comment

 
This week assignment was about the Binary Files. Instead of loading mesh data from human readable lua files as last week, we generated binary files and used that to initialize our mesh.
Binary Files
For creating our mesh, we require 4 important pieces of data. I have stored this data in the binary file in the following order:
  • Index Count
  • Index Array Data
  • Vertex Count
  • Vertex Array Data
The order in which we store this data in the binary file is not that important. The important part is to read the data the way we store it. Below image show my binary file representation (not the actual file but the representation of how I am storing the data):
Picture
The green part is index count followed by index data in red. After that its vertex count and then vertex data. We should try to store the data which is most feasible to us in terms of reading this data.

Two major advantages of a binary file are its size and processing time. Binary files are much smaller as compared to human readable files and the reading of data is much faster in them. For my helix test mesh, I found the following information in the release build:
  • Time to load was 0.022090 secs for human readable lua file vs 0.000205 secs for the binary file.
  • Size on disk was 285 kb for for human readable lua file vs 71 kb for the binary file.

[Note: There are various ways we can write the binary file. We can use fwrite() (C approach) or ofstream (C++ approach). Since while writing the binary file, we are first parsing the lua file, we can either open the file, write the information as we parse it and close the file (and keep on opening and closing as we parse the relevant information from lua). Otherwise, we can parse all the information from lua first and then write it at once to the file. It’s advisable to parse all the information first and then write it to the file to avoid multiple opening and closing calls to the file. This also improves readability of the code as all the write calls are together. While doing multiple open/write/close calls, it’s also important to always open the file in binary. I missed this once and as a result was getting additional 0D before every 0A byte in my binary file. This was because file was getting opened in text mode and MS-DOS (windows) will add an 0D before every 0A in text mode (translation of Line Feed (0A) and Carriage Return (0D) occurred).
This thing took me some time to figure out (I even tried the memory debugging as I was not sure what I am seeing in the binary file is correct!). While reading serialized binary files (by serialized I mean when we have a fair idea about the data in the binary file), one thing which might be helpful is to check how and where the pattern of data is changing. I realized this as in our binary file every alternate byte was 00 (index count and index data) and 0D was getting added right before 0A, the order of 00 suddenly changed. It will not tell the root cause, but certainly will take us one more step closer to the problem.]

Mesh Builder
For this assignment, we moved the parsing of lua code to the mesh builder. Mesh builder is an application which will build our binary file in build time. I am changing the winding order for Direct3D in mesh builder while writing the binary file rather than dong it on run time as before. Both the ways will work but I think we should do it in mesh builder as:
  • It saves some run time by doing the calculation in build time. It’s a fair trade-off as players care more about run time then the load time.
  • It generates different file for OpenGL and Direct3D which is better if we try to open and read the binary files as developer.

As the mesh builder is running when we build the project, its difficulty to debug inside this (We can log debug messages but not been able to hit the break points is obnoxious!). The way to debug here is:
  • Set this project as the Startup Project
  • We are defining in AssetBuildFunctions.lua to run this project. Here we can print the arguments which mesh builder will take while it runs.
  • We can then specify these arguments in the project setting (Settings -> Debugging -> Command Arguments) and then we can debug this project as normal run time debugging.
This is an important way on how we can debug the build time applications.

Game Screenshot
Playable EXE Download
Controls: 
         
W S A D to move game object.
        Up Down Left Right to move camera.
        Ctrl to switch the mesh of game object.
        Space to hide one object (plane).
Picture
1 Comment

    Author

    Write something about yourself. No need to be fancy, just an overview.

    Archives

    October 2018

    Categories

    All

    RSS Feed

FOR ANY FURTHER DETAILS


Telephone

801-859-1131

Email

Resume
File Size: 227 kb
File Type: pdf
Download File

Visit Hard Light Vector
[email protected]
Git Hub
  • Projects
    • Hard Light Vector
    • Memory Manager
    • Samurai Crusader
    • Dyslexia VR
    • Geriatric Depression Suite
  • Prototypes
    • Game Mechanics
    • Diana's Inferno
    • MakeUp & BreakUp
    • 10Pest
    • Ninja Pinball
  • Blogs
    • Sic Parvis Magna
    • Game Engineering - Week 1
    • Game Engineering - Week 2
    • Game Engineering - Week 3
    • Game Engineering - Week 4
    • Game Engineering - Week 5
    • Game Engineering - Week 6
    • Game Engineering - Week 7
    • Game Engineering - Week 8
    • Game Engineering - Week 9
    • Engine Feature - Audio Subsystem
    • Final Project - GameEngineering III
    • AI Movement Algorithms
    • Pathfinding Algortihms
    • Decision Makiing
  • About