00001
00002
00003
00004
00005
00006
00007
00008 #ifndef _DSP_H
00009 #define _DSP_H
00010
00011
00028
00029
00030
00031
00032 #include <math.h>
00033
00034 class Dsp
00035 {
00036 private:
00037
00038
00039
00040
00041
00044 struct Vec {
00046 double x;
00048 double y;
00050 double z;
00051 };
00052
00053
00054
00055
00056
00057
00060 static double MIN_COLOR_INTENS;
00061
00064 static int FRAMES;
00065
00068 static double M_PI;
00069
00072 static double alpha;
00073
00076 static double delta;
00077
00080 static Vec view_vector;
00081
00084 static Vec box[8];
00085
00088 static double xmin, xmax, ymin, ymax, zmin, zmax;
00089
00092 static double eyex, eyey, eyez;
00093
00096 static double refx, refy, refz;
00097
00100 static double vupx, vupy, vupz;
00101
00104 static double left, right, bottom, top, front, back;
00105
00106
00107
00108
00109
00110
00119 static inline double get_red( long int color )
00120 {
00121 return( (double)(((color) >> 16) & 0xff) / 255.0 );
00122 }
00123
00124
00133 static inline double get_green( long int color )
00134 {
00135 return( (double)(((color) >> 8) & 0xff) / 255.0 );
00136 }
00137
00138
00147 static inline double get_blue( long int color )
00148 {
00149 return( (double)(((color) >> 0) & 0xff) / 255.0 );
00150 }
00151
00152
00158 static inline void VecUnit( Vec* a, Vec* b )
00159 {
00160 double len = sqrt(a->x*a->x + a->y*a->y + a->z*a->z);
00161
00162 if( len != 0.0 )
00163 {
00164 b->x = a->x / len;
00165 b->y = a->y / len;
00166 b->z = a->z / len;
00167 }
00168 }
00169
00170
00178 static inline double VecDot( Vec* a, Vec* b )
00179 {
00180 return( a->x*b->x + a->y*b->y + a->z*b->z );
00181 }
00182
00183
00192 static inline void DecodeColor( long int color,
00193 unsigned char* red,
00194 unsigned char* green,
00195 unsigned char* blue )
00196 {
00197 *red = (unsigned char)(((color) >> 16) & 0xff);
00198 *green = (unsigned char)(((color) >> 8) & 0xff);
00199 *blue = (unsigned char)(((color) >> 0) & 0xff);
00200 }
00201
00202
00213 static inline long int EncodeColor( unsigned char red,
00214 unsigned char green,
00215 unsigned char blue )
00216 {
00217 return( ((unsigned long)(red) << 16) |
00218 ((unsigned long)(green) << 8) |
00219 ((unsigned long)(blue) << 0) );
00220 }
00221
00222
00233 static long int ShadeColor( Vec* normal, Vec* view, long int color );
00234
00235
00238 static inline double MAX( double a, double b )
00239 {
00240 return( (a > b) ? a : b );
00241 }
00242
00243
00249 static void DisplaySolid( void );
00250
00251
00264 static void ZbfBeginPoly( long int color, double nx, double ny, double nz );
00265
00266
00277 static void ZbfVertex( double x, double y, double z );
00278
00279
00284 static void ZbfEndPoly( void );
00285
00286 public:
00287
00288
00289
00290
00291
00292
00300 static void SetupView( cdCanvas* zbuffer_canvas );
00301
00302
00307 static void RotateView( void );
00308
00309
00310
00311
00312
00313
00314
00315
00316 static void ZbfModel( cdCanvas* zbuffer_canvas );
00317
00318 };
00319
00322 #endif