home *** CD-ROM | disk | FTP | other *** search
/ Cutting-Edge 3D Game Programming with C++ / CE3DC++.ISO / BOOK / CHAP14 / POLYOBJ.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-14  |  2.8 KB  |  90 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 RadiusXY, RadiusXZ, 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 MoveText ( int Ox, int Oy, int Tx, int Ty );
  70.   void NexText () // Selects the next texture
  71.      {
  72.      if ( ( Select >= 0 ) && ( Select < PCount ) )
  73.         PList [ Select ].NexText ();
  74.      }
  75.   void RotText () // Rotates the selected panel's texture
  76.      {
  77.      if ( ( Select >= 0 ) && ( Select < PCount ) )
  78.         PList [ Select ].RotText ();
  79.      }
  80.   void NextInten ( int Sx, int Sy ); // Selects the next 
  81.                                      // intensity
  82.   int MorphTo ( char *FileName, float Steps );
  83.   void MorphStop () { StartMorph = 0; }
  84.   void MorphStart () { StartMorph = 1; }
  85.   void MorphRev ();
  86.  
  87.   int Collide ( float &X, float &Y, float &Z, float Rad );
  88. };
  89.  
  90. #endif