I'm having to come up with the format of my Resource File and I'd like to ask about the ways they're made, for example, if I'm using the code:
ifstream fileReader;
fileReader.open("Test.fbx");
if(fileReader.is_open())
{
char buffer[256];
while(fileReader.eof())
{
fileReader >> buffer;
//Here
}
}
When parsing .OBJ or .ASE files from 3DS Max, I could simply check for a...
if(strcmp("VERTEX:", buffer) == 0)
{
//Whatever I want to do with vertexes
}
...because each vertex value was separated by an empty space, but when parsing a .FBX there's no spaces until the end of the line, and thus I had to:
int lineLength = strlen(buffer);
for(int i = 0; i < lineLength; i++)
{
//buffer[i] has my current char
}
And get the values together by counting how many ',' I went through, etc. I think the 2nd way is much worse due complexity, but I don't know how it affects performance-wise.
What are the best practices for the creation of asset files? I plan on having all of them in a single file, but separated by something like "IMG:" (all image data defined by IDs) "OBJ:" (all model data) "WAV:" (all audio) etc.
Edit: I'm asking if there's any "best practices" when developing your own resource file, and it'd be binary of course, and I didn't meant to use the original resource files at all. Something like this:
Resource.dat (in ASCII)
IMG:
1 MyPicture.jpg [binary data composing only what I need from a .jpg file] ;
2 AnotherPicture.bmp [binary data composing only what I need from a .bmp file] ;
OBJ:
3 MyModel.fbx [fbx binary data] ;
etc I won't save all the file headers for example, and I probably won't have more than one format for my resources, I'll be converting them all to just the data I need into my resource, such as the imageWidth, imageHeight, and 4 values per pixel for a image resource. I have another code which parses these original files (.jpg, .fbx) and I'm going to save them into a new resource file (in a bloated .dat, organized by object index) to be used in the game engine, but I'd like to know any best practices while creating such a format so I don't code everything just to figure out after "Ops, I should've also saved [data] because I need it now"