I'm writing a Quake3 model loader in C#. I want to fill a struct with the file header data
Here's a tiny segment of the data :
What's the best way of loading this from a file? Currently, I'm doing something like this:
Two questions:
Do I have to do it like this, specifying each individual element, or is there some way I can tell it to just stream the entire thing bit-for-bit into the struct?
If I can grab the entire lot in one go, how do I specify that (for instance) the Name element is actally 64 chars long? Given you can't specify array lengths within the struct declaration, it doesn't seem to be possible.
Thanks,
Cat
Here's a tiny segment of the data :
Code:
struct MD3Header
{
public int Ident;
public int Version;
public char[] Name; // 64 chars long
}
What's the best way of loading this from a file? Currently, I'm doing something like this:
Code:
FileStream fileStream = File.OpenRead(filename);
BinaryReader file = new BinaryReader(fileStream);
MD3Header md3;
md3.Ident = file.ReadInt32();
md3.Version = file.ReadInt32();
md3.Name = file.ReadChars(64);
Two questions:
Do I have to do it like this, specifying each individual element, or is there some way I can tell it to just stream the entire thing bit-for-bit into the struct?
If I can grab the entire lot in one go, how do I specify that (for instance) the Name element is actally 64 chars long? Given you can't specify array lengths within the struct declaration, it doesn't seem to be possible.
Thanks,
Cat