00001 00005 /* Copyright, 2000 Nevrax Ltd. 00006 * 00007 * This file is part of NEVRAX NEL. 00008 * NEVRAX NEL is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2, or (at your option) 00011 * any later version. 00012 00013 * NEVRAX NEL is distributed in the hope that it will be useful, but 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * General Public License for more details. 00017 00018 * You should have received a copy of the GNU General Public License 00019 * along with NEVRAX NEL; see the file COPYING. If not, write to the 00020 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 00021 * MA 02111-1307, USA. 00022 */ 00023 00024 #ifndef NL_EVENT_MOUSE_LISTENER_H 00025 #define NL_EVENT_MOUSE_LISTENER_H 00026 00027 #include "nel/misc/types_nl.h" 00028 #include "nel/misc/event_listener.h" 00029 #include "nel/misc/matrix.h" 00030 #include "nel/3d/viewport.h" 00031 #include "nel/3d/frustum.h" 00032 #include "nel/3d/u_3d_mouse_listener.h" 00033 00034 00035 namespace NL3D 00036 { 00037 00038 00039 using NLMISC::CVector; 00040 using NLMISC::CMatrix; 00041 00042 00050 class CEvent3dMouseListener : public NLMISC::IEventListener, public U3dMouseListener 00051 { 00052 public: 00077 //enum TMouseMode { nelStyle, edit3d, firstPerson }; 00078 00085 CEvent3dMouseListener(); 00086 virtual ~CEvent3dMouseListener() {} 00087 00089 00095 void setMatrix (const NLMISC::CMatrix& matrix) 00096 { 00097 _Matrix=matrix; 00098 } 00099 00105 void setModelMatrix(const NLMISC::CMatrix& matrix) 00106 { 00107 _ModelMatrix = matrix ; 00108 } 00109 00114 void setFrustrum (const CFrustum& frustrum) 00115 { 00116 _Frustrum=frustrum; 00117 } 00118 00123 void setViewport (const NL3D::CViewport& viewport) 00124 { 00125 _Viewport=viewport; 00126 } 00127 00134 void setHotSpot (const CVector& hotSpot) 00135 { 00136 _HotSpot=hotSpot; 00137 } 00138 00144 void setMouseMode(TMouseMode mouseMode) 00145 { 00146 _MouseMode=mouseMode; 00147 } 00148 00150 void enableModelMatrixEdition(bool enable = true) 00151 { 00152 _EnableModelMatrixEdition = enable ; 00153 } 00154 00155 enum TAxis { xAxis = 0, yAxis = 1, zAxis = 2 } ; 00156 00158 void setModelMatrixRotationAxis(TAxis axis) { _CurrentModelRotationAxis = axis ;} 00159 00161 TAxis getModelMatrixRotationAxis(void) const { return _CurrentModelRotationAxis ;} 00162 00163 00164 00169 void enableModelTranslationAxis(TAxis axis, bool enabled) ; 00170 00175 bool isModelTranslationEnabled(TAxis axis) ; 00176 00180 void setModelMatrixTransformMove(const NLMISC::CMatrix& transModelMove); 00181 00183 void getModelMatrixTransformMove(NLMISC::CMatrix& transModelMove) const; 00184 00185 00189 void enableTranslateXYInWorld(bool enabled); 00190 00193 bool isTranslateXYInWorldEnabled() const {return _TranslateXYInWorld;} 00194 00200 void setSpeed (float speed) 00201 { 00202 _Speed=speed; 00203 } 00204 00206 00212 const NLMISC::CMatrix& getViewMatrix () ; 00213 00214 00220 const NLMISC::CMatrix& getModelMatrix() 00221 { 00222 return _ModelMatrix ; 00223 } 00224 00225 00226 00233 CVector getHotSpot () const 00234 { 00235 return _HotSpot; 00236 } 00237 00241 void addToServer (NLMISC::CEventServer& server); 00242 00246 void removeFromServer (NLMISC::CEventServer& server); 00247 00248 private: 00250 virtual void operator ()(const NLMISC::CEvent& event); 00251 00252 00253 00254 TAxis _CurrentModelRotationAxis ; 00255 bool _XModelTranslateEnabled ; 00256 bool _YModelTranslateEnabled ; 00257 bool _ZModelTranslateEnabled ; 00258 00259 CMatrix _Matrix; 00260 CMatrix _ModelMatrix ; 00261 bool _EnableModelMatrixEdition ; 00262 CFrustum _Frustrum; 00263 CVector _HotSpot; 00264 NL3D::CViewport _Viewport; 00265 bool _LeftPushed; 00266 bool _MiddlePushed; 00267 bool _RightPushed; 00268 float _X; 00269 float _Y; 00270 float _Speed; 00271 uint64 _LastTime; 00272 TMouseMode _MouseMode; 00273 bool _TranslateXYInWorld; 00274 NLMISC::CEventListenerAsync _AsyncListener; 00275 00276 CMatrix _ModelMatrixTransformMove; 00277 00281 void truncateVect(CVector &v); 00282 00283 virtual NLMISC::IEventListener &getEventListenerInterface() { return *this; } 00284 00285 00286 }; // NL3D 00287 00288 } 00289 00290 #endif // NL_EVENT_MOUSE_LISTENER_H 00291 00292 /* End of event_mouse_listener.h */
1.6.1