PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: MeshManager.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 __PLMESH_MESHMANAGER_H__ 00024 #define __PLMESH_MESHMANAGER_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLCore/Container/ResourceManager.h> 00032 #include "PLMesh/MeshHandler.h" 00033 00034 00035 //[-------------------------------------------------------] 00036 //[ Namespace ] 00037 //[-------------------------------------------------------] 00038 namespace PLMesh { 00039 00040 00041 //[-------------------------------------------------------] 00042 //[ Forward declarations ] 00043 //[-------------------------------------------------------] 00044 class SkeletonManager; 00045 00046 00047 //[-------------------------------------------------------] 00048 //[ Classes ] 00049 //[-------------------------------------------------------] 00050 /** 00051 * @brief 00052 * This is a manager for the mesh resource 00053 * 00054 * @note 00055 * - Unloads unused resources automatically by default 00056 */ 00057 class MeshManager : public PLCore::ResourceManager<Mesh> { 00058 00059 00060 //[-------------------------------------------------------] 00061 //[ Public functions ] 00062 //[-------------------------------------------------------] 00063 public: 00064 /** 00065 * @brief 00066 * Constructor 00067 * 00068 * @param[in] cRenderer 00069 * Renderer to use 00070 */ 00071 PLMESH_API MeshManager(PLRenderer::Renderer &cRenderer); 00072 00073 /** 00074 * @brief 00075 * Destructor 00076 */ 00077 PLMESH_API virtual ~MeshManager(); 00078 00079 /** 00080 * @brief 00081 * Returns the used renderer 00082 * 00083 * @return 00084 * Pointer to the renderer the meshes should use, can be a null pointer 00085 */ 00086 PLMESH_API PLRenderer::Renderer *GetRenderer() const; 00087 00088 /** 00089 * @brief 00090 * Creates the mesh and adds the required LODs 00091 * 00092 * @return 00093 * The created mesh, a null pointer on error 00094 * 00095 * @note 00096 * - If the mesh is created, the 'Material' is added automatically 00097 */ 00098 PLMESH_API Mesh *CreateMesh(); 00099 00100 /** 00101 * @brief 00102 * Creates a new mesh resource 00103 * 00104 * @param[in] sName 00105 * Resource name, if empty an unused name is set automatically 00106 * @param[in] bStatic 00107 * Static mesh? (better performance!) 00108 * 00109 * @return 00110 * Pointer to the created resource, a null pointer if there was an error 00111 * 00112 * @note 00113 * - If there's already a resource with this name, this resource is returned 00114 */ 00115 PLMESH_API Mesh *CreateMesh(const PLCore::String &sName, bool bStatic = true); 00116 00117 /** 00118 * @brief 00119 * Creates a mesh resource using a mesh creator 00120 * 00121 * @param[in] sName 00122 * Mesh creator class name (for instance "MeshCreatorSphere") 00123 * @param[in] bStatic 00124 * Static mesh? (better performance!) 00125 * @param[in] sParameters 00126 * Mesh creator parameters. (for instance "Radius='4.0' Detail='20'") 00127 * This parameters depend on the used mesh creator. 00128 * 00129 * @return 00130 * Pointer to the created resource, a null pointer if there was an error 00131 * (maybe unknown class or the class is not derived from 'MeshCreator') 00132 */ 00133 PLMESH_API Mesh *CreateMesh(const PLCore::String &sName, bool bStatic, const PLCore::String &sParameters); 00134 00135 /** 00136 * @brief 00137 * Load mesh 00138 * 00139 * @param[in] sFilename 00140 * Mesh filename. It's also possible to create meshes dynamically. 00141 * "Create MeshCreatorSphere Name=\"Sphere\" Radius=\"4.0\" Detail=\"20.0\"" 00142 * For instance will use the mesh creator class 'MeshCreatorSphere' 00143 * to create a mesh with the name 'Sphere' and some parameters. 00144 * @param[in] sParams 00145 * Optional load method parameters, can be an empty string 00146 * @param[in] sMethod 00147 * Optional name of the load method to use, can be an empty string 00148 * @param[in] bReloadMesh 00149 * Force mesh itself to be reloaded? 00150 * @param[in] bStatic 00151 * Static mesh? (better performance!) 00152 * 00153 * @return 00154 * The loaded mesh, a null pointer on error 00155 */ 00156 PLMESH_API Mesh *LoadMesh(const PLCore::String &sFilename, const PLCore::String &sParams = "", const PLCore::String &sMethod = "", bool bReloadMesh = false, bool bStatic = true); 00157 00158 /** 00159 * @brief 00160 * Returns the skeleton manager 00161 * 00162 * @return 00163 * The skeleton manager 00164 */ 00165 PLMESH_API SkeletonManager &GetSkeletonManager() const; 00166 00167 00168 //[-------------------------------------------------------] 00169 //[ Private data ] 00170 //[-------------------------------------------------------] 00171 private: 00172 PLRenderer::Renderer *m_pRenderer; /**< Renderer the manager is using (always valid!) */ 00173 SkeletonManager *m_pSkeletonManager; /**< Skeleton manager (always valid!) */ 00174 00175 00176 //[-------------------------------------------------------] 00177 //[ Private virtual PLCore::ResourceManager functions ] 00178 //[-------------------------------------------------------] 00179 private: 00180 virtual Mesh *CreateResource(const PLCore::String &sName) override; 00181 00182 00183 }; 00184 00185 00186 //[-------------------------------------------------------] 00187 //[ Namespace ] 00188 //[-------------------------------------------------------] 00189 } // PLMesh 00190 00191 00192 #endif // __PLMESH_MESHMANAGER_H__
|