![]() |
|
|||
File indexing completed on 2025-02-21 09:30:10
0001 /* 0002 --------------------------------------------------------------------------- 0003 Open Asset Import Library (assimp) 0004 --------------------------------------------------------------------------- 0005 0006 Copyright (c) 2006-2024, assimp team 0007 0008 All rights reserved. 0009 0010 Redistribution and use of this software in source and binary forms, 0011 with or without modification, are permitted provided that the following 0012 conditions are met: 0013 0014 * Redistributions of source code must retain the above 0015 copyright notice, this list of conditions and the 0016 following disclaimer. 0017 0018 * Redistributions in binary form must reproduce the above 0019 copyright notice, this list of conditions and the 0020 following disclaimer in the documentation and/or other 0021 materials provided with the distribution. 0022 0023 * Neither the name of the assimp team, nor the names of its 0024 contributors may be used to endorse or promote products 0025 derived from this software without specific prior 0026 written permission of the assimp team. 0027 0028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 0029 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 0030 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 0031 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 0032 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 0033 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 0034 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0035 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0036 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0037 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0038 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0039 --------------------------------------------------------------------------- 0040 */ 0041 0042 /** @file texture.h 0043 * @brief Defines texture helper structures for the library 0044 * 0045 * Used for file formats which embed their textures into the model file. 0046 * Supported are both normal textures, which are stored as uncompressed 0047 * pixels, and "compressed" textures, which are stored in a file format 0048 * such as PNG or TGA. 0049 */ 0050 #pragma once 0051 #ifndef AI_TEXTURE_H_INC 0052 #define AI_TEXTURE_H_INC 0053 0054 #ifdef __GNUC__ 0055 # pragma GCC system_header 0056 #endif 0057 0058 #include <assimp/types.h> 0059 0060 #ifdef __cplusplus 0061 extern "C" { 0062 #endif 0063 0064 // -------------------------------------------------------------------------------- 0065 0066 /** \def AI_EMBEDDED_TEXNAME_PREFIX 0067 * \ref AI_MAKE_EMBEDDED_TEXNAME 0068 */ 0069 #ifndef AI_EMBEDDED_TEXNAME_PREFIX 0070 # define AI_EMBEDDED_TEXNAME_PREFIX "*" 0071 #endif 0072 0073 /** @def AI_MAKE_EMBEDDED_TEXNAME 0074 * Used to build the reserved path name used by the material system to 0075 * reference textures that are embedded into their corresponding 0076 * model files. The parameter specifies the index of the texture 0077 * (zero-based, in the aiScene::mTextures array) 0078 */ 0079 #if (!defined AI_MAKE_EMBEDDED_TEXNAME) 0080 # define AI_MAKE_EMBEDDED_TEXNAME(_n_) AI_EMBEDDED_TEXNAME_PREFIX # _n_ 0081 #endif 0082 0083 #include "./Compiler/pushpack1.h" 0084 0085 // -------------------------------------------------------------------------------- 0086 /** @brief Helper structure to represent a texel in a ARGB8888 format 0087 * 0088 * Used by aiTexture. 0089 */ 0090 struct aiTexel { 0091 unsigned char b,g,r,a; 0092 0093 #ifdef __cplusplus 0094 //! Comparison operator 0095 bool operator== (const aiTexel& other) const { 0096 return b == other.b && r == other.r && 0097 g == other.g && a == other.a; 0098 } 0099 0100 //! Inverse comparison operator 0101 bool operator!= (const aiTexel& other) const { 0102 return b != other.b || r != other.r || 0103 g != other.g || a != other.a; 0104 } 0105 0106 //! Conversion to a floating-point 4d color 0107 operator aiColor4D() const { 0108 return aiColor4D(r/255.f,g/255.f,b/255.f,a/255.f); 0109 } 0110 #endif // __cplusplus 0111 0112 } PACK_STRUCT; 0113 0114 #include "./Compiler/poppack1.h" 0115 0116 #define HINTMAXTEXTURELEN 9 0117 0118 // -------------------------------------------------------------------------------- 0119 /** Helper structure to describe an embedded texture 0120 * 0121 * Normally textures are contained in external files but some file formats embed 0122 * them directly in the model file. There are two types of embedded textures: 0123 * 1. Uncompressed textures. The color data is given in an uncompressed format. 0124 * 2. Compressed textures stored in a file format like png or jpg. The raw file 0125 * bytes are given so the application must utilize an image decoder (e.g. DevIL) to 0126 * get access to the actual color data. 0127 * 0128 * Embedded textures are referenced from materials using strings like "*0", "*1", etc. 0129 * as the texture paths (a single asterisk character followed by the 0130 * zero-based index of the texture in the aiScene::mTextures array). 0131 */ 0132 struct aiTexture { 0133 /** Width of the texture, in pixels 0134 * 0135 * If mHeight is zero the texture is compressed in a format 0136 * like JPEG. In this case mWidth specifies the size of the 0137 * memory area pcData is pointing to, in bytes. 0138 */ 0139 unsigned int mWidth; 0140 0141 /** Height of the texture, in pixels 0142 * 0143 * If this value is zero, pcData points to an compressed texture 0144 * in any format (e.g. JPEG). 0145 */ 0146 unsigned int mHeight; 0147 0148 /** A hint from the loader to make it easier for applications 0149 * to determine the type of embedded textures. 0150 * 0151 * If mHeight != 0 this member is show how data is packed. Hint will consist of 0152 * two parts: channel order and channel bitness (count of the bits for every 0153 * color channel). For simple parsing by the viewer it's better to not omit 0154 * absent color channel and just use 0 for bitness. For example: 0155 * 1. Image contain RGBA and 8 bit per channel, achFormatHint == "rgba8888"; 0156 * 2. Image contain ARGB and 8 bit per channel, achFormatHint == "argb8888"; 0157 * 3. Image contain RGB and 5 bit for R and B channels and 6 bit for G channel, achFormatHint == "rgba5650"; 0158 * 4. One color image with B channel and 1 bit for it, achFormatHint == "rgba0010"; 0159 * If mHeight == 0 then achFormatHint is set set to '\\0\\0\\0\\0' if the loader has no additional 0160 * information about the texture file format used OR the 0161 * file extension of the format without a trailing dot. If there 0162 * are multiple file extensions for a format, the shortest 0163 * extension is chosen (JPEG maps to 'jpg', not to 'jpeg'). 0164 * E.g. 'dds\\0', 'pcx\\0', 'jpg\\0'. All characters are lower-case. 0165 * The fourth character will always be '\\0'. 0166 */ 0167 char achFormatHint[ HINTMAXTEXTURELEN ];// 8 for string + 1 for terminator. 0168 0169 /** Data of the texture. 0170 * 0171 * Points to an array of mWidth * mHeight aiTexel's. 0172 * The format of the texture data is always ARGB8888 to 0173 * make the implementation for user of the library as easy 0174 * as possible. If mHeight = 0 this is a pointer to a memory 0175 * buffer of size mWidth containing the compressed texture 0176 * data. Good luck, have fun! 0177 */ 0178 C_STRUCT aiTexel* pcData; 0179 0180 /** Texture original filename 0181 * 0182 * Used to get the texture reference 0183 */ 0184 C_STRUCT aiString mFilename; 0185 0186 #ifdef __cplusplus 0187 0188 //! For compressed textures (mHeight == 0): compare the 0189 //! format hint against a given string. 0190 //! @param s Input string. 3 characters are maximally processed. 0191 //! Example values: "jpg", "png" 0192 //! @return true if the given string matches the format hint 0193 bool CheckFormat(const char* s) const { 0194 if (nullptr == s) { 0195 return false; 0196 } 0197 0198 return (0 == ::strncmp(achFormatHint, s, sizeof(achFormatHint))); 0199 } 0200 0201 // Construction 0202 aiTexture() AI_NO_EXCEPT : 0203 mWidth(0), 0204 mHeight(0), 0205 pcData(nullptr), 0206 mFilename() { 0207 memset(achFormatHint, 0, sizeof(achFormatHint)); 0208 } 0209 0210 // Destruction 0211 ~aiTexture () { 0212 delete[] pcData; 0213 } 0214 #endif 0215 }; 0216 0217 0218 #ifdef __cplusplus 0219 } 0220 #endif 0221 0222 #endif // AI_TEXTURE_H_INC
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |