void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent& event ) { if( event.ShiftDown() ) { if( event.GetWheelRotation() < 0 ) SetView3D( WXK_UP ); // move up else SetView3D( WXK_DOWN ); // move down } else if( event.ControlDown() ) { if( event.GetWheelRotation() > 0 ) SetView3D( WXK_RIGHT ); // move right else SetView3D( WXK_LEFT ); // move left } else { if( event.GetWheelRotation() > 0 ) { GetPrm3DVisu().m_Zoom /= 1.4; if( GetPrm3DVisu().m_Zoom <= 0.01 ) GetPrm3DVisu().m_Zoom = 0.01; } else GetPrm3DVisu().m_Zoom *= 1.4; DisplayStatus(); Refresh( false ); } GetPrm3DVisu().m_Beginx = event.GetX(); GetPrm3DVisu().m_Beginy = event.GetY(); }
void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent& event ) { wxSize size( GetClientSize() ); if( event.ShiftDown() ) { if( event.GetWheelRotation() < 0 ) { /* up */ SetView3D( WXK_UP ); } else { /* down */ SetView3D( WXK_DOWN ); } } else if( event.ControlDown() ) { if( event.GetWheelRotation() > 0 ) { /* right */ SetView3D( WXK_RIGHT ); } else { /* left */ SetView3D( WXK_LEFT ); } } else { if( event.GetWheelRotation() > 0 ) { g_Parm_3D_Visu.m_Zoom /= 1.4; if( g_Parm_3D_Visu.m_Zoom <= 0.01 ) g_Parm_3D_Visu.m_Zoom = 0.01; } else g_Parm_3D_Visu.m_Zoom *= 1.4; DisplayStatus(); Refresh( false ); } g_Parm_3D_Visu.m_Beginx = event.GetX(); g_Parm_3D_Visu.m_Beginy = event.GetY(); }
void EDA_3D_CANVAS::OnPopUpMenu( wxCommandEvent& event ) { int key = 0; switch( event.GetId() ) { case ID_POPUP_ZOOMIN: key = WXK_F1; break; case ID_POPUP_ZOOMOUT: key = WXK_F2; break; case ID_POPUP_VIEW_XPOS: key = 'x'; break; case ID_POPUP_VIEW_XNEG: key = 'X'; break; case ID_POPUP_VIEW_YPOS: key = 'y'; break; case ID_POPUP_VIEW_YNEG: key = 'Y'; break; case ID_POPUP_VIEW_ZPOS: key = 'z'; break; case ID_POPUP_VIEW_ZNEG: key = 'Z'; break; case ID_POPUP_MOVE3D_LEFT: key = WXK_LEFT; break; case ID_POPUP_MOVE3D_RIGHT: key = WXK_RIGHT; break; case ID_POPUP_MOVE3D_UP: key = WXK_UP; break; case ID_POPUP_MOVE3D_DOWN: key = WXK_DOWN; break; default: return; } SetView3D( key ); }
void WindowsRendererOGL2::SetViewLookAt( const Arithmetic::Vector3 &p_Position, const Arithmetic::Vector3 &p_Point, const Arithmetic::Vector3 &p_WorldUp ) { // Calculate the view vectors Arithmetic::Vector3 ViewDir; Arithmetic::Vector3 ViewRight; Arithmetic::Vector3 ViewUp; ViewDir.Copy( p_Point - p_Position ); ViewDir.Normalise( ); ViewRight.Copy( ViewDir.Cross( p_WorldUp ) ); ViewRight.Normalise( ); ViewUp.Copy( ViewRight.Cross( ViewDir ) ); ViewUp.Normalise( ); Arithmetic::Matrix3x3 Mat3; Mat3.SetRows( ViewRight, ViewUp, -ViewDir ); Arithmetic::Vector3 Position; Position.Copy( -( Mat3*p_Position ) ); // Call SetView3D to handle the rest SetView3D( ViewRight, ViewUp, -ViewDir, Position ); }
void XboxRenderer::SetViewLookAt( const Arithmetic::Vector3 &p_Position, const Arithmetic::Vector3 &p_Point, const Arithmetic::Vector3 &p_WorldUp ) { // Calculate the view vectors Arithmetic::Vector3 ViewDir; Arithmetic::Vector3 ViewRight; Arithmetic::Vector3 ViewUp; ViewDir = p_Point - p_Position; ViewDir.Normalise( ); ViewUp = p_WorldUp - p_WorldUp.Dot( ViewDir )*ViewDir; ViewUp.Normalise( ); ViewRight = ViewDir.Cross( ViewUp ); // Call SetView3D to handle setting the view matrix return SetView3D( ViewRight, ViewUp, ViewDir, p_Position ); }
void WindowsRendererOGL3::SetViewLookAt( const Arithmetic::Vector3 &p_Position, const Arithmetic::Vector3 &p_Point, const Arithmetic::Vector3 &p_WorldUp ) { // Calculate the view vectors Arithmetic::Vector3 ViewDir; Arithmetic::Vector3 ViewRight; Arithmetic::Vector3 ViewUp; // First, get the direction and normalise it ViewDir.Copy( p_Point - p_Position ); ViewDir.Normalise( ); // Next, use Gram-Schmidt orthogonalisation to get the Up vector // and normalise that ViewUp.Copy( p_WorldUp-p_WorldUp.Dot( ViewDir )*ViewDir ); ViewUp.Normalise( ); // As the previous two vectors are already normalised, there's no // need to normalise again. Just use the cross product of the // direction and up vectors to generate the new orthogonal vector ViewRight.Copy( ViewDir.Cross( ViewUp ) ); // Create the upper 3x3 matrix from the vectors (negating the // direction elements because the Z axis is pointing toward the // viewer) Arithmetic::Matrix3x3 Rot; Rot.SetRows( ViewRight, ViewUp, -ViewDir ); // Create the position from the negative of the upper 3x3 matrix // multiplied by the desired position. Arithmetic::Vector3 Position; Position.Copy( -( Rot*p_Position ) ); // Call SetView3D to handle the rest SetView3D( ViewRight, ViewUp, -ViewDir, Position ); }
void EDA_3D_CANVAS::OnChar( wxKeyEvent& event ) { SetView3D( event.GetKeyCode() ); event.Skip(); }