aiTexture.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (ASSIMP)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2008, ASSIMP Development Team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the ASSIMP team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the ASSIMP Development Team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. /** @file Defines texture helper structures for the library
  35. *
  36. * Used for file formats which embedd their textures into the model file.
  37. * Supported are both normal textures, which are stored as uncompressed
  38. * pixels, and "compressed" textures, which are stored in a file format
  39. * such as PNG or TGA.
  40. */
  41. #ifndef AI_TEXTURE_H_INC
  42. #define AI_TEXTURE_H_INC
  43. #include "aiTypes.h"
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. // ---------------------------------------------------------------------------
  48. /** \def AI_MAKE_EMBEDDED_TEXNAME
  49. * Used to build the reserved path name used by the material system to
  50. * reference textures that are embedded into their corresponding
  51. * model files. The parameter specifies the index of the texture
  52. * (zero-based, in the aiScene::mTextures array)
  53. */
  54. // ---------------------------------------------------------------------------
  55. #if (!defined AI_MAKE_EMBEDDED_TEXNAME)
  56. # define AI_MAKE_EMBEDDED_TEXNAME(_n_) "*" # _n_
  57. #endif
  58. #include "./Compiler/pushpack1.h"
  59. // ---------------------------------------------------------------------------
  60. /** Helper structure to represent a texel in ARGB8888 format
  61. *
  62. * Used by aiTexture
  63. */
  64. // ---------------------------------------------------------------------------
  65. struct aiTexel
  66. {
  67. unsigned char b,g,r,a;
  68. #ifdef __cplusplus
  69. //! Comparison operator
  70. bool operator== (const aiTexel& other) const
  71. {
  72. return b == other.b && r == other.r &&
  73. g == other.g && a == other.a;
  74. }
  75. //! Negative comparison operator
  76. bool operator!= (const aiTexel& other) const
  77. {
  78. return b != other.b || r != other.r ||
  79. g != other.g || a != other.a;
  80. }
  81. #endif // __cplusplus
  82. } PACK_STRUCT;
  83. #include "./Compiler/poppack1.h"
  84. // ---------------------------------------------------------------------------
  85. /** Helper structure to describe an embedded texture
  86. *
  87. * Normally textures are contained in external files but some file formats
  88. * do embedd them. Embedded
  89. */
  90. // ---------------------------------------------------------------------------
  91. struct aiTexture
  92. {
  93. /** Width of the texture, in pixels
  94. *
  95. * If mHeight is zero the texture is compressed in a format
  96. * like JPEG. In this case mWidth specifies the size of the
  97. * memory area pcData is pointing to, in bytes.
  98. */
  99. unsigned int mWidth;
  100. /** Height of the texture, in pixels
  101. *
  102. * If this value is zero, pcData points to an compressed texture
  103. * in an unknown format (e.g. JPEG).
  104. */
  105. unsigned int mHeight;
  106. /** A hint from the loader to make it easier for applications
  107. * to determine the type of embedded compressed textures.
  108. *
  109. * If mHeight != 0 this member is undefined. Otherwise it
  110. * will be set to '\0\0\0\0' if the loader has no additional
  111. * information about the texture file format used OR the
  112. * file extension of the format without a leading dot.
  113. * E.g. 'dds\0', 'pcx\0'. All characters are lower-case.
  114. */
  115. char achFormatHint[4];
  116. /** Data of the texture.
  117. *
  118. * Points to an array of mWidth * mHeight aiTexel's.
  119. * The format of the texture data is always ARGB8888 to
  120. * make the implementation for user of the library as easy
  121. * as possible. If mHeight = 0 this is a pointer to a memory
  122. * buffer of size mWidth containing the compressed texture
  123. * data. Good luck, have fun!
  124. */
  125. aiTexel* pcData;
  126. #ifdef __cplusplus
  127. // Construction
  128. aiTexture ()
  129. : mWidth (0)
  130. , mHeight (0)
  131. , pcData (NULL)
  132. {
  133. achFormatHint[0] = 0;
  134. achFormatHint[1] = 0;
  135. achFormatHint[2] = 0;
  136. achFormatHint[3] = 0;
  137. }
  138. // Destruction
  139. ~aiTexture ()
  140. {
  141. delete[] pcData;
  142. }
  143. #endif
  144. };
  145. #ifdef __cplusplus
  146. }
  147. #endif
  148. #endif // AI_TEXTURE_H_INC