void Scene::Polygon (short n, float *x, float *y, float *z, long color, short mode) { // check for valid range of vertices if (n < 3 || n > MaxVertices) Matpack.Error("Scene::Polygon: number of vertices (%d) not within 3..%d", n,MaxVertices); Scene scn; // local scene copying the original settings scn.CopySettingsFrom(*this); Facet& f = scn.AddFacet(n); // add one facet to our local scene for (int i = 0; i < n; i++) f(i) = &scn.AddVertex(x[i],y[i],z[i]); scn.ClipBoxScene(); // clip at box scn.ObserveFacets(); // do observer transformation scn.ClipViewScene(); // clip at viewport scn.ProjectFacets(); // do perspective projection Facet* cf; // find the clipped facet for (cf = scn.facets; cf && cf->clipped; cf = cf->next); if ( cf ) { // something left after clipping ? for (int i = 0; i < n; i++) // copy projected vertices to polygon array pix[i] = (*cf)[i].p; Polygon(n,pix,color,mode); // draw the facet within the original scene } }