7.8 Three-dimensional interactive object drawing 249
mensions. The object itself is defined by a collection of independently generated
triangular elements, each defined by three nodes.
Functiondrawobj3dis identical to functiondrawplot3d, except that
the drawing module reads:
/*----------------
Draw nc elements
----------------*/
int Ibcface = 1;
int Iclock = 0;
backface(Ibcface);
backfacedir(Iclock);
const int npoints = 4;
float points[npoints-1][3];
for(int j=1;j<=nc;j++)
{
points[0][0] = xd[j][1];
points[0][1] = yd[j][1];
points[0][2] = zd[j][1];
points[1][0] = xd[j][2];
points[1][1] = yd[j][2];
points[1][2] = zd[j][2];
points[2][0] = xd[j][3];
points[2][1] = yd[j][3];
points[2][2] = zd[j][3];
points[3][0] = xd[j][1];
points[3][1] = yd[j][1];
points[3][2] = zd[j][1];
color (CYAN); // paint the elements
bool fill = true;
polyfill (fill);
poly (npoints,points);
color (lnc); // draw the element contours
fill = false;
polyfill (fill);
poly (npoints,points);
}
Function obj3dtrans is a straightforward modification of function
obj3dtransdesigned to handle element instead of line data.