# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

event_mouse_listener.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #ifndef NL_EVENT_MOUSE_LISTENER_H
00027 #define NL_EVENT_MOUSE_LISTENER_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 #include "nel/misc/event_listener.h"
00031 #include "nel/misc/matrix.h"
00032 #include "nel/3d/viewport.h"
00033 #include "nel/3d/frustum.h"
00034 #include "nel/3d/u_3d_mouse_listener.h"
00035 
00036 
00037 namespace NL3D 
00038 {
00039 
00040 
00041 using NLMISC::CVector;
00042 using NLMISC::CMatrix;
00043 
00044 
00052 class CEvent3dMouseListener : public NLMISC::IEventListener, public U3dMouseListener
00053 {
00054 public:
00079         //enum TMouseMode { nelStyle, edit3d, firstPerson };
00080 
00087         CEvent3dMouseListener();
00088         virtual ~CEvent3dMouseListener() {}
00089 
00091 
00097         void setMatrix (const NLMISC::CMatrix& matrix)
00098         {
00099                 _Matrix=matrix; 
00100         }
00101 
00107         void setModelMatrix(const NLMISC::CMatrix& matrix)
00108         {
00109                 _ModelMatrix = matrix ;
00110         }
00111 
00116         void setFrustrum (const CFrustum& frustrum)
00117         {
00118                 _Frustrum=frustrum;
00119         }
00120 
00125         void setViewport (const NL3D::CViewport& viewport)
00126         {
00127                 _Viewport=viewport;
00128         }
00129 
00136         void setHotSpot (const CVector& hotSpot)
00137         {
00138                 _HotSpot=hotSpot;
00139         }
00140 
00146         void setMouseMode(TMouseMode mouseMode)
00147         {
00148                 _MouseMode=mouseMode;
00149         }
00150 
00152         void enableModelMatrixEdition(bool enable = true) 
00153         { 
00154                 _EnableModelMatrixEdition = enable ;
00155         }
00156           
00157         enum TAxis { xAxis = 0, yAxis = 1, zAxis = 2 } ;
00158 
00160         void setModelMatrixRotationAxis(TAxis axis) { _CurrentModelRotationAxis = axis ;}
00161 
00163         TAxis getModelMatrixRotationAxis(void) const  { return _CurrentModelRotationAxis ;}
00164 
00165         
00166 
00171         void enableModelTranslationAxis(TAxis axis, bool enabled) ;
00172 
00177         bool isModelTranslationEnabled(TAxis axis) ;
00178 
00182         void setModelMatrixTransformMove(const NLMISC::CMatrix& transModelMove);
00183 
00185         void getModelMatrixTransformMove(NLMISC::CMatrix& transModelMove) const;
00186 
00187 
00191         void enableTranslateXYInWorld(bool enabled);
00192 
00195         bool isTranslateXYInWorldEnabled() const {return _TranslateXYInWorld;}
00196 
00202         void setSpeed (float speed)
00203         {
00204                 _Speed=speed;
00205         }
00206 
00208 
00214         const NLMISC::CMatrix& getViewMatrix () ;
00215 
00216 
00222         const NLMISC::CMatrix& getModelMatrix()
00223         {
00224                 return _ModelMatrix ;   
00225         }
00226 
00227 
00228 
00235         CVector getHotSpot () const
00236         {
00237                 return _HotSpot;
00238         }
00239 
00243         void addToServer (NLMISC::CEventServer& server);
00244 
00248         void removeFromServer (NLMISC::CEventServer& server);
00249 
00250 private:
00252         virtual void operator ()(const NLMISC::CEvent& event);
00253 
00254 
00255 
00256         TAxis                _CurrentModelRotationAxis ;
00257         bool                _XModelTranslateEnabled ;
00258         bool                _YModelTranslateEnabled ;
00259         bool                _ZModelTranslateEnabled ;
00260 
00261         CMatrix                         _Matrix;
00262         CMatrix                         _ModelMatrix ;
00263         bool                            _EnableModelMatrixEdition  ;
00264         CFrustum                        _Frustrum;
00265         CVector                         _HotSpot;
00266         NL3D::CViewport         _Viewport;
00267         bool                            _LeftPushed;
00268         bool                            _MiddlePushed;
00269         bool                            _RightPushed;
00270         float                           _X;
00271         float                           _Y;
00272         float                           _Speed;
00273         uint64                          _LastTime;
00274         TMouseMode                      _MouseMode;
00275         bool                            _TranslateXYInWorld;
00276         NLMISC::CEventListenerAsync     _AsyncListener;
00277 
00278         CMatrix                         _ModelMatrixTransformMove;
00279 
00283         void truncateVect(CVector &v) ;
00284 }; // NL3D
00285 
00286 }
00287 
00288 #endif // NL_EVENT_MOUSE_LISTENER_H
00289 
00290 /* End of event_mouse_listener.h */