Main Page | Class Hierarchy | 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 NscPnt* poly;
00091 
00094   static int sizepoly;
00095 
00098   static int npolyverts;
00099 
00102   static Edge* poly_edge;
00103 
00106   static Pixel* scanline_vtx;
00107 
00110   static long int curr_color;
00111 
00113   static int cv_width;
00114 
00116   static int cv_height;
00117 
00118 /* Memory for z-buffer */
00119   static unsigned int* zbuff;
00120 
00121  private:
00122 /*
00123 ** ---------------------------------------------------------------
00124 ** Private class functions:
00125 */
00126 /* --------------------------------------------------------------- */
00129   static inline double MAX( double a, double b )
00130   {
00131    return( (a > b) ? a : b );
00132   }
00133 
00134 /* --------------------------------------------------------------- */
00137   static inline double MIN( double a, double b )
00138   {
00139    return( (a < b) ? a : b );
00140   }
00141 
00142 /* --------------------------------------------------------------- */
00160   static void NSCtoRaster( double xnsc, double ynsc, double znsc,
00161                            int* xr, int* yr, unsigned int* zr );
00162 
00163 /* --------------------------------------------------------------- */
00168   static void OrderIntersections( Pixel* vtx, int left, int right );
00169 
00170 /* --------------------------------------------------------------- */
00178   static void ScanLine( Pixel* vtx_lft, Pixel* vtx_rgt, int ys );
00179 
00180 /* --------------------------------------------------------------- */
00184   static int MountEdges( Edge* edge, int* ymin, int* ymax,
00185                          int npoints, NscPnt* poly );
00186 
00187 /* --------------------------------------------------------------- */
00191   static int MountInt( Pixel* vtx, Edge* edge, int* nedges, int ys );
00192 
00193 /* --------------------------------------------------------------- */
00201   static void FillPoly( int npoints, NscPnt* poly );
00202 
00203 /* --------------------------------------------------------------- */
00207   static void Release( void );
00208 
00209 /* --------------------------------------------------------------- */
00213   static int Alloc( void  );
00214 
00215  public:
00216 /*
00217 ** ---------------------------------------------------------------
00218 ** Public class functions:
00219 */
00220 /* --------------------------------------------------------------- */
00229   static int Init( int width, int height );
00230 
00231 /* --------------------------------------------------------------- */
00236   static void Close( void );
00237 
00238 /* --------------------------------------------------------------- */
00246   static void BeginPoly( long int color );
00247 
00248 /* --------------------------------------------------------------- */
00260   static void Vertex( double x, double y, double z );
00261 
00262 /* --------------------------------------------------------------- */
00268   static void EndPoly( void );
00269 
00270 };
00271 
00274 #endif

Generated on Mon Jun 21 12:45:12 2010 for Trab4 by  doxygen 1.4.2-20050421