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