home *** CD-ROM | disk | FTP | other *** search
/ Cutting-Edge 3D Game Programming with C++ / CE3DC++.ISO / BOOK / CHAP12 / POLYOBJ.HPP < prev    next >
C/C++ Source or Header  |  1996-01-24  |  3KB  |  91 lines

  1. //
  2. // File name: PolyObj.HPP
  3. //
  4. // Description: Header file for a panel object class
  5. //
  6. // Author: John De Goes
  7. //
  8. // Project: Cutting Edge 3D Game Programming
  9. //
  10.  
  11. #ifndef POLYOBJHPP
  12. #define POLYOBJHPP
  13.  
  14. #include "Matrix3D.HPP"
  15. #include "Point3D.HPP"
  16. #include "ATypes.HPP"
  17. #include "Panel3D.HPP"
  18.  
  19. // An object made of panels:
  20. class PanelObject {
  21.   Point3D *TList;     // Temporary vertex list (used for loading)
  22.   Point3D *MList;     // The morphing list
  23.  
  24. protected:            // Data is protected
  25.   void CalcRadius (); // Calculates radius of object
  26.   void Transform ( Matrix3D &M );      // Transforms vertex list
  27.   Point3D LoadCoord ( FILE *InFile );  // Loads a coordinate
  28.   DWORD CountPanels ( char *FileName );// Counts 3DFACEs
  29.   WORD LoadVerts ( char *FileName );   // Loads vertex list
  30.   WORD LoadPanelData ();               // Loads panel data
  31.   WORD LoadPanel ( int &VIndex, int Index ); // Loads a panel
  32. public:                                // Data is public
  33.   Point3D  *VList; // The list of vertices
  34.   Panel3D *PList;  // The list of panels
  35.   DWORD   VCount,  // The vertex count
  36.           PCount;  // The panel count
  37.   WORD Visible,    // A visible flag
  38.        Morph,      // A morphing flag
  39.        StartMorph;
  40.   long Select;
  41.   float Radius;    // The object's radius
  42.   PanelObject () // Constructor
  43.     {
  44.     Morph = 0;
  45.     StartMorph = 1;
  46.     Select = -1;
  47.     VCount = PCount = 0;
  48.     }
  49.   ~PanelObject () // Destructor
  50.     {
  51.     if ( VList )
  52.        delete [] VList;
  53.     if ( PList )
  54.        delete [] PList;
  55.     if ( Morph )
  56.        delete [] MList;
  57.     }
  58.  
  59.   void Display ( Matrix3D &M, unsigned char *Buffer ); // Displays object
  60.   void LoadDXF ( char *FileName );  // Loads DXF files
  61.   void WriteBIN ( char *FileName ); // Writes BIN files
  62.   void ReadBIN ( char *FileName );  // Reads BIN files
  63.  
  64.   int ReadText ( char *FileName );  // Loads textures/data
  65.   int WriteText ( char *FileName ); // Writes textures/data
  66.  
  67.   void InitDefText (); // Initializes default texture/shade 
  68.                        // coords
  69.   void SelNext ();     // Selects the next visible polygon
  70.   void MoveText ( int Ox, int Oy, int Tx, int Ty );
  71.   void NexText () // Selects the next texture
  72.      {
  73.      if ( ( Select >= 0 ) && ( Select < PCount ) )
  74.         PList [ Select ].NexText ();
  75.      }
  76.   void RotText () // Rotates the selected panel's texture
  77.      {
  78.      if ( ( Select >= 0 ) && ( Select < PCount ) )
  79.         PList [ Select ].RotText ();
  80.      }
  81.   void NextInten ( int Sx, int Sy ); // Selects the next 
  82.                                      // intensity
  83.   int MorphTo ( char *FileName, float Steps );
  84.   void MorphStop () { StartMorph = 0; }
  85.   void MorphStart () { StartMorph = 1; }
  86.   void MorphRev ();
  87.  
  88.   int Collide ( float &X, float &Y, float &Z, float Rad );
  89. };
  90.  
  91. #endif