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

dsp.h

Go to the documentation of this file.
00001 /*
00002 ** ---------------------------------------------------------------
00003 ** dsp.h -  Display class definition.
00004 **
00005 ** ---------------------------------------------------------------
00006 */
00007 
00008 #ifndef _DSP_H
00009 #define _DSP_H
00010 
00011 
00036 /*
00037 ** ---------------------------------------------------------------
00038 ** Used global definitions:
00039 */
00040 #include <math.h>
00041 #include "prm.h"
00042 
00043 class Dsp
00044 {
00045  private:
00046 /*
00047 ** ---------------------------------------------------------------
00048 ** Private data type definitions:
00049 */
00050 
00053   struct Vec {
00055     double    x;
00057     double    y;
00059     double    z;
00060    };
00061 
00062  private:
00063 /*
00064 ** ---------------------------------------------------------------
00065 ** Private class variables and constants:
00066 **
00067 */
00070   static double MIN_COLOR_INTENS;
00071 
00074   static Vec view_vector;
00075 
00078   static char* help_cmd[];
00079 
00082   static char* help_msg[];
00083 
00086   static int font_list_base;
00087 
00088  private:
00089 /*
00090 ** ---------------------------------------------------------------
00091 ** Private class functions:
00092 */
00093 /* --------------------------------------------------------------- */
00102   static inline double get_red( long int color )   
00103   {
00104    return( (double)(((color) >> 16) & 0xff) / 255.0 );
00105   }
00106 
00107 /* --------------------------------------------------------------- */
00116   static inline double get_green( long int color )   
00117   {
00118    return( (double)(((color) >>  8) & 0xff) / 255.0 );
00119   }
00120 
00121 /* --------------------------------------------------------------- */
00130   static inline double get_blue( long int color )   
00131   {
00132    return( (double)(((color) >>  0) & 0xff) / 255.0 );
00133   }
00134 
00135 /* --------------------------------------------------------------- */
00141   static inline void VecUnit( Vec* a, Vec* b )
00142   {
00143    double len = sqrt(a->x*a->x + a->y*a->y + a->z*a->z);
00144 
00145    if( len != 0.0 )
00146    {
00147     b->x = a->x / len;
00148     b->y = a->y / len;
00149     b->z = a->z / len;
00150    }
00151   }
00152 
00153 /* --------------------------------------------------------------- */
00161   static inline double VecDot( Vec* a, Vec* b )
00162   {
00163    return( a->x*b->x + a->y*b->y + a->z*b->z );
00164   }
00165 
00166 /* --------------------------------------------------------------- */
00175   static inline void DecodeColor( long int color,
00176                                   unsigned char* red,
00177                                   unsigned char* green,
00178                                   unsigned char* blue )
00179   {
00180    *red   = (unsigned char)(((color) >> 16) & 0xff);
00181    *green = (unsigned char)(((color) >>  8) & 0xff);
00182    *blue  = (unsigned char)(((color) >>  0) & 0xff);
00183   }
00184 
00185 /* --------------------------------------------------------------- */
00196   static inline long int EncodeColor( unsigned char red,
00197                                       unsigned char green,
00198                                       unsigned char blue )
00199   {
00200    return( ((unsigned long)(red)   << 16) |
00201            ((unsigned long)(green) <<  8) |
00202            ((unsigned long)(blue)  <<  0) );
00203   }
00204 
00205 /* --------------------------------------------------------------- */
00216   static long int ShadeColor( Vec* normal, Vec* view, long int color );
00217 
00218 /* --------------------------------------------------------------- */
00224   static void InvertMatrix( double mt[4][4], double imt[4][4] );
00225 
00226 /* --------------------------------------------------------------- */
00234   static void GetCamera( double* eyex, double* eyey, double* eyez,
00235                          double* refx, double* refy, double* refz,
00236                          double* vupx, double* vupy, double* vupz );
00237 
00238 /* --------------------------------------------------------------- */
00299   static int GetViewVolume( double* left,   double* right,
00300                             double* bottom, double* top,
00301                             double* front,  double* back );
00302 
00303 /* --------------------------------------------------------------- */
00311   static void DisplayPrm( Prm* prm );
00312 
00313 /* --------------------------------------------------------------- */
00322   static void HighltPrm( Prm* prm );
00323 
00324  public:
00325 /*
00326 ** ---------------------------------------------------------------
00327 ** Public class functions:
00328 **
00329 */
00330 /* --------------------------------------------------------------- */
00335   static void Init( void );
00336 
00337 /* --------------------------------------------------------------- */
00342   static void Help( void );
00343 
00344 /* --------------------------------------------------------------- */
00349   static void Model( void );
00350 
00351 /* --------------------------------------------------------------- */
00352 /*
00353 ** This function displays all primitives of current model in 
00354 ** the given canvas using the z-buffer algorithm and the CD
00355 ** (Canvas Draw) 2D graphics system).
00356 **
00357 **  @param zbuffer_canvas - CD handle to zbuffer canvas       (in)
00358 */
00359   static int ZbfModel( void* zbuffer_canvas );
00360 
00361 /* --------------------------------------------------------------- */
00374   static void ZbfBeginPoly( long int color, double nx, double ny, double nz );
00375 
00376 /* --------------------------------------------------------------- */
00387   static void ZbfVertex( double x, double y, double z );
00388 
00389 /* --------------------------------------------------------------- */
00394   static void ZbfEndPoly( void );
00395 
00396 /* --------------------------------------------------------------- */
00413   static void GetPickRay( int x, int y,
00414                           double* frontx, double* fronty, double* frontz,
00415                           double* backx,  double* backy,  double* backz );
00416 
00417 };
00418 
00421 #endif

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