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

  1. //
  2. // File name: Matrix3D.HPP
  3. //
  4. // Description: The header file a 3D "view" matrix
  5. //
  6. // Author: John De Goes
  7. //
  8. // Project: Cutting Edge 3D Game Programming
  9. //
  10.  
  11. #ifndef MATRIX3DHPP
  12. #define MATRIX3DHPP
  13.  
  14. #include "Point3D.HPP"
  15. #include "Vector3D.HPP"
  16. #include "SinCos.HPP"
  17.  
  18. void InitMath ();
  19.  
  20. // The 3D view matrix class:
  21. class Matrix3D {
  22. protected:
  23.   void InitMat ( float Mat [ 4 ] [ 4 ] );
  24.   void MergeMatrix ( float NewMatrix [ 4 ] [ 4 ] );
  25.   void MergeMatrices ( float Dest [ 4 ] [ 4 ], float Source [ 4 ] [ 4 ] );
  26.   float Matrix [ 4 ] [ 4 ];
  27.   float RMatrix [ 4 ] [ 4 ];
  28.   int Xr, Zr, Yr;
  29.   float XTrans, YTrans, ZTrans;
  30. public:
  31.   Matrix3D ()
  32.      {
  33.      InitMath ();
  34.      Zr = Yr = Zr = 0;
  35.      XTrans = YTrans = ZTrans = 0.0F;
  36.      Initialize ();
  37.      }
  38.   void Rotate ( int Xa, int Ya, int Za );
  39.   void Translate ( float Xt, float Yt, float Zt );
  40.   void Scale ( float Xs, float Ys, float Zs );
  41.   void Shear ( float Xs, float Ys );
  42.   void Initialize ();
  43.   Point3D &Transform ( Point3D &V );
  44.   Point3D &Untransform ( Point3D &V );
  45.   Vector inline &Transform ( Vector &V );
  46.   float GetXt () { return XTrans; }
  47.   float GetYt () { return YTrans; }
  48.   float GetZt () { return ZTrans; }
  49. };
  50.  
  51. #endif