Main Page | Alphabetical List | Class List | File List | Class Members | File Members

zbf.h

Go to the documentation of this file.
00001 /*
00002 ** ---------------------------------------------------------------
00003 ** zbf.h -  Definition of class to fill polygons in raster (image) 
00004 **          coordinates using the z-buffer algorithm.
00005 */
00006 
00007 #ifndef _ZBF_H
00008 #define _ZBF_H
00009 
00037 class Zbf
00038 {
00039  private:
00040 /*
00041 ** ---------------------------------------------------------------
00042 ** Private data type definitions:
00043 */
00044 
00047   struct NscPnt {
00049     double    x;
00051     double    y;
00053     double    z;
00054    };
00055 
00058   struct Edge {
00060     int    y_max;
00062     int    y_min;
00064     double xs;
00066     double dxs;
00068     double zs;
00070     double dzs;
00071    };
00072 
00075   struct Pixel {
00077     int    x;
00079     double z;
00080    };
00081 
00082  private:
00083 /*
00084 ** ---------------------------------------------------------------
00085 ** Private class variables and constants:
00086 **
00087 */
00090   static cdCanvas* canvas;
00091 
00094   static NscPnt* poly;
00095 
00098   static int sizepoly;
00099 
00102   static int npolyverts;
00103 
00106   static Edge* poly_edge;
00107 
00110   static Pixel* scanline_vtx;
00111 
00114   static long int curr_color;
00115 
00117   static int cv_width;
00118 
00120   static int cv_height;
00121 
00122 /* Memory for z-buffer */
00123   static unsigned int* zbuff;
00124 
00125  private:
00126 /*
00127 ** ---------------------------------------------------------------
00128 ** Private class functions:
00129 */
00130 /* --------------------------------------------------------------- */
00133   static inline int MAX( int a, int b )
00134   {
00135    return( (a > b) ? a : b );
00136   }
00137 
00138 /* --------------------------------------------------------------- */
00141   static inline int MIN( int a, int b )
00142   {
00143    return( (a < b) ? a : b );
00144   }
00145 
00146 /* --------------------------------------------------------------- */
00164   static void NSCtoRaster( double xnsc, double ynsc, double znsc,
00165                            int* xr, int* yr, unsigned int* zr );
00166 
00167 /* --------------------------------------------------------------- */
00172   static void OrderIntersections( Pixel* vtx, int left, int right );
00173 
00174 /* --------------------------------------------------------------- */
00182   static void ScanLine( Pixel* vtx_lft, Pixel* vtx_rgt, int ys );
00183 
00184 /* --------------------------------------------------------------- */
00188   static int MountEdges( Edge* edge, int* ymin, int* ymax,
00189                          int npoints, NscPnt* poly );
00190 
00191 /* --------------------------------------------------------------- */
00195   static int MountInt( Pixel* vtx, Edge* edge, int* nedges, int ys );
00196 
00197 /* --------------------------------------------------------------- */
00205   static void FillPoly( int npoints, NscPnt* poly );
00206 
00207 /* --------------------------------------------------------------- */
00211   static void Release( void );
00212 
00213 /* --------------------------------------------------------------- */
00217   static int Alloc( void  );
00218 
00219  public:
00220 /*
00221 ** ---------------------------------------------------------------
00222 ** Public class functions:
00223 */
00224 /* --------------------------------------------------------------- */
00233   static int Init( cdCanvas* cv );
00234 
00235 /* --------------------------------------------------------------- */
00240   static void Close( void );
00241 
00242 /* --------------------------------------------------------------- */
00250   static void BeginPoly( long int color );
00251 
00252 /* --------------------------------------------------------------- */
00264   static void Vertex( double x, double y, double z );
00265 
00266 /* --------------------------------------------------------------- */
00272   static void EndPoly( void );
00273 
00274 };
00275 
00278 #endif

Generated on Mon Jun 20 18:09:52 2011 for Trab8 by  doxygen 1.4.2-20050421