Graphics Reference
In-Depth Information
{
FILE *fp = fopen( “vis3dtexture.tex”, “wb” );
if( fp == NULL )
{
fprintf( stderr,
“Cannot create the output 3D texture file\n” );
return 1;
}
fwrite( &NUMS, 4, 1, fp );
fwrite( &NUMT, 4, 1, fp );
fwrite( &NUMP, 4, 1, fp );
float zero = 0.;
for( int p = 0; p < NUMP; p++ )
{
float z = -1. + 2. * (float)p / (float)( NUMP-1 );
for( int t = 0; t < NUMT; t++ )
{
float y = -1. + 2. * (float)t / (float)( NUMT-
1 );
for( int s = 0; s < NUMS; s++ )
{
float x = -1. + 2. * (float)s / (float)
( NUMS-1 );
float value = HOWEVER YOU COMPUTE IT,
LOOK IT UP, ETC
fwrite( &value, 4, 1, fp );
fwrite( &zero, 4, 1, fp );
fwrite( &zero, 4, 1, fp );
fwrite( &zero, 4, 1, fp );
}
}
}
fclose( fp );
return 0;
}
In the examples below, we will use the texture-file format to hold data
that is a summation of decaying exponentials, approximating a temperature
distribution in a room with individual heat sources, and whose walls are a heat
sink. This data is available in the file vis3dtexture.tex with the resources
for this topic. In practice, up to four data components could be encapsulated
at the same time, giving you more flexibility in what combinations you can
visualize.
Search WWH ::




Custom Search