From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a02462.html | 2165 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2165 insertions(+) create mode 100644 docs/doxygen/nel/a02462.html (limited to 'docs/doxygen/nel/a02462.html') diff --git a/docs/doxygen/nel/a02462.html b/docs/doxygen/nel/a02462.html new file mode 100644 index 00000000..924a55ca --- /dev/null +++ b/docs/doxygen/nel/a02462.html @@ -0,0 +1,2165 @@ + + +NeL: NL3D::CEvent3dMouseListener class Reference + + + +
+

NL3D::CEvent3dMouseListener Class Reference

#include <event_mouse_listener.h> +

+

Inheritance diagram for NL3D::CEvent3dMouseListener: +

+ +NLMISC::IEventListener +NL3D::U3dMouseListener + +

Detailed Description

+CEvent3dMouseListener is a listener that handle a 3d matrix with mouse events. This can be the view matrix, or the matrix of any object.
Author:
Cyril Corvazier

+Nevrax France

+
Date:
2000
+ +

+ +

+Definition at line 52 of file event_mouse_listener.h. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Setup

enum  TAxis { xAxis = 0, +yAxis = 1, +zAxis = 2 + }
void enableModelMatrixEdition (bool enable=true)
 enable / disable model matrix edition mode. (the default deals with the with matrix)

void enableModelTranslationAxis (TAxis axis, bool enabled)
void enableTranslateXYInWorld (bool enabled)
TAxis getModelMatrixRotationAxis (void) const
 get the current axe of rotation for the model matrix

void getModelMatrixTransformMove (NLMISC::CMatrix &transModelMove) const
 see setModelMatrixTransformMove

bool isModelTranslationEnabled (TAxis axis)
bool isTranslateXYInWorldEnabled () const
void setFrustrum (const CFrustum &frustrum)
void setHotSpot (const CVector &hotSpot)
void setMatrix (const NLMISC::CMatrix &matrix)
void setModelMatrix (const NLMISC::CMatrix &matrix)
void setModelMatrixRotationAxis (TAxis axis)
 set the current axe of rotation for the model matrix

void setModelMatrixTransformMove (const NLMISC::CMatrix &transModelMove)
void setMouseMode (TMouseMode mouseMode)
void setSpeed (float speed)
void setViewport (const NL3D::CViewport &viewport)

Get

void addToServer (NLMISC::CEventServer &server)
CVector getHotSpot () const
const NLMISC::CMatrixgetModelMatrix ()
const NLMISC::CMatrixgetViewMatrix ()
void removeFromServer (NLMISC::CEventServer &server)
virtual void operator() (const NLMISC::CEvent &event)
 Internal use.

void truncateVect (CVector &v)
NLMISC::CEventListenerAsync _AsyncListener
TAxis _CurrentModelRotationAxis
bool _EnableModelMatrixEdition
CFrustum _Frustrum
CVector _HotSpot
uint64 _LastTime
bool _LeftPushed
CMatrix _Matrix
bool _MiddlePushed
CMatrix _ModelMatrix
CMatrix _ModelMatrixTransformMove
TMouseMode _MouseMode
bool _RightPushed
float _Speed
bool _TranslateXYInWorld
NL3D::CViewport _Viewport
float _X
bool _XModelTranslateEnabled
float _Y
bool _YModelTranslateEnabled
bool _ZModelTranslateEnabled

Public Types

enum  TMouseMode { nelStyle, +edit3d, +firstPerson + }

Public Member Functions

 CEvent3dMouseListener ()
virtual void operator() (const CEvent &event)=0
virtual ~CEvent3dMouseListener ()
+


Member Enumeration Documentation

+

+ + + + +
+ + +
enum NL3D::CEvent3dMouseListener::TAxis +
+
+ + + + + +
+   + + +

+

Enumeration values:
+ + + + +
xAxis  +
yAxis  +
zAxis  +
+
+ +

+Definition at line 157 of file event_mouse_listener.h. +

+Referenced by getModelMatrixRotationAxis(). +

+

00157 { xAxis = 0, yAxis = 1, zAxis = 2 } ;
+
+

+ + + + +
+ + +
enum NL3D::U3dMouseListener::TMouseMode [inherited] +
+
+ + + + + +
+   + + +

+Mouse mode. There is two move modes: 3d editor style and NeL style. Default mode is NeL style.

+(nelStyle) NeL style is: MouseRotateHotSpot: CTRL + RIGHTMOUSE MouseTranslateXYHotSpot: CTRL + LEFTMOUSE MouseTranslateZHotSpot: CTRL + SHIFT + LEFTMOUSE MouseZoomHotSpot: ALT + LEFTMOUSE

+(edit3dStyle) 3d editor style is: MouseRotateHotSpot: ALT + MIDDLEMOUSE MouseTranslateXYHotSpot: MIDDLEMOUSE MouseTranslateZHotSpot: CTRL + MIDDLEMOUSE

+(firstPerson) First person shoorter style is: MouseRotateView: MOUSE MOVE KeyUp: MOVE FORWARD KeyDown: MOVE BACKWARD Left: STRAF LEFT Right: STRAF RIGHT PageUp: MOVE UP PageDown: MOVE DOWN

Enumeration values:
+ + + + +
nelStyle  +
edit3d  +
firstPerson  +
+
+ +

+Definition at line 70 of file u_3d_mouse_listener.h. +

+

00070 { nelStyle, edit3d, firstPerson };
+
+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + +
NL3D::CEvent3dMouseListener::CEvent3dMouseListener  ) 
+
+ + + + + +
+   + + +

+Constructor. You should call setMatrix, setFrustrum, setViewport, setHotStop and setMouseMode to initialize the whole object. By default, the viewmatrix is identity, the frustrum is (-1,1,-1,1,1,-1), the hot spot is (0,0,0) and the viewport is fullscreen. The mouse mode is set to the NelStyle. +

+Definition at line 40 of file event_mouse_listener.cpp. +

+References _EnableModelMatrixEdition, _Frustrum, _HotSpot, _LastTime, _Matrix, _ModelMatrix, _MouseMode, _TranslateXYInWorld, _Viewport, NLMISC::CMatrix::identity(), NL3D::CFrustum::init(), NL3D::CViewport::initFullScreen(), NLMISC::CVector::set(), and setSpeed(). +

+

00040                                              :  _CurrentModelRotationAxis(zAxis)
+00041                                                                                           ,_XModelTranslateEnabled(true)
+00042                                                                                                   ,_YModelTranslateEnabled(true)
+00043                                                                                                   ,_ZModelTranslateEnabled(true)
+00044 {
+00045         _Matrix.identity();
+00046         _ModelMatrix.identity() ;
+00047         _EnableModelMatrixEdition = false ;
+00048         _HotSpot.set (0,0,0);
+00049         _Viewport.initFullScreen();
+00050         _Frustrum.init (2.f, 2.f, -1.f, 1.f);
+00051         _MouseMode=nelStyle;
+00052         setSpeed (10.f);
+00053         _LastTime=CTime::getLocalTime ();
+00054         _TranslateXYInWorld= false;
+00055 }
+
+

+ + + + +
+ + + + + + + + + +
virtual NL3D::CEvent3dMouseListener::~CEvent3dMouseListener  )  [inline, virtual]
+
+ + + + + +
+   + + +

+ +

+Definition at line 88 of file event_mouse_listener.h. +

+

00088 {}
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + +
void NL3D::CEvent3dMouseListener::addToServer NLMISC::CEventServer server  ) 
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 323 of file event_mouse_listener.cpp. +

+References _AsyncListener, NLMISC::CEventServer::addListener(), NLMISC::CEventListenerAsync::addToServer(), NLMISC::EventMouseDownId, NLMISC::EventMouseMoveId, NLMISC::EventMouseUpId, and NLMISC::EventMouseWheelId. +

+Referenced by NL3D::CDriverUser::create3dMouseListener(). +

+

00324 {
+00325         server.addListener (EventMouseMoveId, this);
+00326         server.addListener (EventMouseDownId, this);
+00327         server.addListener (EventMouseUpId, this);
+00328         server.addListener (EventMouseWheelId, this);
+00329         _AsyncListener.addToServer (server);
+00330 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CEvent3dMouseListener::enableModelMatrixEdition bool  enable = true  )  [inline]
+
+ + + + + +
+   + + +

+enable / disable model matrix edition mode. (the default deals with the with matrix) +

+ +

+Definition at line 152 of file event_mouse_listener.h. +

+References _EnableModelMatrixEdition. +

+

00153         { 
+00154                 _EnableModelMatrixEdition = enable ;
+00155         }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CEvent3dMouseListener::enableModelTranslationAxis TAxis  axis,
bool  enabled
+
+ + + + + +
+   + + +

+enable / disable an axe for translation (model matrix)

Parameters:
+ + + +
axis the axis to enable / diable
enabled true if the trnaslation is permitted on that axis
+
+ +

+Definition at line 59 of file event_mouse_listener.cpp. +

+References _XModelTranslateEnabled, _YModelTranslateEnabled, _ZModelTranslateEnabled, xAxis, yAxis, and zAxis. +

+

00060 {
+00061         switch (axis)
+00062         {
+00063                 case xAxis: _XModelTranslateEnabled = enabled ; break ;
+00064                 case yAxis: _YModelTranslateEnabled = enabled ; break ;
+00065                 case zAxis: _ZModelTranslateEnabled = enabled ; break ;
+00066         }
+00067 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CEvent3dMouseListener::enableTranslateXYInWorld bool  enabled  ) 
+
+ + + + + +
+   + + +

+if true, XY translation is made in XY World plane (instead of XY view plane). false by default. +

+Definition at line 412 of file event_mouse_listener.cpp. +

+References _TranslateXYInWorld. +

+

00413 {
+00414         _TranslateXYInWorld= enabled;
+00415 }
+
+

+ + + + +
+ + + + + + + + + +
CVector NL3D::CEvent3dMouseListener::getHotSpot  )  const [inline, virtual]
+
+ + + + + +
+   + + +

+Get the current hot spot.

Returns:
the target used when the mouse move. It can be for exemple the center. of the selected object. The hotspot is not modified by mouse events.
+
See also:
getViewMatrix()
+ +

+Implements NL3D::U3dMouseListener. +

+Definition at line 235 of file event_mouse_listener.h. +

+References _HotSpot. +

+

00236         {
+00237                 return _HotSpot;
+00238         }
+
+

+ + + + +
+ + + + + + + + + +
const NLMISC::CMatrix& NL3D::CEvent3dMouseListener::getModelMatrix  )  [inline]
+
+ + + + + +
+   + + +

+Get the current model matrix.

Returns:
The current view matrix.
+
See also:
setModelMatrix()
+ +

+Definition at line 222 of file event_mouse_listener.h. +

+References _ModelMatrix. +

+

00223         {
+00224                 return _ModelMatrix ;   
+00225         }
+
+

+ + + + +
+ + + + + + + + + + +
TAxis NL3D::CEvent3dMouseListener::getModelMatrixRotationAxis void   )  const [inline]
+
+ + + + + +
+   + + +

+get the current axe of rotation for the model matrix +

+ +

+Definition at line 163 of file event_mouse_listener.h. +

+References _CurrentModelRotationAxis, and TAxis. +

+

00163 { return _CurrentModelRotationAxis ;}
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CEvent3dMouseListener::getModelMatrixTransformMove NLMISC::CMatrix transModelMove  )  const
+
+ + + + + +
+   + + +

+see setModelMatrixTransformMove +

+ +

+Definition at line 422 of file event_mouse_listener.cpp. +

+References _ModelMatrixTransformMove. +

+

00423 {
+00424         transModelMove= _ModelMatrixTransformMove;
+00425 }
+
+

+ + + + +
+ + + + + + + + + +
const NLMISC::CMatrix & NL3D::CEvent3dMouseListener::getViewMatrix  )  [virtual]
+
+ + + + + +
+   + + +

+Get the current view matrix.

Returns:
The current view matrix.
+
See also:
setMatrix()
+ +

+Implements NL3D::U3dMouseListener. +

+Definition at line 341 of file event_mouse_listener.cpp. +

+References _AsyncListener, _LastTime, _Matrix, _MouseMode, _Speed, NLMISC::CMatrix::getPos(), NLMISC::CEventListenerAsync::isKeyDown(), NLMISC::KeyDOWN, NLMISC::KeyLEFT, NLMISC::KeyNEXT, NLMISC::KeyPRIOR, NLMISC::KeyRIGHT, NLMISC::KeyUP, NLMISC::CMatrix::mulVector(), NLMISC::CVector::normalize(), NLMISC::CMatrix::setPos(), and uint32. +

+

00342 {
+00343         // Mode first person ?
+00344         if (_MouseMode==firstPerson)
+00345         {
+00346                 // CVector
+00347                 CVector dir (0,0,0);
+00348                 bool find=false;
+00349 
+00350                 // Key pushed ?
+00351                 if (_AsyncListener.isKeyDown (KeyUP))
+00352                 {
+00353                         dir+=CVector (0, 1, 0);
+00354                         find=true;
+00355                 }
+00356                 if (_AsyncListener.isKeyDown (KeyDOWN))
+00357                 {
+00358                         dir+=CVector (0, -1, 0);
+00359                         find=true;
+00360                 }
+00361                 if (_AsyncListener.isKeyDown (KeyRIGHT))
+00362                 {
+00363                         dir+=CVector (1, 0, 0);
+00364                         find=true;
+00365                 }
+00366                 if (_AsyncListener.isKeyDown (KeyLEFT))
+00367                 {
+00368                         dir+=CVector (-1, 0, 0);
+00369                         find=true;
+00370                 }
+00371                 if (_AsyncListener.isKeyDown (KeyNEXT))
+00372                 {
+00373                         dir+=CVector (0, 0, -1);
+00374                         find=true;
+00375                 }
+00376                 if (_AsyncListener.isKeyDown (KeyPRIOR))
+00377                 {
+00378                         dir+=CVector (0, 0, 1);
+00379                         find=true;
+00380                 }
+00381 
+00382                 // key found ?
+00383                 if (find)
+00384                 {
+00385                         // Time elapsed
+00386                         uint32 milli=(uint32)(CTime::getLocalTime ()-_LastTime);
+00387 
+00388                         // Speed
+00389                         float dPos=_Speed*(float)milli/1000.f;
+00390 
+00391                         // Good direction
+00392                         dir.normalize ();
+00393                         dir*=dPos;
+00394 
+00395                         // Orientation
+00396                         dir=_Matrix.mulVector (dir);
+00397 
+00398                         // New position
+00399                         _Matrix.setPos (_Matrix.getPos ()+dir);
+00400                 }
+00401         }
+00402 
+00403         // Last time
+00404         _LastTime=CTime::getLocalTime ();
+00405 
+00406         
+00407         // Return the matrix
+00408         return _Matrix;
+00409 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CEvent3dMouseListener::isModelTranslationEnabled TAxis  axis  ) 
+
+ + + + + +
+   + + +

+check wether translation on the given axis is permitted

Parameters:
+ + +
axis the axis to check
+
+
Returns:
true if translation is permitted
+ +

+Definition at line 69 of file event_mouse_listener.cpp. +

+References _XModelTranslateEnabled, _YModelTranslateEnabled, _ZModelTranslateEnabled, xAxis, yAxis, and zAxis. +

+

00070 {
+00071         switch (axis)
+00072         {
+00073                 case xAxis: return _XModelTranslateEnabled ; break ;
+00074                 case yAxis: return _YModelTranslateEnabled ; break ;
+00075                 case zAxis: return _ZModelTranslateEnabled ; break ;
+00076                 default: return false ; break ;
+00077         }       
+00078 }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CEvent3dMouseListener::isTranslateXYInWorldEnabled  )  const [inline]
+
+ + + + + +
+   + + +

+

See also:
translateXYInWorld()
+ +

+Definition at line 195 of file event_mouse_listener.h. +

+References _TranslateXYInWorld. +

+

00195 {return _TranslateXYInWorld;}
+
+

+ + + + +
+ + + + + + + + + + +
virtual void NLMISC::IEventListener::operator() const CEvent event  )  [pure virtual, inherited]
+
+ + + + + +
+   + + +

+Call back of the listener.

Parameters:
+ + +
event is the event send to the listener
+
+ +

+Implemented in NLMISC::CEventListenerAsync.

+

+ + + + +
+ + + + + + + + + + +
void NL3D::CEvent3dMouseListener::operator() const NLMISC::CEvent event  )  [private, virtual]
+
+ + + + + +
+   + + +

+Internal use. +

+ +

+Definition at line 89 of file event_mouse_listener.cpp. +

+References _CurrentModelRotationAxis, _EnableModelMatrixEdition, _Frustrum, _HotSpot, _Matrix, _ModelMatrix, _ModelMatrixTransformMove, _MouseMode, _TranslateXYInWorld, _Viewport, _X, _Y, NLMISC::altButton, NLMISC::CEventMouse::Button, NLMISC::ctrlButton, NLMISC::CEventMouseWheel::Direction, NLMISC::EventMouseDownId, NLMISC::EventMouseMoveId, NLMISC::EventMouseUpId, NLMISC::EventMouseWheelId, NLMISC::CMatrix::getI(), NLMISC::CMatrix::getJ(), NLMISC::CMatrix::getK(), NLMISC::CMatrix::getPos(), NL3D::CViewport::getRayWithPoint(), NLMISC::CMatrix::identity(), NLMISC::CPlane::intersect(), NLMISC::CMatrix::invert(), NLMISC::leftButton, NLMISC::CPlane::make(), NLMISC::middleButton, NLMISC::CVector::normalize(), NLMISC::CMatrix::normalize(), NLMISC::Pi, r, NLMISC::rightButton, NLMISC::CMatrix::rotate(), NLMISC::CMatrix::rotateX(), NLMISC::CMatrix::rotateZ(), NLMISC::CMatrix::setPos(), NLMISC::shiftButton, truncateVect(), NLMISC::CVector::x, NLMISC::CEventMouse::X, xAxis, NLMISC::CVector::y, NLMISC::CEventMouse::Y, yAxis, NLMISC::CVector::z, and zAxis. +

+

00090 {
+00091         CEventMouse* mouseEvent=(CEventMouse*)&event;
+00092         if (event==EventMouseMoveId)
+00093         {
+00094                 bool bRotate=false;
+00095                 bool bTranslateXY=false;
+00096                 bool bTranslateZ=false;
+00097                 bool bZoom=false;
+00098                 
+00099 
+00100                 // Rotate Axis
+00101                 CVector axis;
+00102 
+00103                 if (_MouseMode==nelStyle)
+00104                 {
+00105                         bRotate=(mouseEvent->Button==(ctrlButton|rightButton));
+00106                         bTranslateXY=(mouseEvent->Button==(ctrlButton|leftButton));
+00107                         bTranslateZ=(mouseEvent->Button==(ctrlButton|shiftButton|leftButton));
+00108                         bZoom=(mouseEvent->Button==(altButton|leftButton));
+00109                         axis=_HotSpot;
+00110                 }
+00111                 else if (_MouseMode==edit3d)
+00112                 {
+00113                         bRotate=(mouseEvent->Button==(altButton|middleButton)) || (mouseEvent->Button==(altButton|leftButton));
+00114                         bTranslateXY=(mouseEvent->Button==(ctrlButton|leftButton)) || (mouseEvent->Button==middleButton);
+00115                         bTranslateZ=(mouseEvent->Button==(ctrlButton|shiftButton|leftButton)) || (mouseEvent->Button==(ctrlButton|middleButton));
+00116                         bZoom=(mouseEvent->Button==(shiftButton|leftButton)) || (mouseEvent->Button==(ctrlButton|altButton|middleButton));
+00117                         axis=_HotSpot;
+00118                 }
+00119                 else // if (_MouseMode==firstPerson)
+00120                 {
+00121                         bRotate=(mouseEvent->Button&leftButton)!=0;
+00122                         bTranslateXY=false;
+00123                         bTranslateZ=false;
+00124                         bZoom=false;
+00125                         axis=_Matrix.getPos();
+00126                 }
+00127 
+00128                 if (bRotate)
+00129                 {
+00130                         if (!_EnableModelMatrixEdition)
+00131                         {                                                       
+00132                                 // First in the hotSpot
+00133                                 CMatrix comeFromHotSpot=_Matrix;
+00134                                 comeFromHotSpot.setPos (axis);
+00135 
+00136                                 // Then turn along the Z axis with X mouse
+00137                                 CMatrix turnZ;
+00138                                 turnZ.identity();
+00139                                 turnZ.rotateZ ((float) Pi*2.f*(_X-mouseEvent->X));
+00140 
+00141                                 // Then turn along the X axis with Y mouse
+00142                                 CMatrix turnX;
+00143                                 turnX.identity();
+00144                                 turnX.rotateX ((float) Pi*2.f*(mouseEvent->Y-_Y));
+00145 
+00146                                 // Then come back from hotspot
+00147                                 CMatrix goToHotSpot=comeFromHotSpot;
+00148                                 goToHotSpot.invert();
+00149 
+00150                                 // Make the matrix
+00151                                 CMatrix negPivot, Pivot;
+00152                                 negPivot.identity();
+00153                                 negPivot.setPos (-axis);
+00154                                 Pivot.identity();
+00155                                 Pivot.setPos (axis);
+00156 
+00157                                 // Make this transformation \\//
+00158                                 //_Matrix=Pivot*turnZ*negPivot*comeFromHotSpot*turnX*goToHotSpot*_Matrix;
+00159                                 Pivot*=turnZ;
+00160                                 Pivot*=negPivot;
+00161                                 Pivot*=comeFromHotSpot;
+00162                                 Pivot*=turnX;
+00163                                 Pivot*=goToHotSpot;
+00164 
+00165                                 
+00166                                 Pivot*=_Matrix;
+00167                                 _Matrix=Pivot;                                          
+00168                                 // Normalize, too much transformation could give an ugly matrix..
+00169                                 _Matrix.normalize (CMatrix::XYZ);                       
+00170                         
+00171                         }
+00172                         else
+00173                         {
+00174                                 CVector pos = _ModelMatrix.getPos() ;
+00175                                 NLMISC::CQuat r ;
+00176                                 switch (_CurrentModelRotationAxis)
+00177                                 {
+00178                                         case xAxis : r = CQuat(CAngleAxis(_ModelMatrix.getI(), (float) Pi*2.f*(_X-mouseEvent->X))) ; break ;
+00179                                         case yAxis : r = CQuat(CAngleAxis(_ModelMatrix.getJ(), (float) Pi*2.f*(_X-mouseEvent->X))) ; break ;
+00180                                         case zAxis : r = CQuat(CAngleAxis(_ModelMatrix.getK(), (float) Pi*2.f*(_X-mouseEvent->X))) ; break ;
+00181                                 } ;
+00182 
+00183                         
+00184                                 CMatrix rm ;
+00185                                 rm.rotate(r) ;
+00186 
+00187                                 _ModelMatrix = rm * _ModelMatrix ;
+00188                                 _ModelMatrix.setPos(pos) ;
+00189 
+00190                                 _ModelMatrix.normalize (CMatrix::XYZ);
+00191                         }
+00192                 }
+00193 
+00194 
+00195                 if (bTranslateXY||bTranslateZ||bZoom)
+00196                 {
+00197                         // Move in plane
+00198 
+00199                         CPlane plane;
+00200 
+00201                         // For precision problem, do all the compute local to the hotspot/model.
+00202                         CVector         decal;
+00203 
+00204                         // Plane of the hotspot
+00205                         if (! _EnableModelMatrixEdition)
+00206                         {                       
+00207                                 decal= axis;
+00208                         }
+00209                         else
+00210                         {                       
+00211                                 decal= _ModelMatrix.getPos();
+00212                         }
+00213                         // Choose plane to move on
+00214                         if (bTranslateXY && _TranslateXYInWorld)
+00215                         {
+00216                                 plane.make (CVector::K, CVector::Null);
+00217                         }
+00218                         else
+00219                         {
+00220                                 plane.make (_Matrix.getJ(), CVector::Null);
+00221                         }
+00222 
+00223 
+00224                         // Get ray from mouse point
+00225                         CMatrix         localViewMatrix= _Matrix;
+00226                         localViewMatrix.setPos(_Matrix.getPos() - decal);
+00227                         CVector localPoint1, localPoint2;
+00228                         CVector pos, dir;
+00229                         _Viewport.getRayWithPoint (_X, _Y, pos, dir, localViewMatrix, _Frustrum);
+00230                         localPoint1=plane.intersect (pos, pos+dir);
+00231                         _Viewport.getRayWithPoint (mouseEvent->X, mouseEvent->Y, pos, dir, localViewMatrix, _Frustrum);
+00232                         localPoint2=plane.intersect (pos, pos+dir);
+00233 
+00234                         // Move the camera
+00235                         if (bTranslateXY)
+00236                         {
+00237                                 if (! _EnableModelMatrixEdition)
+00238                                 {
+00239                                         _Matrix.setPos(_Matrix.getPos()+localPoint1-localPoint2);
+00240                                 }
+00241                                 else
+00242                                 {
+00243                                         CVector dir =  - localPoint1 + localPoint2 ;
+00244                                         // transform the translation as needed.
+00245                                         dir= _ModelMatrixTransformMove * dir;
+00246                                         truncateVect(dir) ;
+00247                                         _ModelMatrix.setPos(_ModelMatrix.getPos()+dir);
+00248                                 }
+00249                         }
+00250                         else if (bTranslateZ)
+00251                         {
+00252                                 CVector vect=localPoint1-localPoint2;
+00253                                 if (! _EnableModelMatrixEdition)
+00254                                 {
+00255                                         _Matrix.setPos(_Matrix.getPos()+_Matrix.getK()*(vect.x+vect.y+vect.z));
+00256                                 }
+00257                                 else
+00258                                 {
+00259                                         CVector dir = _Matrix.getK()*(vect.x+vect.y+vect.z) ;
+00260                                         // transform the translation as needed.
+00261                                         dir= _ModelMatrixTransformMove * dir;
+00262                                         truncateVect(dir) ;
+00263                                         _ModelMatrix.setPos(_ModelMatrix.getPos()+dir);
+00264                                 }
+00265                         }
+00266                         else if (bZoom)
+00267                         {
+00268                                 CVector vect=localPoint1-localPoint2;
+00269                                 CVector direc=axis-_Matrix.getPos();
+00270                                 direc.normalize();
+00271                                 if (! _EnableModelMatrixEdition)
+00272                                 {
+00273                                         _Matrix.setPos(_Matrix.getPos()+direc*(vect.x+vect.y+vect.z));
+00274                                 }
+00275                                 else
+00276                                 {
+00277                                         // transform the translation as needed.
+00278                                         direc= _ModelMatrixTransformMove * direc;
+00279                                         direc.normalize();
+00280                                         _ModelMatrix.setPos(_ModelMatrix.getPos()+direc*(vect.x+vect.y+vect.z));
+00281                                 }
+00282                         }
+00283                 }
+00284                 
+00285 
+00286                 // Update mouse position
+00287                 _X=mouseEvent->X;
+00288                 _Y=mouseEvent->Y;
+00289         }
+00290         else if (event==EventMouseDownId)
+00291         {
+00292                 // Update mouse position
+00293                 _X=mouseEvent->X;
+00294                 _Y=mouseEvent->Y;
+00295         }
+00296         else if (event==EventMouseUpId)
+00297         {
+00298                 // Update mouse position
+00299                 _X=mouseEvent->X;
+00300                 _Y=mouseEvent->Y;
+00301         }
+00302         else if (event==EventMouseWheelId)
+00303         {
+00304                 // Zoom..
+00305                 CEventMouseWheel* mouseEvent=(CEventMouseWheel*)&event;
+00306 
+00307                 CVector direc=_HotSpot-_Matrix.getPos();
+00308                 if (! _EnableModelMatrixEdition)
+00309                 {
+00310                         _Matrix.setPos(_Matrix.getPos()+direc*(mouseEvent->Direction?0.1f:-0.1f));
+00311                 }
+00312                 else
+00313                 {
+00314                         CVector dir = direc*(mouseEvent->Direction?0.1f:-0.1f) ;
+00315                         // transform the translation as needed.
+00316                         dir= _ModelMatrixTransformMove * dir;
+00317                         truncateVect(dir) ;
+00318                         _ModelMatrix.setPos(_ModelMatrix.getPos() + dir);
+00319                 }
+00320         }
+00321 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CEvent3dMouseListener::removeFromServer NLMISC::CEventServer server  ) 
+
+ + + + + +
+   + + +

+Unregister the listener to the server. +

+Definition at line 332 of file event_mouse_listener.cpp. +

+References _AsyncListener, NLMISC::EventMouseDownId, NLMISC::EventMouseMoveId, NLMISC::EventMouseUpId, NLMISC::EventMouseWheelId, NLMISC::CEventListenerAsync::removeFromServer(), and NLMISC::CEventServer::removeListener(). +

+

00333 {
+00334         server.removeListener (EventMouseMoveId, this);
+00335         server.removeListener (EventMouseDownId, this);
+00336         server.removeListener (EventMouseUpId, this);
+00337         server.removeListener (EventMouseWheelId, this);
+00338         _AsyncListener.removeFromServer (server);
+00339 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CEvent3dMouseListener::setFrustrum const CFrustum frustrum  )  [inline, virtual]
+
+ + + + + +
+   + + +

+Set the current frustrum to use.

Parameters:
+ + +
frustrum is the frustrum.
+
+ +

+Implements NL3D::U3dMouseListener. +

+Definition at line 116 of file event_mouse_listener.h. +

+References _Frustrum. +

+

00117         {
+00118                 _Frustrum=frustrum;
+00119         }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CEvent3dMouseListener::setHotSpot const CVector hotSpot  )  [inline, virtual]
+
+ + + + + +
+   + + +

+Set the current hot spot.

Parameters:
+ + +
hotSpot is the target to use when the mouse move. It can be for exemple the center. of the selected object. The hotspot is not modified by mouse events.
+
+
See also:
getViewMatrix()
+ +

+Implements NL3D::U3dMouseListener. +

+Definition at line 136 of file event_mouse_listener.h. +

+References _HotSpot. +

+

00137         {
+00138                 _HotSpot=hotSpot;
+00139         }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CEvent3dMouseListener::setMatrix const NLMISC::CMatrix matrix  )  [inline, virtual]
+
+ + + + + +
+   + + +

+Set both the current view matrix to use.

Parameters:
+ + +
matrix is the matrix to set.
+
+
See also:
getViewMatrix()
+ +

+Implements NL3D::U3dMouseListener. +

+Definition at line 97 of file event_mouse_listener.h. +

+References _Matrix, and matrix. +

+

00098         {
+00099                 _Matrix=matrix; 
+00100         }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CEvent3dMouseListener::setModelMatrix const NLMISC::CMatrix matrix  )  [inline]
+
+ + + + + +
+   + + +

+Set the model matrix only

+param matrix is the matrix to set. getModelMatrix() +

+Definition at line 107 of file event_mouse_listener.h. +

+References _ModelMatrix, and matrix. +

+

00108         {
+00109                 _ModelMatrix = matrix ;
+00110         }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CEvent3dMouseListener::setModelMatrixRotationAxis TAxis  axis  )  [inline]
+
+ + + + + +
+   + + +

+set the current axe of rotation for the model matrix +

+ +

+Definition at line 160 of file event_mouse_listener.h. +

+References _CurrentModelRotationAxis. +

+

00160 { _CurrentModelRotationAxis = axis ;}
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CEvent3dMouseListener::setModelMatrixTransformMove const NLMISC::CMatrix transModelMove  ) 
+
+ + + + + +
+   + + +

+Each move of the modelMatrix is first transformed by this matrix before applying. NB: rot are still done in local Trans part is removed +

+Definition at line 417 of file event_mouse_listener.cpp. +

+References _ModelMatrixTransformMove. +

+

00418 {
+00419         _ModelMatrixTransformMove= transModelMove;
+00420 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CEvent3dMouseListener::setMouseMode TMouseMode  mouseMode  )  [inline, virtual]
+
+ + + + + +
+   + + +

+Set the mouse mode.

Parameters:
+ + +
mouseMode is the mode you want to use.
+
+
See also:
TMouseMode
+ +

+Implements NL3D::U3dMouseListener. +

+Definition at line 146 of file event_mouse_listener.h. +

+References _MouseMode. +

+

00147         {
+00148                 _MouseMode=mouseMode;
+00149         }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CEvent3dMouseListener::setSpeed float  speed  )  [inline, virtual]
+
+ + + + + +
+   + + +

+Set the speed for first person mode. Default 10.f;

Parameters:
+ + +
speed is in unit per second.
+
+
See also:
TMouseMode
+ +

+Implements NL3D::U3dMouseListener. +

+Definition at line 202 of file event_mouse_listener.h. +

+References _Speed. +

+Referenced by CEvent3dMouseListener(). +

+

00203         {
+00204                 _Speed=speed;
+00205         }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CEvent3dMouseListener::setViewport const NL3D::CViewport viewport  )  [inline, virtual]
+
+ + + + + +
+   + + +

+Set the viewport in use in the window. By default, the viewport is fullwindow.

Parameters:
+ + +
viewport is the viewport to use. All events outside the viewport are ignored.
+
+ +

+Implements NL3D::U3dMouseListener. +

+Definition at line 125 of file event_mouse_listener.h. +

+References _Viewport. +

+

00126         {
+00127                 _Viewport=viewport;
+00128         }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CEvent3dMouseListener::truncateVect CVector v  )  [private]
+
+ + + + + +
+   + + +

+remove composant of translations that are not permitted

See also:
enableModelTranslationAxis()
+ +

+Definition at line 81 of file event_mouse_listener.cpp. +

+References _XModelTranslateEnabled, _YModelTranslateEnabled, _ZModelTranslateEnabled, and v. +

+Referenced by operator()(). +

+

00082 {
+00083         if (!_XModelTranslateEnabled) v.x = 0.f ;       
+00084         if (!_YModelTranslateEnabled) v.y = 0.f ;       
+00085         if (!_ZModelTranslateEnabled) v.z = 0.f ;       
+00086 }
+
+


Field Documentation

+

+ + + + +
+ + +
NLMISC::CEventListenerAsync NL3D::CEvent3dMouseListener::_AsyncListener [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 276 of file event_mouse_listener.h. +

+Referenced by addToServer(), getViewMatrix(), and removeFromServer().

+

+ + + + +
+ + +
TAxis NL3D::CEvent3dMouseListener::_CurrentModelRotationAxis [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 256 of file event_mouse_listener.h. +

+Referenced by getModelMatrixRotationAxis(), operator()(), and setModelMatrixRotationAxis().

+

+ + + + +
+ + +
bool NL3D::CEvent3dMouseListener::_EnableModelMatrixEdition [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 263 of file event_mouse_listener.h. +

+Referenced by CEvent3dMouseListener(), enableModelMatrixEdition(), and operator()().

+

+ + + + +
+ + +
CFrustum NL3D::CEvent3dMouseListener::_Frustrum [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 264 of file event_mouse_listener.h. +

+Referenced by CEvent3dMouseListener(), operator()(), and setFrustrum().

+

+ + + + +
+ + +
CVector NL3D::CEvent3dMouseListener::_HotSpot [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 265 of file event_mouse_listener.h. +

+Referenced by CEvent3dMouseListener(), getHotSpot(), operator()(), and setHotSpot().

+

+ + + + +
+ + +
uint64 NL3D::CEvent3dMouseListener::_LastTime [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 273 of file event_mouse_listener.h. +

+Referenced by CEvent3dMouseListener(), and getViewMatrix().

+

+ + + + +
+ + +
bool NL3D::CEvent3dMouseListener::_LeftPushed [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 267 of file event_mouse_listener.h.

+

+ + + + +
+ + +
CMatrix NL3D::CEvent3dMouseListener::_Matrix [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 261 of file event_mouse_listener.h. +

+Referenced by CEvent3dMouseListener(), getViewMatrix(), operator()(), and setMatrix().

+

+ + + + +
+ + +
bool NL3D::CEvent3dMouseListener::_MiddlePushed [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 268 of file event_mouse_listener.h.

+

+ + + + +
+ + +
CMatrix NL3D::CEvent3dMouseListener::_ModelMatrix [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 262 of file event_mouse_listener.h. +

+Referenced by CEvent3dMouseListener(), getModelMatrix(), operator()(), and setModelMatrix().

+

+ + + + +
+ + +
CMatrix NL3D::CEvent3dMouseListener::_ModelMatrixTransformMove [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 278 of file event_mouse_listener.h. +

+Referenced by getModelMatrixTransformMove(), operator()(), and setModelMatrixTransformMove().

+

+ + + + +
+ + +
TMouseMode NL3D::CEvent3dMouseListener::_MouseMode [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 274 of file event_mouse_listener.h. +

+Referenced by CEvent3dMouseListener(), getViewMatrix(), operator()(), and setMouseMode().

+

+ + + + +
+ + +
bool NL3D::CEvent3dMouseListener::_RightPushed [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 269 of file event_mouse_listener.h.

+

+ + + + +
+ + +
float NL3D::CEvent3dMouseListener::_Speed [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 272 of file event_mouse_listener.h. +

+Referenced by getViewMatrix(), and setSpeed().

+

+ + + + +
+ + +
bool NL3D::CEvent3dMouseListener::_TranslateXYInWorld [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 275 of file event_mouse_listener.h. +

+Referenced by CEvent3dMouseListener(), enableTranslateXYInWorld(), isTranslateXYInWorldEnabled(), and operator()().

+

+ + + + +
+ + +
NL3D::CViewport NL3D::CEvent3dMouseListener::_Viewport [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 266 of file event_mouse_listener.h. +

+Referenced by CEvent3dMouseListener(), operator()(), and setViewport().

+

+ + + + +
+ + +
float NL3D::CEvent3dMouseListener::_X [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 270 of file event_mouse_listener.h. +

+Referenced by operator()().

+

+ + + + +
+ + +
bool NL3D::CEvent3dMouseListener::_XModelTranslateEnabled [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 257 of file event_mouse_listener.h. +

+Referenced by enableModelTranslationAxis(), isModelTranslationEnabled(), and truncateVect().

+

+ + + + +
+ + +
float NL3D::CEvent3dMouseListener::_Y [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 271 of file event_mouse_listener.h. +

+Referenced by operator()().

+

+ + + + +
+ + +
bool NL3D::CEvent3dMouseListener::_YModelTranslateEnabled [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 258 of file event_mouse_listener.h. +

+Referenced by enableModelTranslationAxis(), isModelTranslationEnabled(), and truncateVect().

+

+ + + + +
+ + +
bool NL3D::CEvent3dMouseListener::_ZModelTranslateEnabled [private] +
+
+ + + + + +
+   + + +

+Register the listener to the server. +

+Definition at line 259 of file event_mouse_listener.h. +

+Referenced by enableModelTranslationAxis(), isModelTranslationEnabled(), and truncateVect().

+


The documentation for this class was generated from the following files: +
Generated on Tue Mar 16 06:46:28 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1