20.05.2015, 21:54
(
Последний раз редактировалось Crayder; 20.05.2015 в 22:39.
)
Quote:
Yes but I don't understand how the data is actually stored, what is the starting object etc, and I think it'd be easier to just store all the variables in one LARGE string, and then print it to the file - no need to write every loop.
|
I'm writing every loop because modelsizes has 16 objects per line. I'm doing 20 objects (col) per line (row).
It's not like a large string is going to speed it up, it's only 1000 writes.
EDIT: Btw, in my code where I multiply by 1000, it should be by 20. XD
And the string sizes need raised, then the code works beautifully!
The new, perfect (nothings perfect, but it's close) code.
Код:
new Line[2][1536], Float:oX, Float:oY, Float:oZ, Float:R, File:Sizes = fopen("sizes.txt", io_append), File:Offsets = fopen("offsets.txt", io_append); for(new row; row < 1000; row++) { Line[0][0] = EOS; Line[1][0] = EOS; strcat(Line[0], "\t\t"); strcat(Line[1], "\t\t"); for(new col; col < 20; col++) { CA_GetModelBoundingSphere((row * 20) + col, oX, oY, oZ, R); strcat(Line[0], sprintf("%0.6f, ", R)); strcat(Line[1], sprintf("{%0.6f, %0.6f, %0.6f}, ", oX, oY, oZ)); printf("[%i] R: %0.6f S: %0.6f, %0.6f, %0.6f", (row * 20) + col, oX, oY, oZ, R); } strcat(Line[0], "\r\n"); strcat(Line[1], "\r\n"); fwrite(Sizes, Line[0]); fwrite(Offsets, Line[1]); } fclose(Sizes); fclose(Offsets);