vrshoot
diff libs/assimp/assimp/texture.h @ 0:b2f14e535253
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 01 Feb 2014 19:58:19 +0200 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libs/assimp/assimp/texture.h Sat Feb 01 19:58:19 2014 +0200 1.3 @@ -0,0 +1,197 @@ 1.4 +/* 1.5 +--------------------------------------------------------------------------- 1.6 +Open Asset Import Library (assimp) 1.7 +--------------------------------------------------------------------------- 1.8 + 1.9 +Copyright (c) 2006-2012, assimp team 1.10 + 1.11 +All rights reserved. 1.12 + 1.13 +Redistribution and use of this software in source and binary forms, 1.14 +with or without modification, are permitted provided that the following 1.15 +conditions are met: 1.16 + 1.17 +* Redistributions of source code must retain the above 1.18 + copyright notice, this list of conditions and the 1.19 + following disclaimer. 1.20 + 1.21 +* Redistributions in binary form must reproduce the above 1.22 + copyright notice, this list of conditions and the 1.23 + following disclaimer in the documentation and/or other 1.24 + materials provided with the distribution. 1.25 + 1.26 +* Neither the name of the assimp team, nor the names of its 1.27 + contributors may be used to endorse or promote products 1.28 + derived from this software without specific prior 1.29 + written permission of the assimp team. 1.30 + 1.31 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.32 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.33 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.34 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1.35 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.36 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.37 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1.38 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1.39 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.40 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.41 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.42 +--------------------------------------------------------------------------- 1.43 +*/ 1.44 + 1.45 +/** @file texture.h 1.46 + * @brief Defines texture helper structures for the library 1.47 + * 1.48 + * Used for file formats which embed their textures into the model file. 1.49 + * Supported are both normal textures, which are stored as uncompressed 1.50 + * pixels, and "compressed" textures, which are stored in a file format 1.51 + * such as PNG or TGA. 1.52 + */ 1.53 + 1.54 +#ifndef AI_TEXTURE_H_INC 1.55 +#define AI_TEXTURE_H_INC 1.56 + 1.57 +#include "types.h" 1.58 + 1.59 +#ifdef __cplusplus 1.60 +extern "C" { 1.61 +#endif 1.62 + 1.63 + 1.64 +// -------------------------------------------------------------------------------- 1.65 +/** @def AI_MAKE_EMBEDDED_TEXNAME 1.66 + * Used to build the reserved path name used by the material system to 1.67 + * reference textures that are embedded into their corresponding 1.68 + * model files. The parameter specifies the index of the texture 1.69 + * (zero-based, in the aiScene::mTextures array) 1.70 + */ 1.71 +#if (!defined AI_MAKE_EMBEDDED_TEXNAME) 1.72 +# define AI_MAKE_EMBEDDED_TEXNAME(_n_) "*" # _n_ 1.73 +#endif 1.74 + 1.75 + 1.76 +#include "./Compiler/pushpack1.h" 1.77 + 1.78 +// -------------------------------------------------------------------------------- 1.79 +/** @brief Helper structure to represent a texel in a ARGB8888 format 1.80 +* 1.81 +* Used by aiTexture. 1.82 +*/ 1.83 +struct aiTexel 1.84 +{ 1.85 + unsigned char b,g,r,a; 1.86 + 1.87 +#ifdef __cplusplus 1.88 + //! Comparison operator 1.89 + bool operator== (const aiTexel& other) const 1.90 + { 1.91 + return b == other.b && r == other.r && 1.92 + g == other.g && a == other.a; 1.93 + } 1.94 + 1.95 + //! Inverse comparison operator 1.96 + bool operator!= (const aiTexel& other) const 1.97 + { 1.98 + return b != other.b || r != other.r || 1.99 + g != other.g || a != other.a; 1.100 + } 1.101 + 1.102 + //! Conversion to a floating-point 4d color 1.103 + operator aiColor4D() const 1.104 + { 1.105 + return aiColor4D(r/255.f,g/255.f,b/255.f,a/255.f); 1.106 + } 1.107 +#endif // __cplusplus 1.108 + 1.109 +} PACK_STRUCT; 1.110 + 1.111 +#include "./Compiler/poppack1.h" 1.112 + 1.113 +// -------------------------------------------------------------------------------- 1.114 +/** Helper structure to describe an embedded texture 1.115 + * 1.116 + * Normally textures are contained in external files but some file formats embed 1.117 + * them directly in the model file. There are two types of embedded textures: 1.118 + * 1. Uncompressed textures. The color data is given in an uncompressed format. 1.119 + * 2. Compressed textures stored in a file format like png or jpg. The raw file 1.120 + * bytes are given so the application must utilize an image decoder (e.g. DevIL) to 1.121 + * get access to the actual color data. 1.122 + */ 1.123 +struct aiTexture 1.124 +{ 1.125 + /** Width of the texture, in pixels 1.126 + * 1.127 + * If mHeight is zero the texture is compressed in a format 1.128 + * like JPEG. In this case mWidth specifies the size of the 1.129 + * memory area pcData is pointing to, in bytes. 1.130 + */ 1.131 + unsigned int mWidth; 1.132 + 1.133 + /** Height of the texture, in pixels 1.134 + * 1.135 + * If this value is zero, pcData points to an compressed texture 1.136 + * in any format (e.g. JPEG). 1.137 + */ 1.138 + unsigned int mHeight; 1.139 + 1.140 + /** A hint from the loader to make it easier for applications 1.141 + * to determine the type of embedded compressed textures. 1.142 + * 1.143 + * If mHeight != 0 this member is undefined. Otherwise it 1.144 + * is set set to '\\0\\0\\0\\0' if the loader has no additional 1.145 + * information about the texture file format used OR the 1.146 + * file extension of the format without a trailing dot. If there 1.147 + * are multiple file extensions for a format, the shortest 1.148 + * extension is chosen (JPEG maps to 'jpg', not to 'jpeg'). 1.149 + * E.g. 'dds\\0', 'pcx\\0', 'jpg\\0'. All characters are lower-case. 1.150 + * The fourth character will always be '\\0'. 1.151 + */ 1.152 + char achFormatHint[4]; 1.153 + 1.154 + /** Data of the texture. 1.155 + * 1.156 + * Points to an array of mWidth * mHeight aiTexel's. 1.157 + * The format of the texture data is always ARGB8888 to 1.158 + * make the implementation for user of the library as easy 1.159 + * as possible. If mHeight = 0 this is a pointer to a memory 1.160 + * buffer of size mWidth containing the compressed texture 1.161 + * data. Good luck, have fun! 1.162 + */ 1.163 + C_STRUCT aiTexel* pcData; 1.164 + 1.165 +#ifdef __cplusplus 1.166 + 1.167 + //! For compressed textures (mHeight == 0): compare the 1.168 + //! format hint against a given string. 1.169 + //! @param s Input string. 3 characters are maximally processed. 1.170 + //! Example values: "jpg", "png" 1.171 + //! @return true if the given string matches the format hint 1.172 + bool CheckFormat(const char* s) const 1.173 + { 1.174 + return (0 == ::strncmp(achFormatHint,s,3)); 1.175 + } 1.176 + 1.177 + // Construction 1.178 + aiTexture () 1.179 + : mWidth (0) 1.180 + , mHeight (0) 1.181 + , pcData (NULL) 1.182 + { 1.183 + achFormatHint[0] = achFormatHint[1] = 0; 1.184 + achFormatHint[2] = achFormatHint[3] = 0; 1.185 + } 1.186 + 1.187 + // Destruction 1.188 + ~aiTexture () 1.189 + { 1.190 + delete[] pcData; 1.191 + } 1.192 +#endif 1.193 +}; 1.194 + 1.195 + 1.196 +#ifdef __cplusplus 1.197 +} 1.198 +#endif 1.199 + 1.200 +#endif // AI_TEXTURE_H_INC