home *** CD-ROM | disk | FTP | other *** search
/ Cutting-Edge 3D Game Programming with C++ / CE3DC++.ISO / BOOK / CHAP09 / PANEL3D.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-17  |  2.4 KB  |  76 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 "PolyEdge.HPP"
  19. #include "Matrix3D.HPP"
  20.  
  21. #include <Dos.H>
  22.  
  23. // Forward declaration:
  24. class PanelObject;
  25.  
  26. // The panel class:
  27. class Panel3D {
  28. protected:                 // Data is protected
  29.   // Functions:
  30.   void CalcRadius ();      // Calculates panel radius
  31.   long CalcCenterZ ();     // Calculates center Z  
  32.   int inline CalcBFace (); // Determines if panel is backface
  33.   void CalcNormal ();      // Calculates the panel normal
  34.   int CheckExtents ();     // Determines if panel lies within
  35.                            // the Z extents
  36.   int CalcVisible3D ();    // Determines panel's visibility 
  37.                            // in 3D
  38.   int CalcVisible2D ();    // Determines panel's visibility
  39.                            // in 2D
  40.   // Data:
  41.   Point3D *VPoint [ 4 ];   // 4 pointers to a vertex list
  42.   Point2D SPoint [ 5 ];    // Maximum of 5 on-screen points
  43.   WORD Inten [ 4 ];
  44.   Vector Normal;           // The panel normal
  45.   WORD SPCount, Invis;     // Screen point count & invisible flag
  46.   BYTE Color, Padding;     // The panel color
  47.   double Radius;           // The panel's radius
  48. public:                    // Data is public
  49.   Panel3D () { Invis = 0; Color = 0; }  // Constructor:
  50.   void Update ( Matrix3D &M );          // Update normal and misc. information
  51.   void Display ( unsigned char *Dest ); // Rasterize panel
  52.   void Project ();                      // Project panel onto screen
  53.   void InitPosition () { CalcNormal (); CalcRadius (); } // Performs initialization
  54.   void CalcInten ();                    // Calculates panel's intensity
  55.   int Invisible () { return Invis; }    // Determine invisibility
  56.   int IsVisible2D () { return CalcVisible2D (); } // Determine visibility in 3D
  57.   int IsVisible3D () { return CalcVisible3D (); } // Determine visibility in 2D
  58.   
  59.   friend class PanelObject;   // Declare a friend class
  60.  
  61.   int HasVert ( Point3D &P )
  62.     {
  63.     if ( ( *VPoint [ 0 ] ) == P )
  64.        return 1;
  65.     if ( ( *VPoint [ 1 ] ) == P )
  66.        return 1;
  67.     if ( ( *VPoint [ 2 ] ) == P )
  68.        return 1;
  69.     if ( ( *VPoint [ 3 ] ) == P )
  70.        return 1;
  71.     return 0;
  72.     }
  73. };
  74.  
  75. #endif
  76.