vrshoot

annotate 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
rev   line source
nuclear@0 1 /*
nuclear@0 2 ---------------------------------------------------------------------------
nuclear@0 3 Open Asset Import Library (assimp)
nuclear@0 4 ---------------------------------------------------------------------------
nuclear@0 5
nuclear@0 6 Copyright (c) 2006-2012, assimp team
nuclear@0 7
nuclear@0 8 All rights reserved.
nuclear@0 9
nuclear@0 10 Redistribution and use of this software in source and binary forms,
nuclear@0 11 with or without modification, are permitted provided that the following
nuclear@0 12 conditions are met:
nuclear@0 13
nuclear@0 14 * Redistributions of source code must retain the above
nuclear@0 15 copyright notice, this list of conditions and the
nuclear@0 16 following disclaimer.
nuclear@0 17
nuclear@0 18 * Redistributions in binary form must reproduce the above
nuclear@0 19 copyright notice, this list of conditions and the
nuclear@0 20 following disclaimer in the documentation and/or other
nuclear@0 21 materials provided with the distribution.
nuclear@0 22
nuclear@0 23 * Neither the name of the assimp team, nor the names of its
nuclear@0 24 contributors may be used to endorse or promote products
nuclear@0 25 derived from this software without specific prior
nuclear@0 26 written permission of the assimp team.
nuclear@0 27
nuclear@0 28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
nuclear@0 29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
nuclear@0 30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
nuclear@0 31 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
nuclear@0 32 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
nuclear@0 33 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
nuclear@0 34 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
nuclear@0 35 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
nuclear@0 36 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
nuclear@0 37 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
nuclear@0 38 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
nuclear@0 39 ---------------------------------------------------------------------------
nuclear@0 40 */
nuclear@0 41
nuclear@0 42 /** @file texture.h
nuclear@0 43 * @brief Defines texture helper structures for the library
nuclear@0 44 *
nuclear@0 45 * Used for file formats which embed their textures into the model file.
nuclear@0 46 * Supported are both normal textures, which are stored as uncompressed
nuclear@0 47 * pixels, and "compressed" textures, which are stored in a file format
nuclear@0 48 * such as PNG or TGA.
nuclear@0 49 */
nuclear@0 50
nuclear@0 51 #ifndef AI_TEXTURE_H_INC
nuclear@0 52 #define AI_TEXTURE_H_INC
nuclear@0 53
nuclear@0 54 #include "types.h"
nuclear@0 55
nuclear@0 56 #ifdef __cplusplus
nuclear@0 57 extern "C" {
nuclear@0 58 #endif
nuclear@0 59
nuclear@0 60
nuclear@0 61 // --------------------------------------------------------------------------------
nuclear@0 62 /** @def AI_MAKE_EMBEDDED_TEXNAME
nuclear@0 63 * Used to build the reserved path name used by the material system to
nuclear@0 64 * reference textures that are embedded into their corresponding
nuclear@0 65 * model files. The parameter specifies the index of the texture
nuclear@0 66 * (zero-based, in the aiScene::mTextures array)
nuclear@0 67 */
nuclear@0 68 #if (!defined AI_MAKE_EMBEDDED_TEXNAME)
nuclear@0 69 # define AI_MAKE_EMBEDDED_TEXNAME(_n_) "*" # _n_
nuclear@0 70 #endif
nuclear@0 71
nuclear@0 72
nuclear@0 73 #include "./Compiler/pushpack1.h"
nuclear@0 74
nuclear@0 75 // --------------------------------------------------------------------------------
nuclear@0 76 /** @brief Helper structure to represent a texel in a ARGB8888 format
nuclear@0 77 *
nuclear@0 78 * Used by aiTexture.
nuclear@0 79 */
nuclear@0 80 struct aiTexel
nuclear@0 81 {
nuclear@0 82 unsigned char b,g,r,a;
nuclear@0 83
nuclear@0 84 #ifdef __cplusplus
nuclear@0 85 //! Comparison operator
nuclear@0 86 bool operator== (const aiTexel& other) const
nuclear@0 87 {
nuclear@0 88 return b == other.b && r == other.r &&
nuclear@0 89 g == other.g && a == other.a;
nuclear@0 90 }
nuclear@0 91
nuclear@0 92 //! Inverse comparison operator
nuclear@0 93 bool operator!= (const aiTexel& other) const
nuclear@0 94 {
nuclear@0 95 return b != other.b || r != other.r ||
nuclear@0 96 g != other.g || a != other.a;
nuclear@0 97 }
nuclear@0 98
nuclear@0 99 //! Conversion to a floating-point 4d color
nuclear@0 100 operator aiColor4D() const
nuclear@0 101 {
nuclear@0 102 return aiColor4D(r/255.f,g/255.f,b/255.f,a/255.f);
nuclear@0 103 }
nuclear@0 104 #endif // __cplusplus
nuclear@0 105
nuclear@0 106 } PACK_STRUCT;
nuclear@0 107
nuclear@0 108 #include "./Compiler/poppack1.h"
nuclear@0 109
nuclear@0 110 // --------------------------------------------------------------------------------
nuclear@0 111 /** Helper structure to describe an embedded texture
nuclear@0 112 *
nuclear@0 113 * Normally textures are contained in external files but some file formats embed
nuclear@0 114 * them directly in the model file. There are two types of embedded textures:
nuclear@0 115 * 1. Uncompressed textures. The color data is given in an uncompressed format.
nuclear@0 116 * 2. Compressed textures stored in a file format like png or jpg. The raw file
nuclear@0 117 * bytes are given so the application must utilize an image decoder (e.g. DevIL) to
nuclear@0 118 * get access to the actual color data.
nuclear@0 119 */
nuclear@0 120 struct aiTexture
nuclear@0 121 {
nuclear@0 122 /** Width of the texture, in pixels
nuclear@0 123 *
nuclear@0 124 * If mHeight is zero the texture is compressed in a format
nuclear@0 125 * like JPEG. In this case mWidth specifies the size of the
nuclear@0 126 * memory area pcData is pointing to, in bytes.
nuclear@0 127 */
nuclear@0 128 unsigned int mWidth;
nuclear@0 129
nuclear@0 130 /** Height of the texture, in pixels
nuclear@0 131 *
nuclear@0 132 * If this value is zero, pcData points to an compressed texture
nuclear@0 133 * in any format (e.g. JPEG).
nuclear@0 134 */
nuclear@0 135 unsigned int mHeight;
nuclear@0 136
nuclear@0 137 /** A hint from the loader to make it easier for applications
nuclear@0 138 * to determine the type of embedded compressed textures.
nuclear@0 139 *
nuclear@0 140 * If mHeight != 0 this member is undefined. Otherwise it
nuclear@0 141 * is set set to '\\0\\0\\0\\0' if the loader has no additional
nuclear@0 142 * information about the texture file format used OR the
nuclear@0 143 * file extension of the format without a trailing dot. If there
nuclear@0 144 * are multiple file extensions for a format, the shortest
nuclear@0 145 * extension is chosen (JPEG maps to 'jpg', not to 'jpeg').
nuclear@0 146 * E.g. 'dds\\0', 'pcx\\0', 'jpg\\0'. All characters are lower-case.
nuclear@0 147 * The fourth character will always be '\\0'.
nuclear@0 148 */
nuclear@0 149 char achFormatHint[4];
nuclear@0 150
nuclear@0 151 /** Data of the texture.
nuclear@0 152 *
nuclear@0 153 * Points to an array of mWidth * mHeight aiTexel's.
nuclear@0 154 * The format of the texture data is always ARGB8888 to
nuclear@0 155 * make the implementation for user of the library as easy
nuclear@0 156 * as possible. If mHeight = 0 this is a pointer to a memory
nuclear@0 157 * buffer of size mWidth containing the compressed texture
nuclear@0 158 * data. Good luck, have fun!
nuclear@0 159 */
nuclear@0 160 C_STRUCT aiTexel* pcData;
nuclear@0 161
nuclear@0 162 #ifdef __cplusplus
nuclear@0 163
nuclear@0 164 //! For compressed textures (mHeight == 0): compare the
nuclear@0 165 //! format hint against a given string.
nuclear@0 166 //! @param s Input string. 3 characters are maximally processed.
nuclear@0 167 //! Example values: "jpg", "png"
nuclear@0 168 //! @return true if the given string matches the format hint
nuclear@0 169 bool CheckFormat(const char* s) const
nuclear@0 170 {
nuclear@0 171 return (0 == ::strncmp(achFormatHint,s,3));
nuclear@0 172 }
nuclear@0 173
nuclear@0 174 // Construction
nuclear@0 175 aiTexture ()
nuclear@0 176 : mWidth (0)
nuclear@0 177 , mHeight (0)
nuclear@0 178 , pcData (NULL)
nuclear@0 179 {
nuclear@0 180 achFormatHint[0] = achFormatHint[1] = 0;
nuclear@0 181 achFormatHint[2] = achFormatHint[3] = 0;
nuclear@0 182 }
nuclear@0 183
nuclear@0 184 // Destruction
nuclear@0 185 ~aiTexture ()
nuclear@0 186 {
nuclear@0 187 delete[] pcData;
nuclear@0 188 }
nuclear@0 189 #endif
nuclear@0 190 };
nuclear@0 191
nuclear@0 192
nuclear@0 193 #ifdef __cplusplus
nuclear@0 194 }
nuclear@0 195 #endif
nuclear@0 196
nuclear@0 197 #endif // AI_TEXTURE_H_INC