readFile and LPVOID

Started by
10 comments, last by CyberSlag5k 19 years, 2 months ago
Quote:Original post by CyberSlag5k
I've never even seen #QNAN before, and the e###'s make me a little concerned. Plus, none of these values should be negative (although sometimes certain exporters break that convention. Does the e stuff suggest I should be using doubles? I think I might anyway, just to be safe. So yeah, these values are garbage, I think, but the rest of my stuff reads in ok.

#QNAN means that the data read in doesn't represent a floating point number (NAN == Not A Number). The e### stuff is nothing to worry about. If you do float f = 10000000.0f; and then try to cout it, you'll get something with an exponent most likely.

Quote:Original post by CyberSlag5k
normVector.setVector(buffer[0 + (i*4)], buffer[4 + (i*4)], buffer[8 + (i*4)]);

If buffer is an array of floats, then you should be adding 1 each time, not 4. The number is the index in "units" (floats in this case), not bytes (unless buffer is an array of bytes of course).
So, if buffer is an array of floats, the line should be: normVector.setVector(buffer[0 + (i*4)], buffer[1 + (i*4)], buffer[2 + (i*4)]); and similarly for the other lines (3+(i*4), etc).

Quote:Original post by CyberSlag5k
EDIT: It would be nice to be able to check my data to see what the values should actually be. I've tried a few hex viewers I found on download.com but they just came up gibberish. Anyone know a good (free) application for viewing binary files? The data is stored as floats, if that makes any difference.

I use AXE quite happily.

Quote:Original post by CyberSlag5k
Another question, is there a maximum size for these things? I have some pretty gigantic files. Since I'm dynamically creating the buffer/array of floats, I should be able to load in files until I run out of available memory, right?

There's not really any maximum size, But you'll have extreme problems going over 1Gb or so. I've allocated 700Mb in one go before (I have 512Mb RAM). It works, but the call to new takes 2 or 3 minutes (litterally).
Advertisement
As always, Evil Steve, you are the man. Thank you.

I have noticed two more problems with my program. The first is that the data stream contains 2 bytes of nothing I have to skip (which I'm not). The second is that I am totally not going through the data correctly.

Assuming a float is 4 bytes (which on my system it is), look at the first setVector call. On the first iteration, we're reading in data elements 0 (0 + 0 * 4), 1 (1 + 0 * 4), and 2 (2 + 0 * 4). The last vector element set will be 11 (11 + 0 * 4). Now, on the second iteration the first setVector call will be elements 4 (0 + 1 * 4), 5 (1 + 1 * 4), and 6 (2 + 1 * 4). Silly me. I'm fixing it now (I can handle that on my own, I just wanted to point it out just in case anyone is doing anything similar).

Thanks again Evil Steve.
Without order nothing can exist - without chaos nothing can evolve.

This topic is closed to new replies.

Advertisement