PixelLightAPI  .
SNCellPortal.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: SNCellPortal.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_CELLPORTAL_H__
00024 #define __PLSCENE_CELLPORTAL_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLScene/Scene/SNPortal.h"
00032 
00033 
00034 //[-------------------------------------------------------]
00035 //[ Namespace                                             ]
00036 //[-------------------------------------------------------]
00037 namespace PLScene {
00038 
00039 
00040 //[-------------------------------------------------------]
00041 //[ Forward declarations                                  ]
00042 //[-------------------------------------------------------]
00043 class SCCell;
00044 class SceneNodeHandler;
00045 
00046 
00047 //[-------------------------------------------------------]
00048 //[ Classes                                               ]
00049 //[-------------------------------------------------------]
00050 /**
00051 *  @brief
00052 *    Cell-portal scene node
00053 *
00054 *  @remarks
00055 *    A cell-portal allows the viewer to look from one into another cell.
00056 */
00057 class SNCellPortal : public SNPortal {
00058 
00059 
00060     //[-------------------------------------------------------]
00061     //[ Public definitions                                    ]
00062     //[-------------------------------------------------------]
00063     public:
00064         /**
00065         *  @brief
00066         *    Scene node flags (SceneNode flags extension)
00067         */
00068         enum EFlags {
00069             NoSeeThrough  = 1<<10,  /**< It's not possible to 'see through' this cell-portal into the target cell (example usage: closed door) */
00070             NoPassThrough = 1<<11   /**< It's not possible to 'pass through' this cell-portal into the target cell (example usage: window) */
00071         };
00072         pl_enum(EFlags)
00073             pl_enum_base(SNPortal::EFlags)
00074             pl_enum_value(NoSeeThrough,     "It's not possible to 'see through' this cell-portal into the target cell (example usage: closed door)")
00075             pl_enum_value(NoPassThrough,    "It's not possible to 'pass through' this cell-portal into the target cell (example usage: window)")
00076         pl_enum_end
00077 
00078 
00079     //[-------------------------------------------------------]
00080     //[ RTTI interface                                        ]
00081     //[-------------------------------------------------------]
00082     pl_class(PLS_RTTI_EXPORT, SNCellPortal, "PLScene", PLScene::SNPortal, "Cell-portal scene node")
00083         // Attributes
00084         pl_attribute(TargetCell,    PLCore::String,         "", ReadWrite,  GetSet, "Name of the cell this cell-portal links to (for instance 'Parent.Cell2')", "")
00085             // Overwritten SceneNode attributes
00086         pl_attribute(Flags,         pl_flag_type(EFlags),   0,  ReadWrite,  GetSet, "Flags",                                                                    "")
00087         // Constructors
00088         pl_constructor_0(DefaultConstructor,    "Default constructor",  "")
00089     pl_class_end
00090 
00091 
00092     //[-------------------------------------------------------]
00093     //[ Public RTTI get/set functions                         ]
00094     //[-------------------------------------------------------]
00095     public:
00096         PLS_API PLCore::String GetTargetCell() const;
00097         PLS_API void SetTargetCell(const PLCore::String &sValue);
00098 
00099 
00100     //[-------------------------------------------------------]
00101     //[ Public functions                                      ]
00102     //[-------------------------------------------------------]
00103     public:
00104         /**
00105         *  @brief
00106         *    Default constructor
00107         */
00108         PLS_API SNCellPortal();
00109 
00110         /**
00111         *  @brief
00112         *    Destructor
00113         */
00114         PLS_API virtual ~SNCellPortal();
00115 
00116         /**
00117         *  @brief
00118         *    Returns the cell the cell-portal links to
00119         *
00120         *  @return
00121         *    The cell the cell-portal links to, a null pointer on error
00122         *    (maybe there's no node with the cell name or this node is no cell)
00123         */
00124         PLS_API SCCell *GetTargetCellInstance();
00125 
00126         /**
00127         *  @brief
00128         *    Returns the warp matrix
00129         *
00130         *  @return
00131         *    The warp matrix
00132         *
00133         *  @remarks
00134         *    The warp matrix transforms from this cell space into target cell space.
00135         *
00136         *  @note
00137         *    - Is updated automatically
00138         */
00139         PLS_API const PLMath::Matrix3x4 &GetWarpMatrix();
00140 
00141 
00142     //[-------------------------------------------------------]
00143     //[ Private definitions                                   ]
00144     //[-------------------------------------------------------]
00145     private:
00146         /**
00147         *  @brief
00148         *    Flags which hold ínternal portal information (SNPortal flags extension)
00149         */
00150         enum EInternalPortalFlags {
00151             // Recalculate
00152             RecalculateWarpMatrix = 1<<1    /**< Recalculation of warp matrix required */
00153         };
00154 
00155 
00156     //[-------------------------------------------------------]
00157     //[ Private functions                                     ]
00158     //[-------------------------------------------------------]
00159     private:
00160         /**
00161         *  @brief
00162         *    Called when the target cell container, position, rotation or scale changed
00163         */
00164         void OnCellContainerPositionRotationScale();
00165 
00166 
00167     //[-------------------------------------------------------]
00168     //[ Private event handlers                                ]
00169     //[-------------------------------------------------------]
00170     private:
00171         PLCore::EventHandler<> EventHandlerCellContainerPositionRotationScale;
00172 
00173 
00174     //[-------------------------------------------------------]
00175     //[ Private data                                          ]
00176     //[-------------------------------------------------------]
00177     private:
00178         PLCore::String     m_sTargetCell;   /**< Name of the cell this cell-portal links to (for instance 'Parent.Cell2') */
00179         PLMath::Matrix3x4  m_mWarp;         /**< This cell space into target cell space */
00180         SceneNodeHandler  *m_pTargetCell;   /**< Target cell (ALWAYS valid!) */
00181 
00182 
00183 };
00184 
00185 
00186 //[-------------------------------------------------------]
00187 //[ Namespace                                             ]
00188 //[-------------------------------------------------------]
00189 } // PLScene
00190 
00191 
00192 #endif // __PLSCENE_CELLPORTAL_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:00
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported