Hiya fella's
I need a little help to get started in writing a parser for Directx Binary file(eof file). haha before you tell me to use directx's builtin loader functions i aint using direct3d i am using OpenGL. I have seen code to parse text file version but i want to use the binary version. I should also add i don't expect anyone to write the whole lot i just need a little kickstart and i will figure the rest out. Another thing is i don't require any animation, just need to load a mesh and it's materials.
i can load in the header of the binary file.
//////////////////////////
//////////
//////CODE
//////////
//////////
//////////
//////////
//////////
//////////
////
//from MSDN:
#define XOFFILE_FORMAT_MAGIC \
((long)'x' + ((long)'o' << 8) + ((long)'f' << 16) + ((long)' ' << 24))
#define XOFFILE_FORMAT_VERSION03 \
((long)'0' + ((long)'3' << 8)) //+ ((long)'0' << 16) + ((long)'2' << 24))
#define XOFFILE_FORMAT_BINARY \
((long)'b' + ((long)'i' << 8) + ((long)'n' << 16) + ((long)' ' << 24))
#define XOFFILE_FORMAT_TEXT \
((long)'t' + ((long)'x' << 8) + ((long)'t' << 16) + ((long)' ' << 24))
#define XOFFILE_FORMAT_COMPRESSED \
((long)'c' + ((long)'m' << 8) + ((long)'p' << 16) + ((long)' ' << 24))
#define XOFFILE_FORMAT_FLOAT_BITS_
32 \
((long)'0' + ((long)'0' << 8) + ((long)'3' << 16) + ((long)'2' << 24))
#define XOFFILE_FORMAT_FLOAT_BITS_
64 \
((long)'0' + ((long)'0' << 8) + ((long)'6' << 16) + ((long)'4' << 24))
struct X_HEADER
{
unsigned long Magic;
unsigned short MajVersion;
unsigned short MinVersion;
unsigned long Format;
unsigned long Size;
};
ifstream myFile;
X_Header header;
.......................
void main()
{
myFile.open("test.x",ios::
in| ios::binary);
myFile.read((char*)&header
,sizeof(X_
HEADER));
if(!ProcessHeader())
{
//error code
}
}
//check file header is correct binary file
bool ProcessHeader()
{
if (header.Magic != XOFFILE_FORMAT_MAGIC)
{
printf("Not a .X model file. Aborted...\n");
return false;
}
if (header.Format != XOFFILE_FORMAT_BINARY)
{
printf("Not A Binary .x Model File. Aborted...\n");
return false;
}
if (header.MajVersion != XOFFILE_FORMAT_VERSION03)
{
printf("Wrong File Version. Aborted...\n");
return false;
}
if (header.MinVersion != XOFFILE_FORMAT_VERSION03)
{
printf("Wrong File Version. Aborted...\n");
return false;
}
return true;
}
//////////////////////////
//////////
//////////
//////////
//////////
//////////
//////////
//////////
//////////
////
I just haven't got my head around all this token and template stuff that MSDN is talking and howto parse it properly.
so if someone could just get me started and show me how to load say just the first template...hopefully after i see how it is done i will understand it better and can than load the other stuff like the mesh and it's vertices etc etc
Thanks everyone
View the Solution FREE for 7 Days