PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: SCMirror.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_SCENENODE_MIRROR_H__ 00024 #define __PLSCENE_SCENENODE_MIRROR_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLMath/Polygon.h> 00032 #include "PLScene/Scene/SceneNodes/SCRenderToTexture.h" 00033 00034 00035 //[-------------------------------------------------------] 00036 //[ Namespace ] 00037 //[-------------------------------------------------------] 00038 namespace PLScene { 00039 00040 00041 //[-------------------------------------------------------] 00042 //[ Classes ] 00043 //[-------------------------------------------------------] 00044 /** 00045 * @brief 00046 * Planar mirror scene node 00047 * 00048 * @note 00049 * - The vertices of the mirror plane are on the x/y axis 00050 * - If the mirror is drawn, it will set the mirror texture automatically at the first 00051 * texture stage 00052 * - If the variable 'CameraName' is not set or the given camera is invalid, the mirror 00053 * will create a camera with the name 'Virtual camera' within it's container 00054 * - The camera defined through the variable 'CameraName' will be updated automatically by 00055 * the mirror 00056 * - If the mirror is rendered more than once per frame (multiple views, mirrored in another mirror etc.) 00057 * do NOT use a FPS limit - because the mirror only has ONE texture it will render in, this texture can't 00058 * used over multiple frames if the mirror is render more than once per frame! 00059 */ 00060 class SCMirror : public SCRenderToTexture { 00061 00062 00063 //[-------------------------------------------------------] 00064 //[ RTTI interface ] 00065 //[-------------------------------------------------------] 00066 pl_class(PLS_RTTI_EXPORT, SCMirror, "PLScene", PLScene::SCRenderToTexture, "Planar mirror scene node") 00067 // Attributes 00068 pl_attribute(Material, PLCore::String, "", ReadWrite, DirectValue, "Material to use", "Type='Material Effect Image TextureAni'") 00069 pl_attribute(DynamicMap, PLCore::String, "DynamicMap", ReadWrite, DirectValue, "Name of the material/effect parameter to assign the dynamic texture with", "") 00070 pl_attribute(Vertices, PLCore::String, "1.0 -1.0 -1.0 -1.0 -1.0 1.0 1.0 1.0", ReadWrite, DirectValue, "The vertices (x/y position) defining the mirror polygon. Each vertex has 3 components. (xyz)", "") 00071 pl_attribute(NearScale, float, 1.0f, ReadWrite, DirectValue, "Virtual camera near plane scale", "") 00072 pl_attribute(Far, float, 1000.0f, ReadWrite, DirectValue, "Virtual camera far plane", "") 00073 // Overwritten SCRenderToTexture attributes 00074 pl_attribute(FPSLimit, float, 0.0f, ReadWrite, ModifyAttr, "Frames per second limitation, if 0, there's no limitation", "Min='0.0'") 00075 // Constructors 00076 pl_constructor_0(DefaultConstructor, "Default constructor", "") 00077 pl_class_end 00078 00079 00080 //[-------------------------------------------------------] 00081 //[ Public functions ] 00082 //[-------------------------------------------------------] 00083 public: 00084 /** 00085 * @brief 00086 * Default constructor 00087 */ 00088 PLS_API SCMirror(); 00089 00090 /** 00091 * @brief 00092 * Destructor 00093 */ 00094 PLS_API virtual ~SCMirror(); 00095 00096 /** 00097 * @brief 00098 * Returns the mirror polygon 00099 * 00100 * @return 00101 * The mirror polygon 00102 * 00103 * @note 00104 * - After manipulating the vertices of the polygon you should call the polygon 00105 * function ComputePlane() to calculate the plane the mirror polygon is on. 00106 * Further call UpdateBoundingBox() to calculate the new mirror bounding box. 00107 */ 00108 PLS_API PLMath::Polygon &GetPolygon(); 00109 00110 /** 00111 * @brief 00112 * Updates the surrounding bounding box of the mirror 00113 */ 00114 PLS_API void UpdateBoundingBox(); 00115 00116 00117 //[-------------------------------------------------------] 00118 //[ Private functions ] 00119 //[-------------------------------------------------------] 00120 private: 00121 /** 00122 * @brief 00123 * Updates the virtual camera 00124 */ 00125 void UpdateVirtualCamera(); 00126 00127 /** 00128 * @brief 00129 * Sets the dynamic mirror texture 00130 */ 00131 void SetDynamicTexture(); 00132 00133 00134 //[-------------------------------------------------------] 00135 //[ Private data ] 00136 //[-------------------------------------------------------] 00137 private: 00138 float m_fWidth; /**< Mirror width */ 00139 float m_fHeight; /**< Mirror height */ 00140 PLMath::Polygon m_cPolygon; /**< Mirror polygon */ 00141 PLMesh::MeshHandler *m_pMeshHandler; /**< Mirror mesh handler, can be a null pointer */ 00142 00143 00144 //[-------------------------------------------------------] 00145 //[ Public virtual SceneNode functions ] 00146 //[-------------------------------------------------------] 00147 public: 00148 PLS_API virtual PLMesh::MeshHandler *GetMeshHandler() override; 00149 PLS_API virtual void DrawPre(PLRenderer::Renderer &cRenderer, const VisNode *pVisNode = nullptr) override; 00150 PLS_API virtual void DrawSolid(PLRenderer::Renderer &cRenderer, const VisNode *pVisNode = nullptr) override; 00151 PLS_API virtual void DrawTransparent(PLRenderer::Renderer &cRenderer, const VisNode *pVisNode = nullptr) override; 00152 00153 00154 //[-------------------------------------------------------] 00155 //[ Private virtual SceneNode functions ] 00156 //[-------------------------------------------------------] 00157 private: 00158 virtual void InitFunction() override; 00159 virtual void UpdateAABoundingBox() override; 00160 00161 00162 }; 00163 00164 00165 //[-------------------------------------------------------] 00166 //[ Namespace ] 00167 //[-------------------------------------------------------] 00168 } // PLScene 00169 00170 00171 #endif // __PLSCENE_SCENENODE_MIRROR_H__
|