Forum > Development and Presentation
[QUESTION] Parsing ADTs..
<< < (2/2)
Neglected:
--- Quote from: "schlumpf" ---Add 0x14 to all offsets.
You may always want to start reading a chunk by comparing the identifier. At 0x0 in the file you should get 'MVER'.
This is not the case with your reading. It is not the file being wrong, but as said, you reading starting at the wrong position. --- End quote --- Just started using official Blizz files and the reading is going fine so far, but the MCNK part still seems to be out of it.
I'm not actually reading by offsets, btw, I'm reading the file as a whole, so the need for offsets is largely negligble. That is, I'm doing something like this..
--- Code: --- Read MVER // now we've read the MVER from the file, the FileInputStream increments it's position, so the next chunk will be MHDR Read MHDR Read MCIN Read MCNK // This is where I am having trouble. --- End code ---
I am always comparing the Chunk header, and whenever I compare it, the header is correct - even the MCNK one, which I'm having problems with. :l By reading the whole file and checking the header I don't need to check if we're on the right chunk because I'm guarenteed we are :P
Edit: http://pastebin.com/qcjPGF8r Above is the MCNK parse code. As you can see, the Subchunks are not included, and that is for the reason that because the class reads like this:
--- Code: --- read 4 bytes -> name read 4 bytes -> size create array[size]
--- End code --- It means we get heap allocation errors because we read integers that are 1296256081 big. xD
Edit 2: http://pastebin.com/JvXk59E4 Corrosponding value dump.
Edit 3: I'm indecisive. Anyway, I DO check for MH2O before loading the MCNK, so that's not the issue in case you're wondering :P
Edit 4: SOLVED! I forgot I had set the Endianness of the buffer to LITTLE_ENDIAN and was then attempting to reverse all the data, effectively negating it. Thanks for your help :)
Edit 5: Removing the solved status as I still have an issue parsing the ADTs. Right now I'm attempting to simply draw the plane on which the ADT lies - that is, a point by point representation of the ADT. I'm having trouble working out how to use MCVT to generate a height map - how would I go about doing this? (Also, how could I tesselate the chunks in an ADT so that they are next to each other? Using OpenGL at the moment)
glararan:
If you want i can help you with this program.
Navigation
[0] Message Index
[*] Previous page
|