PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: SNMTransformGizmo.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_TRANSFORMGIZMO_H__ 00024 #define __PLSCENE_SCENENODEMODIFIER_TRANSFORMGIZMO_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLMath/Matrix4x4.h> 00032 #include "PLScene/Scene/SceneNodeModifiers/SNMTransform.h" 00033 00034 00035 //[-------------------------------------------------------] 00036 //[ Forward declarations ] 00037 //[-------------------------------------------------------] 00038 namespace PLMath { 00039 class Ray; 00040 } 00041 00042 00043 //[-------------------------------------------------------] 00044 //[ Namespace ] 00045 //[-------------------------------------------------------] 00046 namespace PLScene { 00047 00048 00049 //[-------------------------------------------------------] 00050 //[ Classes ] 00051 //[-------------------------------------------------------] 00052 /** 00053 * @brief 00054 * Abstract transform gizmo scene node modifier base class 00055 * 00056 * @note 00057 * - The internal transform gizmo object space coordinate system we draw in is 10x10x10 so we don't have to work with to small numbers 00058 */ 00059 class SNMTransformGizmo : public SNMTransform { 00060 00061 00062 //[-------------------------------------------------------] 00063 //[ Public definitions ] 00064 //[-------------------------------------------------------] 00065 public: 00066 /** 00067 * @brief 00068 * Selected axis flags 00069 */ 00070 enum ESelected { 00071 XAxis = 1, /**< X axis is selected */ 00072 YAxis = 2, /**< Y axis is selected */ 00073 ZAxis = 4 /**< Z axis is selected */ 00074 }; 00075 00076 00077 //[-------------------------------------------------------] 00078 //[ RTTI interface ] 00079 //[-------------------------------------------------------] 00080 pl_class(PLS_RTTI_EXPORT, SNMTransformGizmo, "PLScene", PLScene::SNMTransform, "Abstract transform gizmo scene node modifier base class") 00081 // Attributes 00082 pl_attribute(DistanceFromCamera, float, 50.0f, ReadWrite, DirectValue, "Distance from the camera (for size control)", "") 00083 // Slots 00084 pl_slot_2(OnDrawTransparent, PLRenderer::Renderer&, const VisNode*, "Called on scene node transparent draw, the used renderer as first parameter, the current visibility node of this scene node, can be a null pointer as second parameter", "") 00085 pl_slot_0(OnUpdate, "Called when the scene node modifier needs to be updated", "") 00086 pl_class_end 00087 00088 00089 //[-------------------------------------------------------] 00090 //[ Public functions ] 00091 //[-------------------------------------------------------] 00092 public: 00093 /** 00094 * @brief 00095 * Returns the current selected axis (see ESelected flags) 00096 * 00097 * @return 00098 * Current selected axis 00099 */ 00100 PLS_API PLCore::uint32 GetSelected() const; 00101 00102 /** 00103 * @brief 00104 * Sets the current selected axis (see ESelected flags) 00105 * 00106 * @param[in] nSelected 00107 * Current selected axis, 0 if nothing is currently selected 00108 */ 00109 PLS_API void SetSelected(PLCore::uint32 nSelected); 00110 00111 /** 00112 * @brief 00113 * Returns whether the transform gizmo is currently in transform mode or not 00114 * 00115 * @return 00116 * 'true' if the transform gizmo is currently in transform mode, else 'false' 00117 */ 00118 PLS_API bool IsTransformMode() const; 00119 00120 /** 00121 * @brief 00122 * Sets whether the transform gizmo is currently in transform mode or not 00123 * 00124 * @param[in] bTransformMode 00125 * 'true' if the transform gizmo is currently in transform mode, else 'false' 00126 */ 00127 PLS_API void SetTransformMode(bool bTransformMode); 00128 00129 00130 //[-------------------------------------------------------] 00131 //[ Protected functions ] 00132 //[-------------------------------------------------------] 00133 protected: 00134 /** 00135 * @brief 00136 * Constructor 00137 * 00138 * @param[in] cSceneNode 00139 * Owner scene node 00140 */ 00141 PLS_API SNMTransformGizmo(SceneNode &cSceneNode); 00142 00143 /** 00144 * @brief 00145 * Destructor 00146 */ 00147 PLS_API virtual ~SNMTransformGizmo(); 00148 00149 00150 //[-------------------------------------------------------] 00151 //[ Protected virtual SceneNodeModifier functions ] 00152 //[-------------------------------------------------------] 00153 protected: 00154 PLS_API virtual void OnActivate(bool bActivate) override; 00155 00156 00157 //[-------------------------------------------------------] 00158 //[ Protected virtual SNMTransformGizmo functions ] 00159 //[-------------------------------------------------------] 00160 protected: 00161 /** 00162 * @brief 00163 * Determines the current selected axis by using a picking ray 00164 * 00165 * @param[in] cRay 00166 * Ray to use for the intersection tests, must be in the correct coordinate system used for the gizmo picking 00167 * 00168 * @return 00169 * Chosen axis (see ESelected flags) 00170 */ 00171 virtual PLCore::uint32 DetermineSelected(const PLMath::Ray &cRay) const = 0; 00172 00173 /** 00174 * @brief 00175 * Updates the transform gizmo selection 00176 * 00177 * @param[in] cRenderer 00178 * Renderer to use 00179 * @param[in] cVisNode 00180 * The current visibility node of this scene node 00181 */ 00182 virtual void UpdateSelection(PLRenderer::Renderer &cRenderer, const VisNode &cVisNode) = 0; 00183 00184 /** 00185 * @brief 00186 * Performs the transform 00187 */ 00188 virtual void PerformTransform() = 0; 00189 00190 /** 00191 * @brief 00192 * Draws the transform gizmo 00193 * 00194 * @param[in] cRenderer 00195 * Renderer to use 00196 * @param[in] pVisNode 00197 * The current visibility node of this scene node, can be a null pointer 00198 */ 00199 virtual void DrawGizmo(PLRenderer::Renderer &cRenderer, const VisNode *pVisNode) = 0; 00200 00201 00202 //[-------------------------------------------------------] 00203 //[ Protected data ] 00204 //[-------------------------------------------------------] 00205 protected: 00206 PLMath::Matrix4x4 m_mObjectSpaceToClipSpace; /**< Current object space to clip space matrix of the transform gizmo */ 00207 PLCore::uint32 m_nSelected; /**< The current selection */ 00208 bool m_bTransform; /**< Is currently a transform performed? */ 00209 00210 00211 //[-------------------------------------------------------] 00212 //[ Private functions ] 00213 //[-------------------------------------------------------] 00214 private: 00215 /** 00216 * @brief 00217 * Called on scene node transparent draw 00218 * 00219 * @param[in] cRenderer 00220 * The used renderer 00221 * @param[in] pVisNode 00222 * The current visibility node of this scene node, can be a null pointer 00223 */ 00224 void OnDrawTransparent(PLRenderer::Renderer &cRenderer, const VisNode *pVisNode); 00225 00226 /** 00227 * @brief 00228 * Called when the scene node modifier needs to be updated 00229 */ 00230 void OnUpdate(); 00231 00232 00233 }; 00234 00235 00236 //[-------------------------------------------------------] 00237 //[ Namespace ] 00238 //[-------------------------------------------------------] 00239 } // PLScene 00240 00241 00242 #endif // __PLSCENE_SCENENODEMODIFIER_TRANSFORMGIZMO_H__
|