/* Transforme un polygone convexe Poly (qui a PolyLength points), en faisant la transformation selon Xform (qui représente généralement une transformation de l'espace objet en passant par l'espace monde à l'espace de visualisation), puis projette le polygone transformé sur l'écran et l'affiche dans la couleur Color. Met à jour le rectangle avec EraseRect, qui sera utilisée ultérieurement pour effacer l'écran. Testé avec Borland C++ 4.02 en modèle small par Jim Mischel 12/16/94. */ #include "polygon.h" void XformAndProjectPoly(double Xform[4][4], struct Point3 * Poly, int PolyLength, int Color) { int i; struct Point3 XformedPoly[MAX_POLY_LENGTH]; struct Point ProjectedPoly[MAX_POLY_LENGTH]; struct PointListHeader Polygon; /* Transformation dans l'espace de visualisation, puis projection à l'écran */ for (i=0; i EraseRect[NonDisplayedPage].Right) if (ProjectedPoly[i].X < SCREEN_WIDTH) EraseRect[NonDisplayedPage].Right = ProjectedPoly[i].X; else EraseRect[NonDisplayedPage].Right = SCREEN_WIDTH; if (ProjectedPoly[i].Y > EraseRect[NonDisplayedPage].Bottom) if (ProjectedPoly[i].Y < SCREEN_HEIGHT) EraseRect[NonDisplayedPage].Bottom = ProjectedPoly[i].Y; else EraseRect[NonDisplayedPage].Bottom = SCREEN_HEIGHT; if (ProjectedPoly[i].X < EraseRect[NonDisplayedPage].Left) if (ProjectedPoly[i].X > 0) EraseRect[NonDisplayedPage].Left = ProjectedPoly[i].X; else EraseRect[NonDisplayedPage].Left = 0; if (ProjectedPoly[i].Y < EraseRect[NonDisplayedPage].Top) if (ProjectedPoly[i].Y > 0) EraseRect[NonDisplayedPage].Top = ProjectedPoly[i].Y; else EraseRect[NonDisplayedPage].Top = 0; } /* Affiche le polygone */ DRAW_POLYGON(ProjectedPoly, PolyLength, Color, 0, 0); }