{
windowpat.cal - calculations for a regular array of windows
or rectangular patters or whatever for a variety of surfaces.
Copyright 1998, Mark J. Stock
If the surface to which this texture is applied is a
polygonized surface or a horizontal cylinder, use 5 arguments.
If the surface is a vertical or diagonal cylinder, cone, or
sphere, use 6. The sixth argument is the radius at which the
windows' width will be correct. i.e. If the surface is curved
in the horizontal plane, use the 6th argument.
It is important to keep the block_* size larger than the
window_* size.
usage:
void brightfunc window_pattern
2 lite_on window_array.cal
0
5 block_width block_height window_width window_height on_frac
or
6 block_width block_height window_width window_height on_frac radius
}
{ normalize Nx and Ny }
squ = Nx*Nx+Ny*Ny;
nx = sqrt(Nx*Nx/squ);
ny = sqrt(Ny*Ny/squ);
{ horizontal, vertical, and angular coordinates }
hval = (ny*Px-nx*Py)/A1;
vval = Pz/A2;
aval = atan2(Ny,Nx)*A6/A1;
{ horizontal and vertical cells and remainders }
ch = floor(hval);
rh = hval - ch;
cv = floor(vval);
rv = vval - cv;
ca = floor(aval);
ra = aval - ca;
lite_on = if(rv-A4/A2, 0,
if(abs(Nz-0.2)-0.6, 0,
if(AC-5.5,
if(ra-A3/A1, 0,
if(2.0*A5+fnoise3(100*ca,0.0,40*cv)-1.0,1.0,0.0)),
if(rh-A3/A1, 0,
if(2.0*A5+fnoise3(100*(ch+nx+ny),A1,40*cv)-1.0,1.0,0.0))
)
)
);
lite_off = 1 - lite_on;