PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: SNPortal.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_PORTAL_H__ 00024 #define __PLSCENE_PORTAL_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLMath/Polygon.h> 00032 #include "PLScene/Scene/SceneNode.h" 00033 00034 00035 //[-------------------------------------------------------] 00036 //[ Namespace ] 00037 //[-------------------------------------------------------] 00038 namespace PLScene { 00039 00040 00041 //[-------------------------------------------------------] 00042 //[ Classes ] 00043 //[-------------------------------------------------------] 00044 /** 00045 * @brief 00046 * Abstract portal scene node 00047 * 00048 * @note 00049 * - Please note: A portal may or may not let light and shadows pass through it. This depends on the used scene renderer, 00050 * so, by default proper portal scene node flags are set so light and shadows may always pass as default. 00051 */ 00052 class SNPortal : public SceneNode { 00053 00054 00055 //[-------------------------------------------------------] 00056 //[ Public definitions ] 00057 //[-------------------------------------------------------] 00058 public: 00059 /** 00060 * @brief 00061 * Scene node debug flags (SceneNode debug flags extension) 00062 */ 00063 enum EDebugFlags { 00064 DebugNoPortalPolygon = 1<<8, /**< Do not draw the (pink) portal polygon */ 00065 DebugPortalVertices = 1<<9 /**< Draw the (white) portal vertices */ 00066 }; 00067 pl_enum(EDebugFlags) 00068 pl_enum_base(SceneNode::EDebugFlags) 00069 pl_enum_value(DebugNoPortalPolygon, "Do not draw the (pink) portal polygon") 00070 pl_enum_value(DebugPortalVertices, "Draw the (white) portal vertices") 00071 pl_enum_end 00072 00073 00074 //[-------------------------------------------------------] 00075 //[ RTTI interface ] 00076 //[-------------------------------------------------------] 00077 pl_class(PLS_RTTI_EXPORT, SNPortal, "PLScene", PLScene::SceneNode, "Abstract portal scene node") 00078 // Attributes 00079 pl_attribute(Vertices, PLCore::String, "-1.0 -1.0 0.0 -1.0 1.0 0.0 1.0 1.0 0.0 1.0 -1.0 0.0", ReadWrite, GetSet, "Vertices (xyz, counterclockwise) defining the portal polygon. There should be at least 3 vertices.", "") 00080 // Overwritten SceneNode attributes 00081 pl_attribute(Flags, pl_flag_type(EFlags), CastShadow|ReceiveShadow, ReadWrite, GetSet, "Flags", "") 00082 pl_attribute(DebugFlags, pl_flag_type(EDebugFlags), 0, ReadWrite, GetSet, "Debug flags", "") 00083 pl_class_end 00084 00085 00086 //[-------------------------------------------------------] 00087 //[ Public RTTI get/set functions ] 00088 //[-------------------------------------------------------] 00089 public: 00090 PLS_API PLCore::String GetVertices() const; 00091 PLS_API void SetVertices(const PLCore::String &sValue); 00092 00093 00094 //[-------------------------------------------------------] 00095 //[ Public functions ] 00096 //[-------------------------------------------------------] 00097 public: 00098 /** 00099 * @brief 00100 * Returns the portal polygon 00101 * 00102 * @return 00103 * The portal polygon 00104 * 00105 * @note 00106 * - Call UpdatePolygon() after you manipulated the portal polygon 00107 */ 00108 PLS_API PLMath::Polygon &GetPolygon(); 00109 00110 /** 00111 * @brief 00112 * Call this function after you manipulated the portal polygon 00113 */ 00114 PLS_API void UpdatePolygon(); 00115 00116 /** 00117 * @brief 00118 * Returns the portal polygon in container space 00119 * 00120 * @return 00121 * The portal polygon in container space 00122 * 00123 * @note 00124 * - This container space portal polygon is rebuild automatically if required 00125 */ 00126 PLS_API const PLMath::Polygon &GetContainerPolygon(); 00127 00128 /** 00129 * @brief 00130 * Returns the warp matrix 00131 * 00132 * @return 00133 * The warp matrix 00134 * 00135 * @remarks 00136 * The warp matrix transforms from this cell space into target cell space. 00137 * 00138 * @note 00139 * - Is updated automatically 00140 */ 00141 PLS_API const PLMath::Matrix3x4 &GetWarpMatrix(); 00142 00143 00144 //[-------------------------------------------------------] 00145 //[ Protected functions ] 00146 //[-------------------------------------------------------] 00147 protected: 00148 /** 00149 * @brief 00150 * Default constructor 00151 */ 00152 PLS_API SNPortal(); 00153 00154 /** 00155 * @brief 00156 * Destructor 00157 */ 00158 PLS_API virtual ~SNPortal(); 00159 00160 00161 //[-------------------------------------------------------] 00162 //[ Protected data ] 00163 //[-------------------------------------------------------] 00164 protected: 00165 PLCore::uint8 m_nInternalPortalFlags; /**< Internal portal flags */ 00166 00167 00168 //[-------------------------------------------------------] 00169 //[ Private definitions ] 00170 //[-------------------------------------------------------] 00171 private: 00172 /** 00173 * @brief 00174 * Flags which hold ínternal portal information 00175 */ 00176 enum EInternalPortalFlags { 00177 // Recalculate 00178 RecalculateContainerPolygon = 1<<0 /**< Recalculation of the container space polygon required */ 00179 }; 00180 00181 00182 //[-------------------------------------------------------] 00183 //[ Private functions ] 00184 //[-------------------------------------------------------] 00185 private: 00186 /** 00187 * @brief 00188 * Called when the scene node container, position, rotation or scale changed 00189 */ 00190 void OnContainerPositionRotationScale(); 00191 00192 00193 //[-------------------------------------------------------] 00194 //[ Private event handlers ] 00195 //[-------------------------------------------------------] 00196 private: 00197 PLCore::EventHandler<> EventHandlerContainerPositionRotationScale; 00198 00199 00200 //[-------------------------------------------------------] 00201 //[ Private data ] 00202 //[-------------------------------------------------------] 00203 private: 00204 PLCore::String m_sVertices; /**< Vertices (xyz, counterclockwise) defining the portal polygon. There should be at least 3 vertices." */ 00205 PLMath::Polygon m_cPolygon; /**< Local portal polygon */ 00206 PLMath::Polygon m_cContainerPolygon; /**< Container space portal polygon */ 00207 00208 00209 //[-------------------------------------------------------] 00210 //[ Public virtual SceneNode functions ] 00211 //[-------------------------------------------------------] 00212 public: 00213 PLS_API virtual void DrawDebug(PLRenderer::Renderer &cRenderer, const VisNode *pVisNode = nullptr) override; 00214 00215 00216 }; 00217 00218 00219 //[-------------------------------------------------------] 00220 //[ Namespace ] 00221 //[-------------------------------------------------------] 00222 } // PLScene 00223 00224 00225 #endif // __PLSCENE_PORTAL_H__
|