Skip to content

Instantly share code, notes, and snippets.

@infogulch infogulch/slab6.c
Created Jul 27, 2012

Embed
What would you like to do?
Excerpt from slab6.c: savevox()
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
You can’t perform that action at this time.