PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: SNMMeshUpdate.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 __PLSCENE_SCENENODEMODIFIER_MESHUPDATE_H__ 00024 #define __PLSCENE_SCENENODEMODIFIER_MESHUPDATE_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLMath/AABoundingBox.h> 00032 #include "PLScene/Scene/SceneNodeModifiers/SNMMesh.h" 00033 00034 00035 //[-------------------------------------------------------] 00036 //[ Namespace ] 00037 //[-------------------------------------------------------] 00038 namespace PLScene { 00039 00040 00041 //[-------------------------------------------------------] 00042 //[ Forward declarations ] 00043 //[-------------------------------------------------------] 00044 class VisNode; 00045 00046 00047 //[-------------------------------------------------------] 00048 //[ Classes ] 00049 //[-------------------------------------------------------] 00050 /** 00051 * @brief 00052 * Mesh scene node modifier which performs frequent mesh updates 00053 * 00054 * @note 00055 * - Usually, there should be only once instance of this scene node modifier per scene node to avoid multiple mesh updates per frame (performance!) 00056 */ 00057 class SNMMeshUpdate : public SNMMesh { 00058 00059 00060 //[-------------------------------------------------------] 00061 //[ Public definitions ] 00062 //[-------------------------------------------------------] 00063 public: 00064 /** 00065 * @brief 00066 * Flags (SceneNodeModifier flags extension) 00067 */ 00068 enum EFlags { 00069 UpdateUnseen = 1<<2 /**< Do also perform an update if the owner scene node is currently not seen */ 00070 }; 00071 pl_enum(EFlags) 00072 pl_enum_base(SceneNodeModifier::EFlags) 00073 pl_enum_value(UpdateUnseen, "Do also perform an update if the owner scene node is currently not seen") 00074 pl_enum_end 00075 00076 00077 //[-------------------------------------------------------] 00078 //[ RTTI interface ] 00079 //[-------------------------------------------------------] 00080 pl_class(PLS_RTTI_EXPORT, SNMMeshUpdate, "PLScene", PLScene::SNMMesh, "Mesh scene node modifier which performs frequent mesh updates") 00081 // Attributes 00082 // Overwritten SceneNodeModifier attributes 00083 pl_attribute(Flags, pl_flag_type(EFlags), 0, ReadWrite, GetSet, "Flags", "") 00084 // Constructors 00085 pl_constructor_1(ParameterConstructor, SceneNode&, "Parameter constructor", "") 00086 pl_class_end 00087 00088 00089 //[-------------------------------------------------------] 00090 //[ Public functions ] 00091 //[-------------------------------------------------------] 00092 public: 00093 /** 00094 * @brief 00095 * Constructor 00096 * 00097 * @param[in] cSceneNode 00098 * Owner scene node 00099 */ 00100 PLS_API SNMMeshUpdate(SceneNode &cSceneNode); 00101 00102 /** 00103 * @brief 00104 * Destructor 00105 */ 00106 PLS_API virtual ~SNMMeshUpdate(); 00107 00108 00109 //[-------------------------------------------------------] 00110 //[ Protected virtual SceneNodeModifier functions ] 00111 //[-------------------------------------------------------] 00112 protected: 00113 PLS_API virtual void OnActivate(bool bActivate) override; 00114 00115 00116 //[-------------------------------------------------------] 00117 //[ Private functions ] 00118 //[-------------------------------------------------------] 00119 private: 00120 /** 00121 * @brief 00122 * Called when the owner scene node was added to a visibility tree 00123 * 00124 * @param[in] cVisNode 00125 * Visibility node which is representing the owner scene node within the visibility tree 00126 */ 00127 void OnAddedToVisibilityTree(VisNode &cVisNode); 00128 00129 /** 00130 * @brief 00131 * Called when the scene node modifier needs to be updated 00132 */ 00133 void OnUpdate(); 00134 00135 00136 //[-------------------------------------------------------] 00137 //[ Private event handlers ] 00138 //[-------------------------------------------------------] 00139 private: 00140 PLCore::EventHandler<VisNode &> EventHandlerAddedToVisibilityTree; 00141 PLCore::EventHandler<> EventHandlerUpdate; 00142 00143 00144 //[-------------------------------------------------------] 00145 //[ Private data ] 00146 //[-------------------------------------------------------] 00147 private: 00148 bool m_bUpdate; /**< Perform an update the next time? */ 00149 bool m_bFirstUpdate; /**< First update performed? */ 00150 PLMath::AABoundingBox m_cDefaultMeshAABoundingBox; /**< Default mesh axis align bounding box */ 00151 PLMath::AABoundingBox m_cDefaultJointAABoundingBox; /**< Default joint axis align bounding box */ 00152 00153 00154 }; 00155 00156 00157 //[-------------------------------------------------------] 00158 //[ Namespace ] 00159 //[-------------------------------------------------------] 00160 } // PLScene 00161 00162 00163 #endif // __PLSCENE_SCENENODEMODIFIER_MESHUPDATE_H__
|