the file is a MD3 format, Here is the code i use to read the first few bytes
ifstream md3file;
md3file.open(filename.c_str(), ios::in|ios::binary|ios::ate|ios_base::binary);
// C stuff
md3_header * md3Header = (struct md3_header *)
malloc(sizeof(struct md3_header));//Malloc seems to read the data correctly
//new vector<int>(sizeof(struct md3_header));
// it involves evil casting.
md3file.read((char *) &md3Header, sizeof(struct md3_header));
if((md3Header->ident != 860898377)||(md3Header->version !=15)
||((md3Header->fileID[0] != 'I')
||(md3Header->fileID[1] != 'D')
||(md3Header->fileID[2] != 'P')
||(md3Header->fileID[3] != '3')))
{
cout<<"Bad Version or identifier"<<endl;
cout << md3Header->fileID[0] << md3Header->fileID[1] <<
md3Header->fileID[2] << md3Header->fileID[3] << endl;
cout << md3Header->version << endl;
cout << md3Header->ident << endl;
}
Now this is what is displayed in my console
Bad Version or identifier
?B??
-23510312
52
now i know this MD3 is correct as another MD3 loader loads it fine ,
Now i want to try and do something different, my code above takes in the struct from my header and places a template inside md3Header, it then puts all the data from the file provided through the parameter into that struct, but as you can see im getting the wrong data,
So here is the question, how can i actually manually tell that my md3Header.fileID[0] to be = to the frist byte in my MD3 file?
in C# i can see it would be so easy just a nice simple md3Header.fileID = getTest(enc.GetString(reader.ReadBytes(4)));
for your information fileID is fileID[4], each has a letter or a number inside it,
Now im not sure if getting the first byte is the way to go, but i want to actually manually put each bit of data into my header pointer
myself instead of trusting "read" function and sizeof
If anyone could help that would be awesome
Canvas