/* Draws all visible faces (faces pointing toward the viewer) in the specified object. The object must have previously been transformed and projected, so that the ScreenVertexList array is filled in. */ #include "polygon.h" void DrawVisibleFaces(struct Object * ObjectToXform) { int i, j, NumFaces = ObjectToXform->NumFaces, NumVertices; int * VertNumsPtr; struct Face * FacePtr = ObjectToXform->FaceList; struct Point * ScreenPoints = ObjectToXform->ScreenVertexList; long v1,v2,w1,w2; struct Point Vertices[MAX_POLY_LENGTH]; struct PointListHeader Polygon; /* Draw each visible face (polygon) of the object in turn */ for (i=0; iNumVerts; /* Copy over the face's vertices from the vertex list */ for (j=0, VertNumsPtr=FacePtr->VertNums; j 0) { /* It is facing the screen, so draw */ /* Appropriately adjust the extent of the rectangle used to erase this page later */ for (j=0; j EraseRect[NonDisplayedPage].Right) if (Vertices[j].X < SCREEN_WIDTH) EraseRect[NonDisplayedPage].Right = Vertices[j].X; else EraseRect[NonDisplayedPage].Right = SCREEN_WIDTH; if (Vertices[j].Y > EraseRect[NonDisplayedPage].Bottom) if (Vertices[j].Y < SCREEN_HEIGHT) EraseRect[NonDisplayedPage].Bottom = Vertices[j].Y; else EraseRect[NonDisplayedPage].Bottom=SCREEN_HEIGHT; if (Vertices[j].X < EraseRect[NonDisplayedPage].Left) if (Vertices[j].X > 0) EraseRect[NonDisplayedPage].Left = Vertices[j].X; else EraseRect[NonDisplayedPage].Left = 0; if (Vertices[j].Y < EraseRect[NonDisplayedPage].Top) if (Vertices[j].Y > 0) EraseRect[NonDisplayedPage].Top = Vertices[j].Y; else EraseRect[NonDisplayedPage].Top = 0; } /* Draw the polygon */ DRAW_POLYGON(Vertices, NumVertices, FacePtr->Color, 0, 0); } } }