Created
July 27, 2012 23:42
-
-
Save infogulch/3191075 to your computer and use it in GitHub Desktop.
Excerpt from slab6.c: savevox()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void savevox (char *filnam) | |
{ | |
FILE *fil; | |
long i, x, y, z; | |
voxtype *vptr, *vptr2; | |
optimizexdimen(); | |
optimizeydimen(); | |
optimizezdimen(); | |
if (!(fil = fopen(filnam,"wb"))) return; | |
fwrite(&xsiz,4,1,fil); | |
fwrite(&ysiz,4,1,fil); | |
fwrite(&zsiz,4,1,fil); | |
vptr = voxdata; | |
for(x=0;x<xsiz;x++) | |
for(y=0;y<ysiz;y++) | |
{ | |
vptr2 = &vptr[ylen[x][y]]; | |
for(z=0;z<zsiz;z++) | |
{ | |
if ((vptr < vptr2) && (vptr->z == z)) | |
{ fputc(vptr->col,fil); vptr++; } | |
else | |
{ | |
i = (x*MAXYSIZ+y)*BUFZSIZ+z; | |
if (!(vbit[i>>5]&(1<<i))) fputc(0,fil); | |
else fputc(255,fil); | |
} | |
} | |
} | |
fwrite(fipalette,768,1,fil); | |
fclose(fil); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment