PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: PickingResult.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 __PLENGINE_PICKINGRESULT_H__ 00024 #define __PLENGINE_PICKINGRESULT_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLMath/Vector3.h> 00032 #include <PLCore/Base/Event/EventHandler.h> 00033 #include "PLEngine/PLEngine.h" 00034 00035 00036 //[-------------------------------------------------------] 00037 //[ Forward declarations ] 00038 //[-------------------------------------------------------] 00039 namespace PLScene { 00040 class SceneNode; 00041 class SceneContainer; 00042 } 00043 00044 00045 //[-------------------------------------------------------] 00046 //[ Namespace ] 00047 //[-------------------------------------------------------] 00048 namespace PLEngine { 00049 00050 00051 //[-------------------------------------------------------] 00052 //[ Classes ] 00053 //[-------------------------------------------------------] 00054 /** 00055 * @brief 00056 * Class receiving the scene picking result and offering further functionality 00057 */ 00058 class PickingResult { 00059 00060 00061 //[-------------------------------------------------------] 00062 //[ Friends ] 00063 //[-------------------------------------------------------] 00064 friend class Picking; 00065 00066 00067 //[-------------------------------------------------------] 00068 //[ Public functions ] 00069 //[-------------------------------------------------------] 00070 public: 00071 /** 00072 * @brief 00073 * Constructor 00074 */ 00075 PL_API PickingResult(); 00076 00077 /** 00078 * @brief 00079 * Destructor 00080 */ 00081 PL_API ~PickingResult(); 00082 00083 //[-------------------------------------------------------] 00084 //[ Picking result access ] 00085 //[-------------------------------------------------------] 00086 /** 00087 * @brief 00088 * Returns the picked scene node 00089 * 00090 * @return 00091 * The picked scene node, a null pointer on error 00092 */ 00093 PL_API PLScene::SceneNode *GetSceneNode() const; 00094 00095 /** 00096 * @brief 00097 * Returns the picked geometry 00098 * 00099 * @return 00100 * The picked geometry (if there's one) 00101 */ 00102 PL_API PLCore::uint32 GetGeometry() const; 00103 00104 /** 00105 * @brief 00106 * Returns the picked triangle 00107 * 00108 * @return 00109 * The picked triangle (if there's one) 00110 */ 00111 PL_API PLCore::uint32 GetTriangle() const; 00112 00113 /** 00114 * @brief 00115 * Returns the picked point in node space 00116 * 00117 * @return 00118 * The picked point in node space (if there's one) 00119 */ 00120 PL_API const PLMath::Vector3 &GetPoint() const; 00121 00122 /** 00123 * @brief 00124 * Returns the scene container the picking line and distance is in 00125 * 00126 * @return 00127 * The scene container the picking line and distance is in, a null pointer on error (in this case result is scene node space) 00128 */ 00129 PL_API PLScene::SceneContainer *GetSceneContainer() const; 00130 00131 /** 00132 * @brief 00133 * Returns the picking line start position 00134 * 00135 * @return 00136 * The picking line start position 00137 * 00138 * @see 00139 * - GetSceneContainer() 00140 */ 00141 PL_API const PLMath::Vector3 &GetLineStartPos() const; 00142 00143 /** 00144 * @brief 00145 * Returns the nearest squared distance to the line start position 00146 * 00147 * @return 00148 * The nearest squared distance to the line start position 00149 * 00150 * @see 00151 * - GetSceneContainer() 00152 * 00153 * @note 00154 * - Use for example 'Math::Sqrt(cMyPicking.GetNearestSquaredDistance())' to 00155 * get the actual nearest distance if you really need it 00156 */ 00157 PL_API float GetNearestSquaredDistance() const; 00158 00159 //[-------------------------------------------------------] 00160 //[ Further functionality ] 00161 //[-------------------------------------------------------] 00162 /** 00163 * @brief 00164 * Returns the currently picked texture coordinate (can also be outside the 0..1 interval) 00165 * 00166 * @param[out] vTexCoord 00167 * Receives the picked texture coordinate if all went fine 00168 * @param[in] nTexCoordChannel 00169 * Texture coordinate channel to use 00170 * 00171 * @return 00172 * 'true' if all went fine, else 'false' 00173 */ 00174 PL_API bool GetTextureCoordinate(PLMath::Vector2 &vTexCoord, PLCore::uint32 nTexCoordChannel = 0) const; 00175 00176 /** 00177 * @brief 00178 * Returns the currently picked wrapped texture coordinate (always between 0..1) 00179 * 00180 * @param[out] vTexCoord 00181 * Receives the picked wrapped texture coordinate if all went fine 00182 * @param[in] nTexCoordChannel 00183 * Texture coordinate channel to use 00184 * 00185 * @return 00186 * 'true' if all went fine, else 'false' 00187 */ 00188 PL_API bool GetWrappedTextureCoordinate(PLMath::Vector2 &vTexCoord, PLCore::uint32 nTexCoordChannel = 0) const; 00189 00190 00191 //[-------------------------------------------------------] 00192 //[ Private data ] 00193 //[-------------------------------------------------------] 00194 private: 00195 PLScene::SceneNode *m_pSceneNode; /**< Current picked scene node, can be a null pointer */ 00196 PLCore::uint32 m_nGeometry; /**< Picked geometry */ 00197 PLCore::uint32 m_nTriangle; /**< Picked triangle */ 00198 PLMath::Vector3 m_vPoint; /**< Picked point in node space */ 00199 PLScene::SceneContainer *m_pSceneContainer; /**< Scene container our line start position and squared distance are in, can be a null pointer */ 00200 PLMath::Vector3 m_vLineStartPos; /**< Line start position, see 'm_pSceneContainer' */ 00201 float m_fNearestSquaredDistance; /**< Nearest squared distance to the line start position, less 0 means 'not initialized yet', see 'm_pSceneContainer' */ 00202 00203 00204 }; 00205 00206 00207 //[-------------------------------------------------------] 00208 //[ Namespace ] 00209 //[-------------------------------------------------------] 00210 } // PLEngine 00211 00212 00213 #endif // __PLENGINE_PICKING_H__
|