PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: GMMSurfacePatch.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 __PLSCENE_SCENENODE_GMMSURFACEPATCH_H__ 00024 #define __PLSCENE_SCENENODE_GMMSURFACEPATCH_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLMath/Quadtree.h> 00032 #include "PLScene/PLScene.h" 00033 00034 00035 //[-------------------------------------------------------] 00036 //[ Namespace ] 00037 //[-------------------------------------------------------] 00038 namespace PLScene { 00039 00040 00041 //[-------------------------------------------------------] 00042 //[ Forward declarations ] 00043 //[-------------------------------------------------------] 00044 class GMMSurface; 00045 class GMMSurfacePatch; 00046 00047 00048 //[-------------------------------------------------------] 00049 //[ Classes ] 00050 //[-------------------------------------------------------] 00051 /** 00052 * @brief 00053 * GMM surface patch 00054 */ 00055 class GMMSurfacePatch : public PLMath::QuadtreePatch { 00056 00057 00058 //[-------------------------------------------------------] 00059 //[ Friends ] 00060 //[-------------------------------------------------------] 00061 friend class GMMSurface; 00062 00063 00064 //[-------------------------------------------------------] 00065 //[ Public functions ] 00066 //[-------------------------------------------------------] 00067 public: 00068 /** 00069 * @brief 00070 * Returns whether the patch is active or not 00071 * 00072 * @return 00073 * 'true' if the patch is active, else 'false' 00074 */ 00075 PLS_API bool IsActive() const; 00076 00077 /** 00078 * @brief 00079 * Sets whether the patch is active or not 00080 * 00081 * @param[in] bActive 00082 * Should the patch be active? 00083 */ 00084 PLS_API void SetActive(bool bActive = true); 00085 00086 /** 00087 * @brief 00088 * Computes the variance of each mip map level 00089 * 00090 * @param[out] nOffset 00091 * Will receive the offset 00092 */ 00093 PLS_API void ComputeVariance(PLCore::uint32 &nOffset); 00094 00095 /** 00096 * @brief 00097 * Updates the patch bounding box 00098 */ 00099 PLS_API void UpdateBoundingBox(); 00100 00101 00102 //[-------------------------------------------------------] 00103 //[ Private functions ] 00104 //[-------------------------------------------------------] 00105 private: 00106 /** 00107 * @brief 00108 * Constructor 00109 * 00110 * @param[in] cGMMSurface 00111 * Owner GMM surface of this patch 00112 */ 00113 GMMSurfacePatch(GMMSurface &cGMMSurface); 00114 00115 /** 00116 * @brief 00117 * Destructor 00118 */ 00119 virtual ~GMMSurfacePatch(); 00120 00121 /** 00122 * @brief 00123 * Initializes the GMM surface patch 00124 */ 00125 void Init(); 00126 00127 /** 00128 * @brief 00129 * Creates the GMM surface patch 00130 * 00131 * @param[in] nXOffset 00132 * X offset of this patch in the height map 00133 * @param[in] nYOffset 00134 * Y offset of this patch in the height map 00135 * @param[in] nOffset 00136 * Current offset (is increased inside the function) 00137 * 00138 * @return 00139 * 'true' if all went fine, else 'false' 00140 */ 00141 bool Create(PLCore::uint32 nXOffset, PLCore::uint32 nYOffset, PLCore::uint32 &nOffset); 00142 00143 /** 00144 * @brief 00145 * Kills the GMM surface patch 00146 */ 00147 void Destroy(); 00148 00149 /** 00150 * @brief 00151 * Updates the GMM surface patch 00152 * 00153 * @note 00154 * - Must be done before the GMM surface patch is drawn!! 00155 */ 00156 void Update(); 00157 00158 00159 //[-------------------------------------------------------] 00160 //[ Private data ] 00161 //[-------------------------------------------------------] 00162 private: 00163 bool m_bActive; /**< Is the patch active? */ 00164 PLCore::uint32 m_nLevel; /**< Current geo mip map level */ 00165 PLMath::Vector3 m_vCenter; /**< Patch center */ 00166 PLCore::uint32 m_nOffset; /**< Surface vertex offset */ 00167 PLCore::uint32 m_nXOffset; /**< X offset in the height map */ 00168 PLCore::uint32 m_nYOffset; /**< Y offset in the height map */ 00169 float *m_pVariance; /**< Height variance for each level, can be a null pointer */ 00170 GMMSurface *m_pGMMSurface; /**< Owner GMM surface of this patch (always valid!) */ 00171 GMMSurfacePatch *m_pNeighbour[4]; /**< Neighbor patches, can be a null pointer */ 00172 00173 00174 }; 00175 00176 00177 //[-------------------------------------------------------] 00178 //[ Namespace ] 00179 //[-------------------------------------------------------] 00180 } // PLScene 00181 00182 00183 #endif // __PLSCENE_SCENENODE_GMMSURFACEPATCH_H__
|