00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #pragma once
00013
00014 #include "nvsgcommon.h"
00015
00016 #include "nvsg/Camera.h"
00017
00020 namespace nvui
00021 {
00022
00024
00030 class CameraManipulator
00031 {
00032 public:
00034 NVSG_API CameraManipulator(void);
00036 NVSG_API virtual ~CameraManipulator(void);
00037
00039
00040 enum
00041 { _NO_BTN_KEY = 0x0000
00042 , _LEFT_MOUSE_BTN = 0x0001
00043 , _MIDDLE_MOUSE_BTN = 0x0002
00044 , _RIGHT_MOUSE_BTN = 0x0004
00045 , _SHIFT_KEY = 0x0100
00046 , _CONTROL_KEY = 0x0200
00047 };
00048
00050
00051 NVSG_API virtual void apply() = 0;
00052
00054
00056 NVSG_API virtual void keyDown( UINT key
00057 );
00059
00060 NVSG_API virtual void keyUp( UINT key
00061 );
00063
00064 NVSG_API virtual void keyRepeat();
00065
00067
00068 NVSG_API virtual void mouseButtonDown( UINT btn
00069 , int x
00070 , int y
00071 );
00073
00074 NVSG_API virtual void mouseButtonUp( UINT btn
00075 , int x
00076 , int y
00077 );
00079
00080 NVSG_API virtual void mouseMotion( int x
00081 , int y
00082 );
00084
00086 UINT getKeyState( void ) const;
00087
00089 void resetKeyState( void );
00090
00092
00094 UINT getButtonState( void ) const;
00095
00097 void resetButtonState( void );
00098
00100
00101 void attach( const nvsg::Camera * pCamera
00102 );
00103
00105
00108 const nvsg::Camera * getAttachedCamera( void );
00109
00111
00113 void setViewportSize( size_t width
00114 , size_t height
00115 );
00116
00117 protected:
00118 bool m_dragAndThrowAnim;
00119
00120 UINT m_buttonState;
00121 UINT m_keyState;
00122
00123 const nvsg::Camera * m_camera;
00124
00125 int m_mouseX;
00126 int m_mouseY;
00127
00128 int m_mouseXlast;
00129 int m_mouseYlast;
00130
00131 int m_mouseXstart;
00132 int m_mouseYstart;
00133
00134 size_t m_vpWidth;
00135 size_t m_vpHeight;
00136
00138
00140 NVSG_API virtual UINT convertKey(UINT key
00141 );
00142
00144
00146 NVSG_API virtual UINT convertMouseButton( UINT btn
00147 );
00148
00149 };
00150
00151 inline void CameraManipulator::attach(const nvsg::Camera * pCamera)
00152 {
00153 __TRACE();
00154
00155 if (m_camera)
00156 {
00157 m_camera->removeRef();
00158 }
00159
00160 m_camera = pCamera;
00161
00162 if (pCamera)
00163 {
00164 m_camera->addRef();
00165 }
00166 }
00167
00168 inline void CameraManipulator::setViewportSize( size_t width, size_t height )
00169 {
00170 m_vpWidth = width;
00171 m_vpHeight = height;
00172 }
00173
00174 inline const nvsg::Camera * CameraManipulator::getAttachedCamera( void )
00175 {
00176 return( m_camera );
00177 }
00178
00179 inline UINT CameraManipulator::getButtonState( void ) const
00180 {
00181 return( m_buttonState );
00182 }
00183
00184 inline UINT CameraManipulator::getKeyState( void ) const
00185 {
00186 return( m_keyState );
00187 }
00188
00189 inline void CameraManipulator::resetButtonState( void )
00190 {
00191 m_buttonState = _NO_BTN_KEY;
00192 }
00193
00194 inline void CameraManipulator::resetKeyState( void )
00195 {
00196 m_keyState = _NO_BTN_KEY;
00197 }
00198 }