aiMatrix4x4.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /** @file 4x4 matrix structure, including operators when compiling in C++ */
  2. #ifndef AI_MATRIX4X4_H_INC
  3. #define AI_MATRIX4X4_H_INC
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. struct aiMatrix3x3;
  8. // Set packing to 4
  9. #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
  10. #pragma pack(push,4)
  11. #define PACK_STRUCT
  12. #elif defined( __GNUC__ )
  13. #define PACK_STRUCT __attribute__((packed))
  14. #else
  15. #error Compiler not supported
  16. #endif
  17. // ---------------------------------------------------------------------------
  18. /** Represents a column-major 4x4 matrix,
  19. * use this for homogenious coordinates
  20. */
  21. // ---------------------------------------------------------------------------
  22. typedef struct aiMatrix4x4
  23. {
  24. #ifdef __cplusplus
  25. aiMatrix4x4 () :
  26. a1(1.0f), a2(0.0f), a3(0.0f), a4(0.0f),
  27. b1(0.0f), b2(1.0f), b3(0.0f), b4(0.0f),
  28. c1(0.0f), c2(0.0f), c3(1.0f), c4(0.0f),
  29. d1(0.0f), d2(0.0f), d3(0.0f), d4(1.0f){}
  30. aiMatrix4x4 ( float _a1, float _a2, float _a3, float _a4,
  31. float _b1, float _b2, float _b3, float _b4,
  32. float _c1, float _c2, float _c3, float _c4,
  33. float _d1, float _d2, float _d3, float _d4) :
  34. a1(_a1), a2(_a2), a3(_a3), a4(_a4),
  35. b1(_b1), b2(_b2), b3(_b3), b4(_b4),
  36. c1(_c1), c2(_c2), c3(_c3), c4(_c4),
  37. d1(_d1), d2(_d2), d3(_d3), d4(_d4)
  38. {}
  39. /** Constructor from 3x3 matrix. The remaining elements are set to identity. */
  40. explicit aiMatrix4x4( const aiMatrix3x3& m);
  41. aiMatrix4x4& operator *= (const aiMatrix4x4& m);
  42. aiMatrix4x4 operator* (const aiMatrix4x4& m) const;
  43. aiMatrix4x4& Transpose();
  44. aiMatrix4x4& Inverse();
  45. float Determinant() const;
  46. float* operator[](unsigned int p_iIndex);
  47. const float* operator[](unsigned int p_iIndex) const;
  48. #endif // __cplusplus
  49. float a1, a2, a3, a4;
  50. float b1, b2, b3, b4;
  51. float c1, c2, c3, c4;
  52. float d1, d2, d3, d4;
  53. } PACK_STRUCT aiMatrix4x4_t;
  54. // Reset packing
  55. #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
  56. #pragma pack( pop )
  57. #endif
  58. #undef PACK_STRUCT
  59. #ifdef __cplusplus
  60. } // end extern "C"
  61. #endif // __cplusplus
  62. #endif // AI_MATRIX4X4_H_INC