CEvent3dMouseListener is a listener that handle a 3d matrix with mouse events. More...
#include <event_mouse_listener.h>
Inherits NLMISC::IEventListener, and NL3D::U3dMouseListener.
Public Member Functions | |
| CEvent3dMouseListener () | |
| Mouse mode. | |
| virtual | ~CEvent3dMouseListener () |
Setup | |
|
| |
| enum | TAxis { xAxis = 0, yAxis = 1, zAxis = 2 } |
| void | setMatrix (const NLMISC::CMatrix &matrix) |
| Set both the current view matrix to use. | |
| void | setModelMatrix (const NLMISC::CMatrix &matrix) |
| Set the model matrix only. | |
| void | setFrustrum (const CFrustum &frustrum) |
| Set the current frustrum to use. | |
| void | setViewport (const NL3D::CViewport &viewport) |
| Set the viewport in use in the window. | |
| void | setHotSpot (const CVector &hotSpot) |
| Set the current hot spot. | |
| void | setMouseMode (TMouseMode mouseMode) |
| Set the mouse mode. | |
| void | enableModelMatrixEdition (bool enable=true) |
| enable / disable model matrix edition mode. (the default deals with the with matrix) | |
| void | setModelMatrixRotationAxis (TAxis axis) |
| set the current axe of rotation for the model matrix | |
| TAxis | getModelMatrixRotationAxis (void) const |
| get the current axe of rotation for the model matrix | |
| void | enableModelTranslationAxis (TAxis axis, bool enabled) |
| enable / disable an axe for translation (model matrix) | |
| bool | isModelTranslationEnabled (TAxis axis) |
| check whether translation on the given axis is permitted | |
| void | setModelMatrixTransformMove (const NLMISC::CMatrix &transModelMove) |
| Each move of the modelMatrix is first transformed by this matrix before applying. | |
| void | getModelMatrixTransformMove (NLMISC::CMatrix &transModelMove) const |
| see setModelMatrixTransformMove | |
| void | enableTranslateXYInWorld (bool enabled) |
| if true, XY translation is made in XY World plane (instead of XY view plane). | |
| bool | isTranslateXYInWorldEnabled () const |
| void | setSpeed (float speed) |
| Set the speed for first person mode. | |
Get | |
|
| |
| TAxis | _CurrentModelRotationAxis |
| bool | _XModelTranslateEnabled |
| bool | _YModelTranslateEnabled |
| bool | _ZModelTranslateEnabled |
| CMatrix | _Matrix |
| CMatrix | _ModelMatrix |
| bool | _EnableModelMatrixEdition |
| CFrustum | _Frustrum |
| CVector | _HotSpot |
| NL3D::CViewport | _Viewport |
| bool | _LeftPushed |
| bool | _MiddlePushed |
| bool | _RightPushed |
| float | _X |
| float | _Y |
| float | _Speed |
| uint64 | _LastTime |
| TMouseMode | _MouseMode |
| bool | _TranslateXYInWorld |
| NLMISC::CEventListenerAsync | _AsyncListener |
| CMatrix | _ModelMatrixTransformMove |
| const NLMISC::CMatrix & | getViewMatrix () |
| Get the current view matrix. | |
| const NLMISC::CMatrix & | getModelMatrix () |
| Get the current model matrix. | |
| CVector | getHotSpot () const |
| Get the current hot spot. | |
| void | addToServer (NLMISC::CEventServer &server) |
| Register the listener to the server. | |
| void | removeFromServer (NLMISC::CEventServer &server) |
| Unregister the listener to the server. | |
| virtual void | operator() (const NLMISC::CEvent &event) |
| Internal use. | |
| void | truncateVect (CVector &v) |
| remove composant of translations that are not permitted | |
| virtual NLMISC::IEventListener & | getEventListenerInterface () |
CEvent3dMouseListener is a listener that handle a 3d matrix with mouse events.
This can be the view matrix, or the matrix of any object.
Definition at line 50 of file event_mouse_listener.h.
Definition at line 155 of file event_mouse_listener.h.
| NL3D::CEvent3dMouseListener::CEvent3dMouseListener | ( | ) |
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 shooter style is: MouseRotateView: MOUSE MOVE KeyUp: MOVE FORWARD KeyDown: MOVE BACKWARD Left: STRAF LEFT Right: STRAF RIGHT PageUp: MOVE UP PageDown: MOVE DOWN 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 38 of file event_mouse_listener.cpp.
References _EnableModelMatrixEdition, _Frustrum, _HotSpot, _LastTime, _Matrix, _ModelMatrix, _MouseMode, _TranslateXYInWorld, _Viewport, NLMISC::CTime::getLocalTime(), NLMISC::CMatrix::identity(), NL3D::CFrustum::init(), NL3D::CViewport::initFullScreen(), NL3D::U3dMouseListener::nelStyle, NLMISC::CVector::set(), and setSpeed().
| virtual NL3D::CEvent3dMouseListener::~CEvent3dMouseListener | ( | ) | [inline, virtual] |
Definition at line 86 of file event_mouse_listener.h.
| void NL3D::CEvent3dMouseListener::addToServer | ( | NLMISC::CEventServer & | server | ) |
Register the listener to the server.
Definition at line 321 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().
| void NL3D::CEvent3dMouseListener::enableModelMatrixEdition | ( | bool | enable = true |
) | [inline] |
enable / disable model matrix edition mode. (the default deals with the with matrix)
Definition at line 150 of file event_mouse_listener.h.
References _EnableModelMatrixEdition.
enable / disable an axe for translation (model matrix)
| axis | the axis to enable / diable | |
| enabled | true if the trnaslation is permitted on that axis |
Definition at line 57 of file event_mouse_listener.cpp.
References _XModelTranslateEnabled, _YModelTranslateEnabled, _ZModelTranslateEnabled, xAxis, yAxis, and zAxis.
| 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 410 of file event_mouse_listener.cpp.
References _TranslateXYInWorld.
| virtual NLMISC::IEventListener& NL3D::CEvent3dMouseListener::getEventListenerInterface | ( | ) | [inline, private, virtual] |
Implements NL3D::U3dMouseListener.
Definition at line 283 of file event_mouse_listener.h.
| CVector NL3D::CEvent3dMouseListener::getHotSpot | ( | ) | const [inline, virtual] |
Get the current hot spot.
Implements NL3D::U3dMouseListener.
Definition at line 233 of file event_mouse_listener.h.
References _HotSpot.
| const NLMISC::CMatrix& NL3D::CEvent3dMouseListener::getModelMatrix | ( | ) | [inline] |
Get the current model matrix.
Definition at line 220 of file event_mouse_listener.h.
References _ModelMatrix.
| TAxis NL3D::CEvent3dMouseListener::getModelMatrixRotationAxis | ( | void | ) | const [inline] |
get the current axe of rotation for the model matrix
Definition at line 161 of file event_mouse_listener.h.
References _CurrentModelRotationAxis.
| void NL3D::CEvent3dMouseListener::getModelMatrixTransformMove | ( | NLMISC::CMatrix & | transModelMove | ) | const |
see setModelMatrixTransformMove
Definition at line 420 of file event_mouse_listener.cpp.
References _ModelMatrixTransformMove.
| const NLMISC::CMatrix & NL3D::CEvent3dMouseListener::getViewMatrix | ( | void | ) | [virtual] |
Get the current view matrix.
Implements NL3D::U3dMouseListener.
Definition at line 339 of file event_mouse_listener.cpp.
References _AsyncListener, _LastTime, _Matrix, _MouseMode, _Speed, NL3D::U3dMouseListener::firstPerson, NLMISC::CTime::getLocalTime(), NLMISC::CMatrix::getPos(), NLMISC::CEventListenerAsync::isKeyDown(), NLMISC::KeyDOWN, NLMISC::KeyLEFT, NLMISC::KeyNEXT, NLMISC::KeyPRIOR, NLMISC::KeyRIGHT, NLMISC::KeyUP, NLMISC::CMatrix::mulVector(), NLMISC::CVector::normalize(), and NLMISC::CMatrix::setPos().
check whether translation on the given axis is permitted
| axis | the axis to check |
Definition at line 67 of file event_mouse_listener.cpp.
References _XModelTranslateEnabled, _YModelTranslateEnabled, _ZModelTranslateEnabled, xAxis, yAxis, and zAxis.
| bool NL3D::CEvent3dMouseListener::isTranslateXYInWorldEnabled | ( | ) | const [inline] |
Definition at line 193 of file event_mouse_listener.h.
References _TranslateXYInWorld.
| void NL3D::CEvent3dMouseListener::operator() | ( | const NLMISC::CEvent & | event | ) | [private, virtual] |
Internal use.
Implements NLMISC::IEventListener.
Definition at line 87 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, NL3D::U3dMouseListener::edit3d, 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::CVector::K, NLMISC::leftButton, NLMISC::CPlane::make(), NLMISC::middleButton, NL3D::U3dMouseListener::nelStyle, NLMISC::CVector::normalize(), NLMISC::CMatrix::normalize(), NLMISC::CVector::Null, NLMISC::Pi, 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::CMatrix::XYZ, NLMISC::CVector::y, NLMISC::CEventMouse::Y, yAxis, NLMISC::CVector::z, and zAxis.
| void NL3D::CEvent3dMouseListener::removeFromServer | ( | NLMISC::CEventServer & | server | ) |
Unregister the listener to the server.
Definition at line 330 of file event_mouse_listener.cpp.
References _AsyncListener, NLMISC::EventMouseDownId(), NLMISC::EventMouseMoveId(), NLMISC::EventMouseUpId(), NLMISC::EventMouseWheelId(), NLMISC::CEventListenerAsync::removeFromServer(), and NLMISC::CEventServer::removeListener().
| void NL3D::CEvent3dMouseListener::setFrustrum | ( | const CFrustum & | frustrum | ) | [inline, virtual] |
Set the current frustrum to use.
| frustrum | is the frustrum. |
Implements NL3D::U3dMouseListener.
Definition at line 114 of file event_mouse_listener.h.
References _Frustrum.
| void NL3D::CEvent3dMouseListener::setHotSpot | ( | const CVector & | hotSpot | ) | [inline, virtual] |
Set the current hot spot.
| 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. |
Implements NL3D::U3dMouseListener.
Definition at line 134 of file event_mouse_listener.h.
References _HotSpot.
| void NL3D::CEvent3dMouseListener::setMatrix | ( | const NLMISC::CMatrix & | matrix | ) | [inline, virtual] |
Set both the current view matrix to use.
| matrix | is the matrix to set. |
Implements NL3D::U3dMouseListener.
Definition at line 95 of file event_mouse_listener.h.
References _Matrix.
| 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 105 of file event_mouse_listener.h.
References _ModelMatrix.
| void NL3D::CEvent3dMouseListener::setModelMatrixRotationAxis | ( | TAxis | axis | ) | [inline] |
set the current axe of rotation for the model matrix
Definition at line 158 of file event_mouse_listener.h.
References _CurrentModelRotationAxis.
| 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 415 of file event_mouse_listener.cpp.
References _ModelMatrixTransformMove.
| void NL3D::CEvent3dMouseListener::setMouseMode | ( | TMouseMode | mouseMode | ) | [inline] |
Set the mouse mode.
| mouseMode | is the mode you want to use. |
Definition at line 144 of file event_mouse_listener.h.
References _MouseMode.
| void NL3D::CEvent3dMouseListener::setSpeed | ( | float | speed | ) | [inline, virtual] |
Set the speed for first person mode.
Default 10.f;
| speed | is in unit per second. |
Implements NL3D::U3dMouseListener.
Definition at line 200 of file event_mouse_listener.h.
References _Speed.
Referenced by CEvent3dMouseListener().
| void NL3D::CEvent3dMouseListener::setViewport | ( | const NL3D::CViewport & | viewport | ) | [inline, virtual] |
Set the viewport in use in the window.
By default, the viewport is fullwindow.
| viewport | is the viewport to use. All events outside the viewport are ignored. |
Implements NL3D::U3dMouseListener.
Definition at line 123 of file event_mouse_listener.h.
References _Viewport.
| void NL3D::CEvent3dMouseListener::truncateVect | ( | CVector & | v | ) | [private] |
remove composant of translations that are not permitted
Definition at line 79 of file event_mouse_listener.cpp.
References _XModelTranslateEnabled, _YModelTranslateEnabled, _ZModelTranslateEnabled, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.
Referenced by operator()().
Definition at line 274 of file event_mouse_listener.h.
Referenced by addToServer(), getViewMatrix(), and removeFromServer().
Definition at line 254 of file event_mouse_listener.h.
Referenced by getModelMatrixRotationAxis(), operator()(), and setModelMatrixRotationAxis().
Definition at line 261 of file event_mouse_listener.h.
Referenced by CEvent3dMouseListener(), enableModelMatrixEdition(), and operator()().
Definition at line 262 of file event_mouse_listener.h.
Referenced by CEvent3dMouseListener(), operator()(), and setFrustrum().
CVector NL3D::CEvent3dMouseListener::_HotSpot [private] |
Definition at line 263 of file event_mouse_listener.h.
Referenced by CEvent3dMouseListener(), getHotSpot(), operator()(), and setHotSpot().
uint64 NL3D::CEvent3dMouseListener::_LastTime [private] |
Definition at line 271 of file event_mouse_listener.h.
Referenced by CEvent3dMouseListener(), and getViewMatrix().
bool NL3D::CEvent3dMouseListener::_LeftPushed [private] |
Definition at line 265 of file event_mouse_listener.h.
CMatrix NL3D::CEvent3dMouseListener::_Matrix [private] |
Definition at line 259 of file event_mouse_listener.h.
Referenced by CEvent3dMouseListener(), getViewMatrix(), operator()(), and setMatrix().
Definition at line 266 of file event_mouse_listener.h.
Definition at line 260 of file event_mouse_listener.h.
Referenced by CEvent3dMouseListener(), getModelMatrix(), operator()(), and setModelMatrix().
Definition at line 276 of file event_mouse_listener.h.
Referenced by getModelMatrixTransformMove(), operator()(), and setModelMatrixTransformMove().
Definition at line 272 of file event_mouse_listener.h.
Referenced by CEvent3dMouseListener(), getViewMatrix(), operator()(), and setMouseMode().
Definition at line 267 of file event_mouse_listener.h.
float NL3D::CEvent3dMouseListener::_Speed [private] |
Definition at line 270 of file event_mouse_listener.h.
Referenced by getViewMatrix(), and setSpeed().
Definition at line 273 of file event_mouse_listener.h.
Referenced by CEvent3dMouseListener(), enableTranslateXYInWorld(), isTranslateXYInWorldEnabled(), and operator()().
Definition at line 264 of file event_mouse_listener.h.
Referenced by CEvent3dMouseListener(), operator()(), and setViewport().
float NL3D::CEvent3dMouseListener::_X [private] |
Definition at line 268 of file event_mouse_listener.h.
Referenced by operator()().
Definition at line 255 of file event_mouse_listener.h.
Referenced by enableModelTranslationAxis(), isModelTranslationEnabled(), and truncateVect().
float NL3D::CEvent3dMouseListener::_Y [private] |
Definition at line 269 of file event_mouse_listener.h.
Referenced by operator()().
Definition at line 256 of file event_mouse_listener.h.
Referenced by enableModelTranslationAxis(), isModelTranslationEnabled(), and truncateVect().
Definition at line 257 of file event_mouse_listener.h.
Referenced by enableModelTranslationAxis(), isModelTranslationEnabled(), and truncateVect().
1.6.1