home *** CD-ROM | disk | FTP | other *** search
/ Cutting-Edge 3D Game Programming with C++ / CE3DC++.ISO / BOOK / CHAP08 / PANEL3D.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-19  |  2.4 KB  |  74 lines

  1. //
  2. // File name: Panel3D.HPP
  3. //
  4. // Description: Header file for a 3D panel class
  5. //
  6. // Author: John De Goes
  7. //
  8. // Project: Cutting Edge 3D Game Programming
  9. //
  10.  
  11. #ifndef PANEL3DHPP
  12. #define PANEL3DHPP
  13.  
  14. #include "Point3D.HPP"
  15. #include "Point2D.HPP"
  16. #include "Vector3D.HPP"
  17. #include "ATypes.HPP"
  18. #include "Matrix3D.HPP"
  19.  
  20. #include <Dos.H>
  21.  
  22. // Forward declaration:
  23. class PanelObject;
  24.  
  25. // The panel class:
  26. class Panel3D {
  27. protected:                 // Data is protected
  28.   // Functions:
  29.   void CalcRadius ();      // Calculates panel radius
  30.   long CalcCenterZ ();     // Calculates center Z  
  31.   int inline CalcBFace (); // Determines if panel is backface
  32.   void CalcNormal ();      // Calculates the panel normal
  33.   int CheckExtents ();     // Determines if panel lies within
  34.                            // the Z extents
  35.   int CalcVisible3D ();    // Determines panel's visibility 
  36.                            // in 3D
  37.   int CalcVisible2D ();    // Determines panel's visibility
  38.                            // in 2D
  39.   // Data:
  40.   Point3D *VPoint [ 4 ];   // 4 pointers to a vertex list
  41.   Point2D SPoint [ 5 ];    // Maximum of 5 on-screen points
  42.   Vector Normal;           // The panel normal
  43.   WORD SPCount, Invis;     // Screen point count & invisible flag
  44.   BYTE Color, Padding;     // The panel's color
  45.   double Radius;           // The panel's radius
  46. public:                    // Data is public
  47.   Panel3D () { Invis = 0; Color = 0; }  // Constructor:
  48.   void Update ( Matrix3D &M );          // Update normal and misc. information
  49.   void Display ( unsigned char *Dest ); // Rasterize panel
  50.   void Project ();                      // Project panel onto screen
  51.   void InitPosition () { CalcNormal (); CalcRadius (); } // Performs initialization
  52.   void CalcInten ();                    // Calculates panel's intensity
  53.   int Invisible () { return Invis; }    // Determine invisibility
  54.   int IsVisible2D () { return CalcVisible2D (); } // Determine visibility in 3D
  55.   int IsVisible3D () { return CalcVisible3D (); } // Determine visibility in 2D
  56.   
  57.   friend class PanelObject;   // Declare a friend class
  58.  
  59.   int HasVert ( Point3D &P )
  60.     {
  61.     if ( ( *VPoint [ 0 ] ) == P )
  62.        return 1;
  63.     if ( ( *VPoint [ 1 ] ) == P )
  64.        return 1;
  65.     if ( ( *VPoint [ 2 ] ) == P )
  66.        return 1;
  67.     if ( ( *VPoint [ 3 ] ) == P )
  68.        return 1;
  69.     return 0;
  70.     }
  71. };
  72.  
  73. #endif
  74.