PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: TextureAni.h * 00003 * 00004 * Copyright (C) 2002-2011 The PixelLight Team (http://www.pixellight.org/) 00005 * 00006 * This file is part of PixelLight. 00007 * 00008 * PixelLight is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published by 00010 * the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * PixelLight is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with PixelLight. If not, see <http://www.gnu.org/licenses/>. 00020 \*********************************************************/ 00021 00022 00023 #ifndef __PLRENDERER_TEXTUREANI_H__ 00024 #define __PLRENDERER_TEXTUREANI_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLMath/Vector3.h> 00032 #include <PLGraphics/Color/Color4.h> 00033 #include "PLRenderer/Texture/Texture.h" 00034 #include "PLRenderer/Texture/AniInfoManager.h" 00035 00036 00037 //[-------------------------------------------------------] 00038 //[ Namespace ] 00039 //[-------------------------------------------------------] 00040 namespace PLRenderer { 00041 00042 00043 //[-------------------------------------------------------] 00044 //[ Forward declarations ] 00045 //[-------------------------------------------------------] 00046 class TextureHandler; 00047 00048 00049 //[-------------------------------------------------------] 00050 //[ Classes ] 00051 //[-------------------------------------------------------] 00052 /** 00053 * @brief 00054 * Texture animation resource class 00055 */ 00056 class TextureAni : public Texture { 00057 00058 00059 //[-------------------------------------------------------] 00060 //[ Friends ] 00061 //[-------------------------------------------------------] 00062 friend class TextureHandler; 00063 00064 00065 //[-------------------------------------------------------] 00066 //[ Public structures ] 00067 //[-------------------------------------------------------] 00068 public: 00069 /** 00070 * @brief 00071 * Texture animation 00072 */ 00073 struct TextureFrame { 00074 TextureHandler *pTextureHandler; /**< Texture handler for this frame (always valid!) */ 00075 }; 00076 00077 /** 00078 * @brief 00079 * Matrix animation 00080 */ 00081 struct MatrixFrame { 00082 PLMath::Vector3 vTranslation; /**< Translation */ 00083 PLMath::Vector3 vRotation; /**< Rotation */ 00084 PLMath::Vector3 vScale; /**< Scale */ 00085 }; 00086 00087 /** 00088 * @brief 00089 * Color animation 00090 */ 00091 struct ColorFrame { 00092 PLGraphics::Color4 vColor; /**< Color */ 00093 }; 00094 00095 00096 //[-------------------------------------------------------] 00097 //[ Public functions ] 00098 //[-------------------------------------------------------] 00099 public: 00100 /** 00101 * @brief 00102 * Destructor 00103 */ 00104 PLRENDERER_API virtual ~TextureAni(); 00105 00106 /** 00107 * @brief 00108 * Copy operator 00109 * 00110 * @param[in] cSource 00111 * Source to copy from 00112 * 00113 * @return 00114 * This instance 00115 */ 00116 PLRENDERER_API TextureAni &operator =(const TextureAni &cSource); 00117 00118 //[-------------------------------------------------------] 00119 //[ Texture animation ] 00120 //[-------------------------------------------------------] 00121 /** 00122 * @brief 00123 * Returns the texture animation manager 00124 * 00125 * @return 00126 * The texture handlers texture animation manager 00127 */ 00128 inline AniInfoManager &GetTextureAnimationManager(); 00129 inline const AniInfoManager &GetTextureAnimationManager() const; 00130 00131 /** 00132 * @brief 00133 * Create standard texture animation 00134 * 00135 * @note 00136 * - A standard animation in only added if there are at the moment no animations at all 00137 */ 00138 PLRENDERER_API void CreateStandardTextureAnimation(); 00139 00140 /** 00141 * @brief 00142 * Returns the texture frames array 00143 * 00144 * @return 00145 * The texture frames array 00146 */ 00147 inline PLCore::Array<TextureFrame*> &GetTextureFrames(); 00148 inline const PLCore::Array<TextureFrame*> &GetTextureFrames() const; 00149 00150 //[-------------------------------------------------------] 00151 //[ Matrix animation ] 00152 //[-------------------------------------------------------] 00153 /** 00154 * @brief 00155 * Returns the matrix animation manager 00156 * 00157 * @return 00158 * The texture handlers matrix animation manager 00159 */ 00160 inline AniInfoManager &GetMatrixAnimationManager(); 00161 inline const AniInfoManager &GetMatrixAnimationManager() const; 00162 00163 /** 00164 * @brief 00165 * Create standard matrix animation 00166 * 00167 * @note 00168 * - A standard animation in only added if there are at the moment no animations at all 00169 */ 00170 PLRENDERER_API void CreateStandardMatrixAnimation(); 00171 00172 /** 00173 * @brief 00174 * Returns the matrix frames array 00175 * 00176 * @return 00177 * The matrix frames array 00178 */ 00179 inline PLCore::Array<MatrixFrame*> &GetMatrixFrames(); 00180 inline const PLCore::Array<MatrixFrame*> &GetMatrixFrames() const; 00181 00182 //[-------------------------------------------------------] 00183 //[ Color animation ] 00184 //[-------------------------------------------------------] 00185 /** 00186 * @brief 00187 * Returns the color animation manager 00188 * 00189 * @return 00190 * The texture handlers color animation manager 00191 */ 00192 inline AniInfoManager &GetColorAnimationManager(); 00193 inline const AniInfoManager &GetColorAnimationManager() const; 00194 00195 /** 00196 * @brief 00197 * Create standard color animation 00198 * 00199 * @note 00200 * - A standard animation in only added if there are at the moment no animations at all 00201 */ 00202 PLRENDERER_API void CreateStandardColorAnimation(); 00203 00204 /** 00205 * @brief 00206 * Returns the color frames array 00207 * 00208 * @return 00209 * The color frames array 00210 */ 00211 inline PLCore::Array<ColorFrame*> &GetColorFrames(); 00212 inline const PLCore::Array<ColorFrame*> &GetColorFrames() const; 00213 00214 00215 //[-------------------------------------------------------] 00216 //[ Private functions ] 00217 //[-------------------------------------------------------] 00218 private: 00219 /** 00220 * @brief 00221 * Constructor 00222 * 00223 * @param[in] cManager 00224 * Texture manager using this resource 00225 * @param[in] sName 00226 * Resource name to set 00227 */ 00228 TextureAni(TextureManager &cManager, const PLCore::String &sName); 00229 00230 00231 //[-------------------------------------------------------] 00232 //[ Private data ] 00233 //[-------------------------------------------------------] 00234 private: 00235 // Texture animation 00236 AniInfoManager m_cTextureAnimationManager; /**< Texture animation manager */ 00237 PLCore::Array<TextureFrame*> m_lstTextureFrames; /**< Texture animation frames */ 00238 // Matrix animation 00239 AniInfoManager m_cMatrixAnimationManager; /**< Matrix animation manager */ 00240 PLCore::Array<MatrixFrame*> m_lstMatrixFrames; /**< Matrix animation frames */ 00241 // Color animation 00242 AniInfoManager m_cColorAnimationManager; /**< Color animation manager */ 00243 PLCore::Array<ColorFrame*> m_lstColorFrames; /**< Color animation frames */ 00244 00245 00246 //[-------------------------------------------------------] 00247 //[ Public virtual Texture functions ] 00248 //[-------------------------------------------------------] 00249 public: 00250 PLRENDERER_API virtual bool IsAnimated() const override; 00251 00252 00253 //[-------------------------------------------------------] 00254 //[ Public virtual PLCore::Loadable functions ] 00255 //[-------------------------------------------------------] 00256 public: 00257 PLRENDERER_API virtual bool LoadByFilename(const PLCore::String &sFilename, const PLCore::String &sParams = "", const PLCore::String &sMethod = "") override; 00258 PLRENDERER_API virtual bool SaveByFilename(const PLCore::String &sFilename, const PLCore::String &sParams = "", const PLCore::String &sMethod = "") override; 00259 PLRENDERER_API virtual bool SaveByFile(PLCore::File &cFile, const PLCore::String &sParams = "", const PLCore::String &sMethod = "") override; 00260 PLRENDERER_API virtual bool Unload() override; 00261 PLRENDERER_API virtual PLCore::String GetLoadableTypeName() const override; 00262 00263 00264 }; 00265 00266 00267 //[-------------------------------------------------------] 00268 //[ Namespace ] 00269 //[-------------------------------------------------------] 00270 } // PLRenderer 00271 00272 00273 //[-------------------------------------------------------] 00274 //[ Implementation ] 00275 //[-------------------------------------------------------] 00276 #include "PLRenderer/Texture/TextureAni.inl" 00277 00278 00279 #endif // __PLRENDERER_TEXTUREANI_H__
|