16 #define TACHYON_INTERNAL 1    40 static object_methods scalarvol_methods = {
    42   (
void (*)(
void *, 
void *, 
void *, 
void *))(
box_normal),
    49                     int xs, 
int ys, 
int zs, 
const char * fname, 
    51   standard_texture * tx, * tex;
    54   tex=(standard_texture *) voidtex;
    55   tex->flags = RT_TEXTURE_NOFLAGS; 
    57   tx=malloc(
sizeof(standard_texture));
    72   strcpy(vol->
name, fname);
    82   tx->flags = RT_TEXTURE_NOFLAGS;
    93   tx->outlinewidth = 0.0;
    97   tx->obj = (
void *) 
newbox(tx, min, max); 
   107     tx->texfunc = (color(*)(
const void *, 
const void *, 
void *))(
constant_texture);
   112   return (
void *) tx->obj;
   126     col.r = scalar * 4.0;
   133       col.g = (scalar - 0.25) * 2.0;
   139       col.b = (scalar - 0.75) * 4.0;
   150   flt a, tx1, tx2, ty1, ty2, tz1, tz2;
   152   flt t, tdist, dt, sum, tt; 
   153   vector pnt, bln, bln_1;
   155   flt scalar, transval; 
   156   long x, y, z, lxyres, lxres;
   158   standard_texture * tex = (standard_texture *) tx;
   159   const flt voxel_inv = 1.0f / 255.0;
   161   vol=(
scalarvol *) ((standard_texture *) bx->tex)->img;
   170   if (ry->d.x == 0.0) {
   171     if ((ry->o.x < bx->
min.x) || (ry->o.x > bx->
max.x)) 
return col;
   173     tx1 = (bx->
min.x - ry->o.x) / ry->d.x;
   174     tx2 = (bx->
max.x - ry->o.x) / ry->d.x;
   175     if (tx1 > tx2) { a=tx1; tx1=tx2; tx2=a; }
   176     if (tx1 > tnear) tnear=tx1;
   177     if (tx2 < tfar)   tfar=tx2;
   179   if (tnear > tfar) 
return col;
   180   if (tfar < 0.0) 
return col;
   182   if (ry->d.y == 0.0) {
   183     if ((ry->o.y < bx->
min.y) || (ry->o.y > bx->
max.y)) 
return col;
   185     ty1 = (bx->
min.y - ry->o.y) / ry->d.y;
   186     ty2 = (bx->
max.y - ry->o.y) / ry->d.y;
   187     if (ty1 > ty2) { a=ty1; ty1=ty2; ty2=a; }
   188     if (ty1 > tnear) tnear=ty1;
   189     if (ty2 < tfar)   tfar=ty2;
   191   if (tnear > tfar) 
return col;
   192   if (tfar < 0.0) 
return col;
   194   if (ry->d.z == 0.0) {
   195     if ((ry->o.z < bx->
min.z) || (ry->o.z > bx->
max.z)) 
return col;
   197     tz1 = (bx->
min.z - ry->o.z) / ry->d.z;
   198     tz2 = (bx->
max.z - ry->o.z) / ry->d.z;
   199     if (tz1 > tz2) { a=tz1; tz1=tz2; tz2=a; }
   200     if (tz1 > tnear) tnear=tz1;
   201     if (tz2 < tfar)   tfar=tz2;
   209   if (ry->maxdist < tfar) 
   213   if (tnear > tfar) 
return col;
   214   if (tfar < 0.0) 
return col;
   216   if (tnear < 0.0) tnear=0.0;
   224   dt=
SQRT(bln.x*bln.x + bln.y*bln.y + bln.z*bln.z) / tdist; 
   233   bln_1.x = 1.0 / bln.x;
   234   bln_1.y = 1.0 / bln.y;
   235   bln_1.z = 1.0 / bln.z;
   237   for (t=tnear; t<=tfar; t+=dt) {
   238     pnt.x=((ry->o.x + (ry->d.x * t)) - bx->
min.x) * bln_1.x;
   239     pnt.y=((ry->o.y + (ry->d.y * t)) - bx->
min.y) * bln_1.y;
   240     pnt.z=((ry->o.z + (ry->d.z * t)) - bx->
min.z) * bln_1.z;
   242     x=(
long) ((vol->
xres - 1.5) * pnt.x + 0.5);
   243     y=(long) ((vol->
yres - 1.5) * pnt.y + 0.5);
   244     z=(long) ((vol->
zres - 1.5) * pnt.z + 0.5);
   246     ptr = vol->
data + ((lxyres * z) + (lxres * y) + x);
   248     scalar = ((int) ptr[0]) * voxel_inv;
   252     transval = tt * scalar; 
   257       col.r += transval * col2.r;
   258       col.g += transval * col2.g;
   259       col.b += transval * col2.b;
   260       if (sum < 0.0) sum=0.0;
   287   dfile=fopen(vol->
name, 
"r");
   290     sprintf(msgtxt, 
"Can't load volume %s, using object color", vol->
name); 
   297     sprintf(msgtxt, 
"Loading %dx%dx%d volume set from %s",
   307     sprintf(msgtxt, 
"Can't load volume %s, using object color", vol->
name); 
 color shade_transmission(ray *incident, const shadedata *shadevars, flt trans)
 
RT_OBJECT_HEAD vector min
minimum vertex coordinate 
 
box * newbox(void *tex, vector min, vector max)
 
void rt_ui_message(int level, char *msg)
 
void box_intersect(const box *bx, ray *ry)
 
color scalar_volume_texture(const vector *hit, const texture *tx, ray *ry)
 
vector max
maximum vertex coordinate 
 
Tachyon cross-platform thread creation and management, atomic operations, and CPU feature query APIs...
 
double flt
generic floating point number, using double 
 
int rt_mynode(void)
distributed memory parallel node rank 
 
color VoxelColor(flt scalar)
 
Tachyon cross-platform timers, special math function wrappers, and RNGs. 
 
void LoadVol(scalarvol *vol)
 
void * newscalarvol(void *voidtex, vector min, vector max, int xs, int ys, int zs, const char *fname, scalarvol *invol)
 
Tachyon public API function prototypes and declarations used to drive the ray tracing engine...
 
void box_normal(const box *bx, const vector *pnt, const ray *incident, vector *N)
 
int scalarvol_bbox(void *obj, vector *min, vector *max)
 
color constant_texture(const vector *hit, const texture *tx, const ray *ry)
 
axis-aligned box definition