aiTypes.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #ifndef AI_TYPES_H_INC
  2. #define AI_TYPES_H_INC
  3. #include <sys/types.h>
  4. #include <memory.h>
  5. #if (defined _MSC_VER)
  6. # include "Compiler/VisualStudio/stdint.h"
  7. #endif // (defined _MSC_VER)
  8. #include "aiVector3D.h"
  9. #include "aiMatrix3x3.h"
  10. #include "aiMatrix4x4.h"
  11. #include "aiVector3D.inl"
  12. #include "aiMatrix3x3.inl"
  13. #include "aiMatrix4x4.inl"
  14. #ifdef __cplusplus
  15. #include <string>
  16. extern "C" {
  17. #endif
  18. /** Maximum dimension for strings, ASSIMP strings are zero terminated */
  19. const size_t MAXLEN = 1024;
  20. // ---------------------------------------------------------------------------
  21. /** Represents a two-dimensional vector.
  22. */
  23. // ---------------------------------------------------------------------------
  24. typedef struct aiVector2D
  25. {
  26. #ifdef __cplusplus
  27. aiVector2D () : x(0.0f), y(0.0f) {}
  28. aiVector2D (float _x, float _y) : x(_x), y(_y) {}
  29. aiVector2D (const aiVector2D& o) : x(o.x), y(o.y) {}
  30. #endif // __cplusplus
  31. float x, y;
  32. } aiVector2D_t;
  33. // aiVector3D type moved to separate header due to size of operators
  34. // aiQuaternion type moved to separate header due to size of operators
  35. // aiMatrix4x4 type moved to separate header due to size of operators
  36. // ---------------------------------------------------------------------------
  37. /** Represents a color in Red-Green-Blue space.
  38. */
  39. // ---------------------------------------------------------------------------
  40. typedef struct aiColor3D
  41. {
  42. #ifdef __cplusplus
  43. aiColor3D () : r(0.0f), g(0.0f), b(0.0f) {}
  44. aiColor3D (float _r, float _g, float _b) : r(_r), g(_g), b(_b) {}
  45. aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {}
  46. #endif // __cplusplus
  47. float r, g, b;
  48. } aiColor3D_t;
  49. // ---------------------------------------------------------------------------
  50. /** Represents a color in Red-Green-Blue space including an
  51. * alpha component.
  52. */
  53. // ---------------------------------------------------------------------------
  54. typedef struct aiColor4D
  55. {
  56. #ifdef __cplusplus
  57. aiColor4D () : r(0.0f), g(0.0f), b(0.0f), a(0.0f) {}
  58. aiColor4D (float _r, float _g, float _b, float _a)
  59. : r(_r), g(_g), b(_b), a(_a) {}
  60. aiColor4D (const aiColor4D& o)
  61. : r(o.r), g(o.g), b(o.b), a(o.a) {}
  62. #endif // __cplusplus
  63. float r, g, b, a;
  64. } aiColor4D_t;
  65. // ---------------------------------------------------------------------------
  66. /** Represents a string, zero byte terminated
  67. */
  68. // ---------------------------------------------------------------------------
  69. typedef struct aiString
  70. {
  71. #ifdef __cplusplus
  72. inline aiString() :
  73. length(0)
  74. {
  75. // empty
  76. }
  77. inline aiString(const aiString& rOther) :
  78. length(rOther.length)
  79. {
  80. memcpy( data, rOther.data, rOther.length);
  81. this->data[this->length] = '\0';
  82. }
  83. void Set( const std::string& pString)
  84. {
  85. if( pString.length() > MAXLEN - 1)
  86. return;
  87. length = pString.length();
  88. memcpy( data, pString.c_str(), length);
  89. data[length] = 0;
  90. }
  91. #endif // __cplusplus
  92. size_t length;
  93. char data[MAXLEN];
  94. } aiString_t;
  95. // ---------------------------------------------------------------------------
  96. /** Standard return type for all library functions.
  97. *
  98. * To check whether a function failed or not check against
  99. * AI_SUCCESS.
  100. */
  101. // ---------------------------------------------------------------------------
  102. enum aiReturn
  103. {
  104. AI_SUCCESS = 0x0,
  105. AI_FAILURE = -0x1,
  106. AI_INVALIDFILE = -0x2,
  107. AI_OUTOFMEMORY = -0x3,
  108. AI_INVALIDARG = -0x4
  109. };
  110. #ifdef __cplusplus
  111. }
  112. #endif
  113. #endif