home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Amiga / Jeux / demos / crystalPPC.lha / polyplan.h < prev    next >
C/C++ Source or Header  |  1998-01-15  |  2KB  |  70 lines

  1. #ifndef POLYPLANE_H
  2. #define POLYPLANE_H
  3.  
  4. #ifndef MATH3D_H
  5. #include "math3d.h"
  6. #endif
  7.  
  8. class Vertex;
  9.  
  10. // This class represents a texture plane. This is a plane
  11. // that defines the orientation and offset of a texture. It can
  12. // be used by several polygons to let the textures fit perfectly.
  13.  
  14. class PolyPlane
  15. {
  16.   friend class Polygon3D;
  17.   friend class Polygon2D;
  18.   friend class PolyTexture;
  19.  
  20. private:
  21.   char name[30];
  22.   PolyPlane* next, * prev;
  23.  
  24.   Matrix3 m_obj2tex;    // Transformation from object to texture space.
  25.   Vector3 v_obj2tex;    // Translation from object to texture space.
  26.  
  27.   Matrix3 m_world2tex;    // Transformation from world to texture space.
  28.   Vector3 v_world2tex;    // Translation from world to texture space.
  29.  
  30.   // Transformed texture space transformation. This transforms a
  31.   // coordinate from camera space to texture space. This transformation
  32.   // is obtained by using m_world2tex and v_world2tex with the camera transformation.
  33.   Matrix3 m_cam2tex;
  34.   Vector3 v_cam2tex;
  35.  
  36. public:
  37.   PolyPlane (char* name);
  38.   ~PolyPlane ();
  39.  
  40.   char* get_name () { return name; }
  41.   void set_next (PolyPlane* n) { next = n; }
  42.   void set_prev (PolyPlane* p) { prev = p; }
  43.   PolyPlane* get_next () { return next; }
  44.   PolyPlane* get_prev () { return prev; }
  45.  
  46.   void transform_world2cam (Matrix3& m_w2c, Matrix3& m_c2w, Vector3& v_w2c);
  47.   void object_to_world (Matrix3& m_o2w, Matrix3& m_w2o, Vector3& v_o2w);
  48.  
  49.   void set_texture_space (Vertex& v_orig,
  50.                 Vertex& v1, float len1,
  51.                 Vertex& v2, float len2);
  52.   void set_texture_space (float xo, float yo, float zo,
  53.               float x1, float y1, float z1, float len1,
  54.               float x2, float y2, float z2, float len2);
  55.   void set_texture_space (Vertex& v_orig, Vertex& v_u, Vertex& v_v);
  56.   void set_texture_space (float xo, float yo, float zo,
  57.                 float xu, float yu, float zu,
  58.                 float xv, float yv, float zv);
  59.   void set_texture_space (float xo, float yo, float zo,
  60.                 float xu, float yu, float zu,
  61.                 float xv, float yv, float zv,
  62.                 float xw, float yw, float zw);
  63.   void set_texture_space (Matrix3& tx_matrix, Vector3& tx_vector);
  64.  
  65.   void save (FILE* fp, int indent);
  66.   void load (char** buf);
  67. };
  68.  
  69. #endif /*POLYPLANE_H*/
  70.